html - JSF layout and templating -


i have templating search.xhtml page accept user's search term on page. after user click "search!" button, result displayed on same page, below search box, shown in simple code below.

search.xhtml:

<ui:define name="search">     <h:form id="wordform">             <h:inputtext id="word" value="#{wordcontroller.word}" />                 <h:commandbutton id="search" value="search!"                 action="#{wordcontroller.search}" />     </h:form>     </ui:define>      /*** here display search results!!! ***/    <ui:define name="searchresult">           <h:outputtext value="search results:"/>     <c:foreach items="#{wordcontroller.wordinfolist}" var="wordinfo">          <h:outputtext value="#{wordinfo.display}"             rendered="#{not empty wordinfo.display}" />           <ui:repeat value="#{wordinfo.relatedwords}" var="relatedinfo">             <h:outputlink value="index.xhtml">               <h:outputtext value="#{relatedinfo}" />               <f:param name="relatedword" value="#{relatedinfo}" />             </h:outputlink>          </ui:repeat>     </c:foreach>  /*edit: add f:medatadata tag accept parameter "relatedword" */     <f:metadata>             <f:viewparam id="related" name="relatedword"                 value="#{wordcontroller.word}" />             <f:viewaction action="#{wordcontroller.info()}" />     </f:metadata>  </ui:define> 

the layout.xhtml inserts search.xhtml page.

layout.xhtml:

 <ui:fragment rendered="#{not empty wordcontroller.word}">         <div id="searchresult">             <ui:insert name="searchresult">                              </ui:insert>         </div> </ui:fragment> 

the problem that, when user visits page, before clicks "search!" button, search results displayed teh search box, although search result empty, except string "search results: " not empty.

how can modify before user performs search, display search box. , display search results search box after user clicks search button.

thank you.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -