jsf提交按钮不起作用

时间:2010-06-15 11:16:09

标签: jsp jsf ibm-jsf

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

有人遇到过这个吗?查看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>

3 个答案:

答案 0 :(得分:2)

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

更新

我能够在JSF 1.2中用hx:jspPanel替换h:panelGroups,一切正常。呼!

答案 1 :(得分:1)

  

但如果我使用immediate="true",它就会被调用

换句话说,当在模型中未收集,验证,转换和更新非immediate输入值时,它可以正常工作。所以事情在那里失败了。我看到您添加了<h:messages/>,因此您应该收到任何验证/转换错误的通知。你也注意这个吗?

答案 2 :(得分:0)

解决方案/修复

解决方案1:JSP更改 - 需要将h:commandLink或hx:commandExButton置于hx:jspPanel循环之外。 影响:可能存在UI设计更改(外观和感觉)需要实施此解决方案。

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