在详细画面中,通过隐藏状态的值来控制删除按钮是否显示,当状态为”更新”时则显示删除按钮,否则不显示.
问题:当没有输入企業CD时,JSF将不执行update model values等阶段,这时value="#{REQPG010EAction.status}" 
的值为null.... <c:if....>失效了,各位,jsf怎样处理类似问题?
 <c:if test="${REQPG010EAction.status == 'update'}">
 <h:commandButton value="删除" onclick="getCtrl();" action="#{REQPG010EAction.do_delete_logic}" />
 </c:if> <h:inputHidden id="status" value="#{REQPG010EAction.status}" />
 <h:inputText id="trd_id" label="企業CD" size="40"  
      style="height: 15px;" required="true" value="#{REQPG010EAction.trd_id}">
      <gr:validateByteLength maxLength="8" />
  </h:inputText>

解决方案 »

  1.   

    1\给REQPG010EAction.status设定初始值即可。<managed-bean>
       <managed-bean-name>customer</managed-bean-name>
       <managed-bean-class>foo.Customer</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>status</property-name>
                <property-class>java.lang.String</property-class>
                <value>update</value>
            </managed-property>
    </managed-bean>
      

  2.   

    在定义status时付初值就可以了,如
    String status="";
      

  3.   

    o my god~
     <h:commandButton value="删除" onclick="getCtrl();" action="#{REQPG010EAction.do_delete_logic}" 
    rendered="#{!empty REQPG010EAction.status && REQPG010EAction.status==\"update\"}"
    /> <h:inputHidden id="status" value="#{REQPG010EAction.status}" />
     <h:inputText id="trd_id" label="企業CD" size="40"                 
          style="height: 15px;" required="true" value="#{REQPG010EAction.trd_id}">
          <gr:validateByteLength maxLength="8" />
      </h:inputText>看来你没有领会到rendered的用途