jsf提交按钮不起作用

问题描述:

我正在使用IBM Faces Client Framework的hx:commandExButton来调用我的方法。但该方法没有被调用。但是如果我使用immediate="true"它会被调用。但是,大家都知道,我的模型不会更新,所以对我没有用处。jsf提交按钮不起作用

有没有人遇到过这个?检查hx:commandExButton id="btnSearch"

<%-- tpl:metadata --%> 
    <%-- jsf:pagecode language="java" location="/src/pagecode/view/costestimation/SearchAssignee.java" --%><%-- /jsf:pagecode --%> 
<%-- /tpl:metadata --%> 
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%><%@taglib 
    prefix="h" uri="http://java.sun.com/jsf/html"%><%@taglib 
    uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%><%@taglib 
    uri="http://java.sun.com/portlet_2_0" prefix="portlet"%><%@taglib 
    uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model" 
    prefix="portlet-client-model"%><%@page language="java" 
    contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><portlet-client-model:init> 
    <portlet-client-model:require module="ibm.portal.xml.*" /> 
    <portlet-client-model:require module="ibm.portal.portlet.*" /> 
</portlet-client-model:init> 
<portlet:defineObjects /> 
<link rel="stylesheet" type="text/css" title="Style" 
    href="../../theme/stylesheet.css"> 
<f:view> 
    <f:loadBundle var="giamsBundle" 
     basename="com.ibm.costprojectionportlet.nl.GIAMSResourceBundle" /> 
    <hx:viewFragment id="viewFragment1"> 

     <hx:scriptCollector id="scriptCollector1"> 

      <script language="JavaScript" 
       src='<%=renderResponse.encodeURL(renderRequest 
             .getContextPath() 
             + "/js/common.js")%>'></script> 

      <h:outputText value="<br/>" escape="false" /> 

      <h:outputText id="titleSearch" styleClass="outputText" 
       value="#{giamsBundle['title.search']}" escape="false"></h:outputText> 

      <h:outputText value="<br/>" escape="false" /> 

      <h:messages style="font-weight:bold;color:red;" layout="table"></h:messages> 

      <hx:panelSection styleClass="panelSection" title="SearchCriteria" 
       id="searchCriteriaPanel" initClosed="false" 
       style="border-width: thin; border-style: groove"> 
       <h:form styleClass="form" id="searchCriteriaForm"> 
        <h:messages style="font-weight:bold;color:red;" layout="table"></h:messages> 
        <h:panelGrid columns="2" cellpadding="1" border="0" width="100%"> 
         <h:column> 
          <hx:panelFormBox helpPosition="over" labelPosition="left" 
           styleClass="panelFormBox" id="formBoxLeft"> 
           <hx:formItem styleClass="formItem" id="frmLastName" 
            label="#{giamsBundle['lbl.search.lastname']}" escape="false"> 
            <h:inputText styleClass="inputText" size="20" id="txtLastName" 
             value="#{pc_SearchAssignee.assignee.lastName}"> 
            </h:inputText> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="frmHomeCountrySerial" 
            label="#{giamsBundle['lbl.search.homecountryserial']}" 
            escape="false"> 
            <h:inputText styleClass="inputText" size="20" 
             id="txtHomeCountrySerial" 
             value="#{pc_SearchAssignee.assignee.companyDetails.homeCountrySerial}"> 
            </h:inputText> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="frmHomeCountry" 
            label="#{giamsBundle['lbl.search.homecountry']}" escape="false"> 
            <h:selectOneMenu styleClass="selectOneMenu" id="ddHomeCountry" 
             value=""> 
             <f:selectItems value="#{pc_referenceData.telephoneTypeList}" /> 
            </h:selectOneMenu> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="frmHomeBusinessUnit" 
            label="#{giamsBundle['lbl.search.homebusunit']}" escape="false"> 
            <h:selectOneMenu styleClass="selectOneMenu" value="" 
             id="ddHomeBusinessUnit"> 
             <f:selectItems value="#{pc_referenceData.telephoneTypeList}" /> 
            </h:selectOneMenu> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="frmforButtons" label="" 
            escape="false"> 
            <h:panelGroup> 
             <hx:commandExButton styleClass="commandExButton" 
              id="btnSearch" value="#{giamsBundle['btn.search']}" 
              action="#{pc_SearchAssignee.searchAssignee}"> 
             </hx:commandExButton> 
             <hx:commandExButton styleClass="commandExButton" 
              id="btnCancel" value="#{giamsBundle['btn.cancel']}" 
              action="#{pc_SearchAssignee.searchAssignee}"> 
             </hx:commandExButton> 
            </h:panelGroup> 
           </hx:formItem> 

          </hx:panelFormBox> 
         </h:column> 

         <h:column> 
          <hx:panelFormBox helpPosition="over" labelPosition="left" 
           styleClass="panelFormBox" id="formBoxRight"> 

           <hx:formItem styleClass="formItem" id="frmFirstName" 
            label="#{giamsBundle['lbl.search.firstname']}" escape="false"> 
            <h:inputText styleClass="inputText" size="20" id="txtFirstName" 
             value="#{pc_SearchAssignee.assignee.firstName}"> 
            </h:inputText> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="frmHomeNotesEmail" 
            label="#{giamsBundle['lbl.search.homenotesemail']}" 
            escape="false"> 
            <h:panelGroup> 
             <h:inputText styleClass="inputText" size="20" 
              id="txtHomeNotesEmail" 
              value="#{pc_SearchAssignee.assignee.lotusNotesId}"> 
             </h:inputText> 
            </h:panelGroup> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="frmHomeLocation" 
            label="#{giamsBundle['lbl.search.homeloc']}" escape="false"> 
            <h:inputText styleClass="inputText" size="20" 
             id="txtHomeLocation" 
             value="#{pc_SearchAssignee.assignee.homeAddress.cityName}"> 
            </h:inputText> 
           </hx:formItem> 

           <hx:formItem styleClass="formItem" id="blank" label="" 
            escape="false"> 
            <h:outputText id="txtblank" escape="false"></h:outputText> 
           </hx:formItem> 

          </hx:panelFormBox> 
         </h:column> 
        </h:panelGrid> 
       </h:form> 

       <f:facet name="opened"> 
        <hx:jspPanel id="jspPanelMainOpen"> 
         <hx:graphicImageEx id="imageExMainOpen" 
          styleClass="graphicImageEx" align="middle" 
          value="/theme/img/form_header.GIF" width="100%" height="20"></hx:graphicImageEx> 

        </hx:jspPanel> 
       </f:facet> 

      </hx:panelSection> 



      <h:outputText id="titleResults" styleClass="outputText" 
       value="#{giamsBundle['lbl.search.results']}" escape="false"></h:outputText> 

      <h:outputText value="<br/>" escape="false" /> 

      <hx:dataTableEx border="0" cellspacing="2" width="100%" 
       columnClasses="columnClass1" headerClass="headerClass" 
       footerClass="footerClass" rowClasses="rowClass1, rowClass2" 
       styleClass="dataTableEx" id="searchAssignee" 
       value="#{pc_SearchAssignee.assigneeList}" var="searchitr" 
       binding="#{pc_SearchAssignee.searchDataTable}" 
       rendered="#{pc_SearchAssignee.render}"> 

       <hx:columnEx id="columnEx1"> 
        <f:facet name="header"> 
         <hx:panelBox styleClass="panelBox" id="selectPanelBox"> 
          <hx:outputSelecticons styleClass="outputSelecticons" 
           id="selectCheckBox"></hx:outputSelecticons> 
         </hx:panelBox> 
        </f:facet> 

        <hx:inputRowSelect styleClass="inputRowSelect" 
         value="#{searchitr.selected}" id="rowSelect"></hx:inputRowSelect> 
        <f:facet name="header"></f:facet> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx2"> 
        <f:facet name="header"> 
         <h:outputText id="lblEeId" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.eeid']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtEEID" 
         value="#{searchitr.employeeID}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx3"> 
        <f:facet name="header"> 
         <h:outputText id="lblFirstName" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.firstname']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtFirstName" 
         value="#{searchitr.firstName}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx4"> 
        <f:facet name="header"> 
         <h:outputText id="lblLastName" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.lastname']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtLastName" 
         value="#{searchitr.lastName}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx5"> 
        <f:facet name="header"> 
         <h:outputText id="lblHomeNotesEmail" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.homenotesemail']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtHomeNotesEmail" 
         value="#{searchitr.homeAddress.addressLine1}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx6"> 
        <f:facet name="header"> 
         <h:outputText id="lblHomeCountry" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.homecountry']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtHomeCountry" 
         value="#{searchitr.homeAddress.addressLine1}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx7"> 
        <f:facet name="header"> 
         <h:outputText id="lblHomeLocation" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.homeloc']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtHomeLocation" 
         value="#{searchitr.homeTaxID}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx8"> 
        <f:facet name="header"> 
         <h:outputText id="lblHomeBusUnit" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.homebusunit']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtHomeBusUnit" 
         value="#{searchitr.homeTaxID}"></h:inputText> 
       </hx:columnEx> 

       <hx:columnEx id="columnEx9"> 
        <f:facet name="header"> 
         <h:outputText id="lblAssignStatus" styleClass="outputText" 
          value="#{giamsBundle['lbl.search.assignmentstatus']}"></h:outputText> 
        </f:facet> 

        <h:inputText styleClass="inputText" id="dttxtAssignStatus" 
         value="#{searchitr.homeTaxID}"></h:inputText> 
       </hx:columnEx> 

      </hx:dataTableEx> 

      <h:outputText value="<br/>" escape="false" /> 

      <hx:commandExButton type="submit" styleClass="commandExButton" 
       rendered="#{pc_SearchAssignee.render}" id="btnContinue" 
       value="#{giamsBundle['btn.continue']}" 
       action="#{pc_SearchAssignee.searchAssignee}"> 
      </hx:commandExButton> 

     </hx:scriptCollector> 
    </hx:viewFragment> 
