【发布时间】:2017-03-04 11:26:47
【问题描述】:
我需要重置表单域并清除加载的表单值。 不过我用过-
public void refresh() {
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ViewHandler viewHandler = application.getViewHandler();
UIViewRoot viewRoot = viewHandler.createView(context, context
.getViewRoot().getViewId());
context.setViewRoot(viewRoot);
context.renderResponse(); //Optional
}
上面的代码可以工作,但是当我在 panelgroup 中使用的字段中输入值时,它不起作用。
<h:panelGroup>
<ui:repeat value="#{formDynAttrbBean.vals}" var="values">
<b:panelGrid columns="6" cellspacing="4">
<b:inputText id="label" value="">
</b:inputText>
<b:selectOneMenu value="">
<f:selectItem itemLabel="SelectType" itemValue="" />
<f:selectItems value="" />
</b:selectOneMenu>
<b:selectBooleanCheckbox value="" />
<b:commandButton actionListener="#{form.types}" />
</b:panelGrid>
</ui:repeat>
<b:commandButton tooltip="Add new attribute" tooltip-position="bottom"
iconAwesome="plus" actionListener="#{form.add}" update="@form" />
<tr />
<b:commandButton value="Save" ajax="true"
actionListener="#{form.submit}" update="@form" />
<tr />
<b:commandButton type="reset" action="#{formController.refresh}"
value="Reset">
</b:commandButton>
</h:panelGroup>
当我在面板组和重复字段中输入值时,刷新功能在这种情况下不起作用。 我只是 bootsfaces 的初学者。请建议我一种方法。提前谢谢你。
【问题讨论】:
标签: java reset bootsfaces