2 个片段之间的搜索参数

发布于 2024-11-28 04:24:27 字数 4937 浏览 0 评论 0原文

我有 2 个片段,位于 2 ui:composition 中:

(1)

     <p:panel id="pSearchParamas" >
     <div class="fieldset">
        <div class="field">
            <h:outputText id="lNickname" value="Nickname : " />
            <p:inputText id="itNickname" value="#{usersSearchController.nickname}" immediate="true"></p:inputText>
       </div>
        <div class="field">
            <h:outputText id="lDisplayName" value="Display Name :" />
            <p:inputText id="itDisplay" value="#{usersSearchController.displayname}" immediate="true"></p:inputText>
       </div>
        <div class="field">
            <h:panelGrid columns="1" style="margin-bottom:10px">
                <h:outputText id="lAge" value="Age :" />
                <br/>between<br/>
                <p:inputMask id="itAgeMin" value="#{usersSearchController.minAge}" mask="99" immediate="true" ></p:inputMask>
                <p:slider for="itAgeMin" step="5" maxValue="100" minValue="15" />
                <br/> and <br/>
                <p:inputMask id="itAgeMax" value="#{usersSearchController.maxAge}" mask="99" immediate="true" ></p:inputMask>
                <p:slider for="itAgeMax" step="5" maxValue="100" minValue="15" />
            </h:panelGrid>
       </div>
        <div class="field">
            <h:outputText id="lCountry" value="Country :" />
            <h:selectOneMenu id="somCountries" value="#{usersSearchController.countryId}" immediate="true">
                <f:selectItems value="#{countriesController.allCountriesItems}" ></f:selectItems>
            </h:selectOneMenu>
       </div>
    </div>
    <div class="AttributesArea">
        <h:outputText id="lAttributesArea" value="Attributes:"  />
    </div>
</p:panel>
        <p:commandLink id="bSearch" value="Search" action="#{usersSearchController.prepareResults}"
                       update="main:searchContentSnippet" process="pSearchParamas" ajax="true" >
        </p:commandLink>

(2)

     <p:outputPanel id="pResults" >
    <h:panelGroup rendered="#{usersSearchController.results.rowCount > 0}">
        <p:dataGrid id="dtResults"
                    value="#{usersSearchController.results}"
                    var="item"
                    rows="10" columns="10" >
            <p:column>
                <p:panel header="#{item.displayName}" style="text-align:center">
                    <h:panelGrid columns="1" style="width:100%">
                        <h:outputText value="#{item.displayName}"></h:outputText>
                        <p:graphicImage rendered="#{imagestickiesController.image != null}"
                                        value="#{imagestickiesController.image}" width="100" height="100"
                                        binding="#{imagestickiesController.imageforuserid}" >
                            <f:attribute  name="uID" value="#{item.userID}" />
                        </p:graphicImage>
                        <h:outputText id="lAboutMe" value="#{item.aboutMe}"/>
                    </h:panelGrid>
                </p:panel>
            </p:column>
        </p:dataGrid>
        <br/>
            <h:outputText value="#{usersSearchController.paginationHelper.pageFirstItem + 1}..#{usersSearchController.paginationHelper.pageLastItem + 1}/#{usersSearchController.paginationHelper.itemsCount}"/>&nbsp;
            <h:commandLink action="#{usersSearchController.previous}" value="#{bundle.Previous} #{usersSearchController.paginationHelper.pageSize}" rendered="#{usersSearchController.paginationHelper.hasPreviousPage}">
                <f:param   name="currentPageNumber" value="#{usersSearchController.paginationHelper.page}"/>
                <f:ajax render="pResults"></f:ajax>
            </h:commandLink>
                &nbsp;
            <h:commandLink action="#{usersSearchController.next}" value="#{bundle.Next} #{usersSearchController.paginationHelper.pageSize}" rendered="#{usersSearchController.paginationHelper.hasNextPage}">
                <f:param   name="currentPageNumber" value="#{usersSearchController.paginationHelper.page}"/>
                <f:ajax render="pResults"></f:ajax>
            </h:commandLink>
                &nbsp;                    
</h:panelGroup>
    <br/>
</p:outputPanel>

现在,我希望使用给定的搜索参数(来自片段 1)进行搜索并更新片段 2 (p:dataGrid) 中的值。所发生的情况是,在执行查询(运行以填充 dataGrid)后调用搜索参数的 setter 和 getter。 我正在寻找一种解决方案,使参数适合查询(必须在查询运行之前以某种方式执行设置器和获取器 - 查询在 usersSearchController.results 上运行)。

提前致谢。