</f:view> 

但是,如果使用immediate="true"它越来越被称为

换句话说,它工作正常时,非immediate输入值没有得到收集,验证,转换和在模型中更新。所以有些失败了。我看到你已经添加了<h:messages/>,所以你应该得到任何验证/转换错误的通知。你也注意到了吗?

我有一个类似的问题,将其他人的代码从JSF 1.1升级到JSF 1.2(运行在Websphere Application Server 7.0上),导致hx:commandExButton不能调用该方法。该按钮被包含在hx:jspPanel标签中。当我删除这个标签时,按钮将起作用。不幸的是,我需要这个hx:jspPanel标签来呈现不同的主题。我想我将不得不想出不同的方式来选择主题。吮吸。

更新:

我能够更换HX:用H jspPanel:在JSF 1.2和一切工作panelGroups。呼!

+0

这个答案没有用,因为他的commandExButton不在jspPanel中... – Blaskovicz 2012-11-11 22:05:47

解决方案/修复

解决方法1:JSP变化 - 需要放置H:commandLink或HX:commandExButton的HX以外:jspPanel循环。 影响:可能会有UI设计更改(请看&的感觉)需要实施此解决方案。

解决方案2:JSP更改 - 需要用h:panelGroup替换hx:jspPanel 影响:没有UI设计更改需要实施此解决方案。