我在我的小程序中發現了一個問題,我想知道是否有人對如何儘可能最好地解決此問題有任何提示或建議。如何根據請求範圍的bean中的值呈現表單時提交的表單提交
我有請求範圍內的bean testBean。它包含以下內容:
public class testBean {
private boolean internal = false;
private String input = "";
public String internalTrue() {
System.out.println("Set internal true");
setInternal(true);
return null;
}
public String submitForm() {
System.out.println("");
return null;
}
public boolean isInternal() {
return internal;
}
public void setInternal(boolean internal) {
this.internal = internal;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
}
我的文件了welcomeJSF.jsp包含此:
<f:view>
<h:form>
<h:commandButton value="Set internal true" action="#{testBean.internalTrue}" />
</h:form>
<h:panelGrid columns="1" rendered="#{testBean.internal}">
<h:form>
<h:outputText value="JavaServer Faces" /><h:inputText value="#{testBean.input}" />
<h:commandButton value="Go" action="#{testBean.submitForm}" />
</h:form>
</h:panelGrid>
</f:view>
當我運行應用程序林帶有按鈕 「設置內部真」。我點擊它,並且我提供了帶有「Go」按鈕的表單。點擊「Go」不會觸發我的bean中的方法,很可能是因爲該字段實際上不再在服務器上呈現,因此它不會運行該方法。有沒有什麼聰明的解決方案?
提前,謝謝你的時間。因爲在應用請求值階段其呈現屬性的結果總是以假
感謝您爲我清理!非常好的答案 – 2009-06-17 21:11:19