如何使用f:ajax更新h:panelGroup [英] how to update h:panelGroup using f:ajax
问题描述
如何使用f:ajax更新h:panelGroup.何时,我选择h:selectBooleanCheckbox从officeAdd1获取值并将此值设置为headOfficeAdd1.am在bean中获取officeAdd1值,但我想将值更新为headOfficeAdd1.
How to update h:panelGroup using f:ajax.When, i select h:selectBooleanCheckbox getting value from officeAdd1 and set this value into headOfficeAdd1.Am getting officeAdd1 value in bean but i want to update value into headOfficeAdd1.
谢谢...
<h:form id="form">
<p:panel id="display">
<p:spacer width="20" />
<h:panelGrid columns="6">
<h:outputLabel value="Address:"
style="text-align: left;display: block;width:130px;" />
<p:inputTextarea
value="#{companyInformationBean.current.officeAdd1}"
autoResize="true" style="width:170px;" maxlength="150" />
</h:panelGrid>
<h:panelGrid columns="6">
<h:selectBooleanCheckbox id="remember"
value="#{companyInformationBean.current.checkBox}">
<f:ajax event="click" execute="@form"
listener="#{companyInformationBean.checkBoxValue}" />
</h:selectBooleanCheckbox>
<h:outputLabel value="Same as Registered Office Address"
style="text-align: left;display: block;" />
<p:spacer width="20" />
</h:panelGrid>
<p:spacer width="20" />
<h:panelGroup id="hidepanelgroup">
<h:panelGrid id="getaddress" columns="6">
<h:outputLabel value="Head Office Address:"
style="text-align: left;display: block;width:130px;" />
<p:inputTextarea id="headadd"
value="#{companyInformationBean.current.headOfficeAdd1}"
autoResize="true" style="width:170px;" maxlength="150" />
</h:panelGrid>
</h:panelGroup>
</p:panel>
</h:form>
Bean:
public void checkBoxValue()
{
if(current.getCheckBox()==true)
{
logger.info("getofadd"+current.getOfficeAdd1());
current.setHeadOfficeAdd1(current.getOfficeAdd1());
}
else
{
logger.info("checkbox value false");
}
}
推荐答案
您需要在< f:ajax render>
属性中指定要渲染的客户端ID.
You need to specify client IDs-to-render in the <f:ajax render>
attribute.
因此,假设第二个文本区域的ID为 headadd
,则应该这样做:
Thus, given that the second textarea has an ID of headadd
, this should do:
<f:ajax ... render="headadd" />
不相关与具体问题无关,将布尔值与布尔表达式中的布尔值进行比较确实没有任何意义.只需直接检查布尔值本身即可.
Unrelated to the concrete problem, comparing booleans against booleans in a boolean expression really doesn't make any sense. Just check the boolean itself directly.
if (current.getCheckBox())
顺便尝试使用自我记录的属性和方法名称.属性名称为 remember
会更合适.
By the way, try to use self-documenting property and method names. A property name of remember
would be more suitable.
这篇关于如何使用f:ajax更新h:panelGroup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!