面板内的命令按钮出现问题

时间:2011-06-23 13:18:43

标签: java jsf primefaces

我有一个代码,当我从selectOneMenu中选择一个选项时,会生成一个包含Inputtext和commandButton的面板。在面板内部,commandButton不起作用的问题 当我按下按钮页面只是重新加载(我有一个3按钮生成一个PDF报告,第二个导航到另一个页面,第三个重置),我已经添加了一个按钮知道只是为了测试。 我的代码JSF ChooseKPI.xhtml:

      <h:form>

         <br></br>
         KPIs:<h:selectOneMenu  style="width:200px" immediate="true"  value="#{ToolsKPI.myChoice}" onchange="submit()"  valueChangeListener="#{BeanTest.selectChangeHandler}" required="true" >
           <f:selectItems value="#{ToolsKPI.getMyListKPI()}" />
             </h:selectOneMenu>

<p:panel header="KPI" style="margin-bottom:10px;width:450px;height:350px;" rendered="#{BeanTest.showPanelBoolClosed}" >
<h1>KPI1</h1>
<br></br> 
test <h:inputText autocomplete="on"  value="#{BeanTest.test}" />
<h:commandButton immediate="true"  action="#{BeanTools.testt}"  value="Valid" />

</p:panel>



                <p:panel rendered="#{BeanTest.showPanelBoolOpen}" >

                    <br></br>
                    <h1>KPI2</h1>
             <h:inputText value="test2" />
             <h:inputText value="test3" />
  </h:form> 

导航规则:

<navigation-rule>
    <from-view-id>ChooseKPI.xhtml</from-view-id>
            <navigation-case>
       <from-action>#{BeanTools.testt}</from-action>
       <from-outcome>true</from-outcome>
       <to-view-id>Test1.xhtml</to-view-id>
    </navigation-case>
    <navigation-case>
       <from-action>#{BeanTools.testt}</from-action>
       <from-outcome>false</from-outcome>
       <to-view-id>index.xhtml</to-view-id>
    </navigation-case>

Managed Bean:

public boolean testt()
{   
 if(test.equals("a"))

    return true;
else 
    return false;

}

我应该添加其他表格吗?如果是,我如何在导航规则中提及第二种形式?

谢谢

1 个答案:

答案 0 :(得分:0)

也许您应该尝试使用条件导航:

http://www.mkyong.com/jsf2/conditional-navigation-rule-in-jsf-2-0/

<navigation-rule>
    <from-view-id>start.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>test</from-outcome>
        <if>#{BeanTools.testt}</if>
        <to-view-id>finish.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

我不确定你是否可以使用带有from-outcome的布尔类型...我只使用/看过字符串。

相关问题