以下是JSF弹出窗口的代码段。它在呈现表单时正确绑定controller.text值。但是,当我们单击OK时,没有在辅助bean上设置该值。
此外,我还可以在Chrome网络工具的帖子中看到提交的表单值。
<rich:popupPanel id="revisionTextBox" width="250" height="150">
<f:facet name="header">Enter revision history text</f:facet>
<h:form method="post" action="#{controller.doSomething(this)}">
<h:panelGrid>
<h:inputTextarea
id="text"
binding="#{controller.text}"
style="border-bottom-style: none; width:100%;overflow:hidden"
disabled="false"
immediate="true"
cols="80"
value="#{controller.textValue}"
rows="7"
>
<f:ajax execute="@this @form"/>
</h:inputTextarea>
<h:panelGroup>
<h:commandButton type="button" value="OK"
onclick="#{rich:component('confirmation')}.hide();someFunction();return false" >
</h:commandButton>
<input type="button" value="Cancel"
onclick="#{rich:component('confirmation')}.hide();return false" />
</h:panelGroup>
</h:panelGrid>
</h:form>
</rich:popupPanel>
控制器
@Controller
public class TreeController implements TreeToggleListener{
private UIComponent text;
private String textValue = "HI";
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public UIComponent getText() {
return text;
}
public void setText(UIComponent text) {
this.text = text;
}
public void doAnotherSomething(){
System.out.println("hi");
}
}