I have 2 snippets, which are in 2 ui:composition :

(1)

     <p:panel id="pSearchParamas" >
     <div class="fieldset">
        <div class="field">
            <h:outputText id="lNickname" value="Nickname : " />
            <p:inputText id="itNickname" value="#{usersSearchController.nickname}" immediate="true"></p:inputText>
       </div>
        <div class="field">
            <h:outputText id="lDisplayName" value="Display Name :" />
            <p:inputText id="itDisplay" value="#{usersSearchController.displayname}" immediate="true"></p:inputText>
       </div>
        <div class="field">
            <h:panelGrid columns="1" style="margin-bottom:10px">
                <h:outputText id="lAge" value="Age :" />
                <br/>between<br/>
                <p:inputMask id="itAgeMin" value="#{usersSearchController.minAge}" mask="99" immediate="true" ></p:inputMask>
                <p:slider for="itAgeMin" step="5" maxValue="100" minValue="15" />
                <br/> and <br/>
                <p:inputMask id="itAgeMax" value="#{usersSearchController.maxAge}" mask="99" immediate="true" ></p:inputMask>
                <p:slider for="itAgeMax" step="5" maxValue="100" minValue="15" />
            </h:panelGrid>
       </div>
        <div class="field">
            <h:outputText id="lCountry" value="Country :" />
            <h:selectOneMenu id="somCountries" value="#{usersSearchController.countryId}" immediate="true">
                <f:selectItems value="#{countriesController.allCountriesItems}" ></f:selectItems>
            </h:selectOneMenu>
       </div>
    </div>
    <div class="AttributesArea">
        <h:outputText id="lAttributesArea" value="Attributes:"  />
    </div>
</p:panel>
        <p:commandLink id="bSearch" value="Search" action="#{usersSearchController.prepareResults}"
                       update="main:searchContentSnippet" process="pSearchParamas" ajax="true" >
        </p:commandLink>

(2)

     <p:outputPanel id="pResults" >
    <h:panelGroup rendered="#{usersSearchController.results.rowCount > 0}">
        <p:dataGrid id="dtResults"
                    value="#{usersSearchController.results}"
                    var="item"
                    rows="10" columns="10" >
            <p:column>
                <p:panel header="#{item.displayName}" style="text-align:center">
                    <h:panelGrid columns="1" style="width:100%">
                        <h:outputText value="#{item.displayName}"></h:outputText>
                        <p:graphicImage rendered="#{imagestickiesController.image != null}"
                                        value="#{imagestickiesController.image}" width="100" height="100"
                                        binding="#{imagestickiesController.imageforuserid}" >
                            <f:attribute  name="uID" value="#{item.userID}" />
                        </p:graphicImage>
                        <h:outputText id="lAboutMe" value="#{item.aboutMe}"/>
                    </h:panelGrid>
                </p:panel>
            </p:column>
        </p:dataGrid>
        <br/>
            <h:outputText value="#{usersSearchController.paginationHelper.pageFirstItem + 1}..#{usersSearchController.paginationHelper.pageLastItem + 1}/#{usersSearchController.paginationHelper.itemsCount}"/> 
            <h:commandLink action="#{usersSearchController.previous}" value="#{bundle.Previous} #{usersSearchController.paginationHelper.pageSize}" rendered="#{usersSearchController.paginationHelper.hasPreviousPage}">
                <f:param   name="currentPageNumber" value="#{usersSearchController.paginationHelper.page}"/>
                <f:ajax render="pResults"></f:ajax>
            </h:commandLink>
                 
            <h:commandLink action="#{usersSearchController.next}" value="#{bundle.Next} #{usersSearchController.paginationHelper.pageSize}" rendered="#{usersSearchController.paginationHelper.hasNextPage}">
                <f:param   name="currentPageNumber" value="#{usersSearchController.paginationHelper.page}"/>
                <f:ajax render="pResults"></f:ajax>
            </h:commandLink>
                                     
</h:panelGroup>
    <br/>
</p:outputPanel>

Now, I wish to make a search by using the given search paramters (from snippet 1) and update the values in snippet 2 (p:dataGrid). What happens is that the setters and getters of the search parameters are being called after the execution of the query (that runs in order to populate the dataGrid).
I'm searching for a solution that will make the parameters raedy for the query (setters and getters in some way must be executed before the query runs - the query runs on usersSearchController.results).

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩套路吗 2024-12-05 04:24:27

获得令牌和值后,您可以使用“Apache Velocity”将令牌替换为值。

Once you have the token and values, you can use "Apache Velocity" to replace the token with the values.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文