【问题标题】:Richfaces: rendered condition and bean with request scopeRichfaces:渲染条件和具有请求范围的 bean
【发布时间】:2011-01-07 11:20:59
【问题描述】:

为什么我的jsf不能执行动作doAction1,my action showPanel set 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;
}

}

【问题讨论】:

    标签: java jsf richfaces


    【解决方案1】:

    确定

    rendered="#{sample.showPanel}"
    

    在您提交时评估为“真”。

    【讨论】:

    • 第一个动作“showPanel”设置 showPanel=true.. 但是请求 bean 不保存带有属性的 bean 状态...提交时如何设置当前 showPanel 属性第二个动作???,你是一些例子......它是如何正确的?非常感谢。
    • 一个请求范围的 bean 将只为一个请求保存一个值。您需要使用更长的范围,例如会话、视图或对话之类的东西。
    猜你喜欢
    • 1970-01-01
    • 2012-01-19
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-21
    • 2011-11-11
    • 1970-01-01
    相关资源
    最近更新 更多