0

我有一个搜索结果,它大约是 8 - 10。我将它们列在一个页面中。当用户单击这些记录之一时,它会将输入类型隐藏发送到后台 bean。下面的代码:

 <h:commandLink action="#{clController.action()}" 
                                       value="#{item.code}" >
                                  <input type="hidden" name="address" value="#{item.address}" />
                                  <input type="hidden" name="name" value="#{item.name}" />
                                     <input type="hidden" name="taxDept" value="#{item.taxDept}" />
                        </h:commandLink>

即使我点击 8. 记录。为什么它发送到后面是第一个记录?

这是我的回豆动作功能:

 public String action() {
             address = FacesContext.getCurrentInstance().
        getExternalContext().getRequestParameterMap().get("address");
             name = FacesContext.getCurrentInstance().
        getExternalContext().getRequestParameterMap().get("name");
            taxDept = FacesContext.getCurrentInstance().
        getExternalContext().getRequestParameterMap().get("taxDept");
            System.out.print(taxDept);
            System.out.print(address);
             System.out.print(name);

             return "start";

    }

我的整个表格

 <h:form>      
            <h:panelGroup class="content ">
                <h1><span>Get Customer List
                    </span></h1>

                <h:panelGroup class="padding" id="SearchTermsText">
                    <br />

                    <h:panelGroup>
                        <h:outputLabel id="selectCity"  value="City:" /><br />
                        <h:selectOneMenu id="type0" value="#{clController.city}">
                            <f:selectItem itemValue="All" itemLabel="All" />
                            <f:selectItem itemValue="Ankara" itemLabel="Ankara" />
                            <f:selectItem itemValue="Istanbul" itemLabel="Istanbul" />
                            <f:selectItem itemValue="Izmir" itemLabel="Izmir" />

                        </h:selectOneMenu>
                    </h:panelGroup>

                    <h:outputLabel id="selectType" value="Type" /><br />
                    <h:selectOneMenu id="type" value="#{clController.type}">
                        <f:selectItem itemValue="All" itemLabel="All" />
                        <f:selectItem itemValue="Customer" itemLabel="Customer" />
                        <f:selectItem itemValue="Provider" itemLabel="Provider" />
                        <f:selectItem itemValue="Bank" itemLabel="Bank" />
                        <f:selectItem itemValue="Foundation" itemLabel="Foundation" />
                        <f:selectItem itemValue="Agent" itemLabel="Agent" />
                        <f:selectItem itemValue="Branch" itemLabel="Branch" />
                        <f:selectItem itemValue="Contact" itemLabel="Contact" />
                        <f:selectItem itemValue="Related" itemLabel="Related" />
                        <f:selectItem itemValue="Personnel" itemLabel="Personnel" />
                    </h:selectOneMenu>

                    <h:panelGroup>
                        <h:commandButton type="submit"  onclick="#{clController.getCustomer()}"  id="searchButton"  value="Search"  />
                    </h:panelGroup>
                </h:panelGroup>

                <h:dataTable  styleClass="pretty"   value="#{clController.clDataModel}" var="item">
                    <h:column headerClass="left">
                        <f:facet name="header">
                            <h:outputText value="Amount"/>
                        </f:facet>



                            <h:commandLink action="#{clController.action()}" 
                                           value="#{item.code}" >
                                      <input type="hidden" name="address" value="#{item.address}" />
                                      <input type="hidden" name="name" value="#{item.name}" />
                                         <input type="hidden" name="taxDept" value="#{item.taxDept}" />
                            </h:commandLink>





                        <br />

                        <h:outputText class="red" id="amount"   value="#{item.name}"></h:outputText> <h:outputText value="&#160;" />
                    </h:column>
                    <h:column headerClass="right" >
                        <f:facet  name="header">
                            <h:outputText value="Date"/>
                        </f:facet> 
                        <h:outputText style="float:right" value="#{item.type}" />
                    </h:column>
                </h:dataTable>

            </h:panelGroup> 

        </h:form>
4

0 回答 0