为什么我的jsf无法执行动作doAction1,我的动作showPanel设置showPanel = true ???,
<h:form>
<h1> JSF do not post a "execute doAction1"</h1>
<a4j:commandButton action="#{sample.showPanel}" value="Show Panel"
reRender="MyPanelShow"></a4j:commandButton>
<a4j:outputPanel id="MyPanelShow" >
<rich:panel rendered="#{sample.showPanel}" id="panel1">
<h:inputText value="#{sample.name}" id="input1"></h:inputText>
<a4j:commandButton value="Ejecutar" action="#{sample.doAction1}"
reRender="MyPanelShow" id="action1"></a4j:commandButton>
</rich:panel>
</a4j:outputPanel>
</h:form>
<!-- Backing Bean-->
package py.com.roshka.jrey.uifrw.web;
import java.io.Serializable;
public class SampleBean implements Serializable{
private String name;
private boolean showPanel = false;
public String doAction1() {
name = name + " Ok";
return null;
}
public String showPanel() {
showPanel = true;
return null;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the showPanel
*/
public boolean isShowPanel() {
return showPanel;
}
/**
* @param showPanel
* the showPanel to set
*/
public void setShowPanel(boolean showPanel) {
this.showPanel = showPanel;
}
}
最佳答案
确保
rendered="#{sample.showPanel}"
提交时评估为“真”。