I have this weird situation. I have a jsf 2.0 application, with template pages. on the header I have some links with h:link to keep the url bookmarkability and h:commandLink that I use to signin and signout.. the problem is when I navigate to a specific page via h:link let say the url become bla.jsf?uName=dino then once I'm in bla.jsf?uName=dino I click the signout button that should take me to signout.jsf wont work. in stead, it takes me to bla.jsf page without ?uName=dino.
I have no nested h:form and everything seems normal to me. is there any suggestion why its behaving like this ?
I'm sure you are asking if I have h:form on h:commandLink. yes I do have that too.here is my code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<div class="floatRight">
<h:form id="firstFormHeader" prependId="false">
<p:autoComplete id="searchInputId" size="40" style="z-index: 20;" value="#{autoComplete.text}" completeMethod="#{autoComplete.complete}"/>
<h:commandButton value="#{label.search}" action="#{autoComplete.getSearchedVideo}" />
<p:watermark for="searchInputId" value="#{label.search}" />
</h:form>
</div>
<div style="z-index: 1;" id="topsection">
<div style="position:relative; bottom:-51px;">
<div id="menu" style="height:37px;" class="title ui-widget-header">
<h:panelGrid border="0" columns="2" style="float: left;">
<h:column>
<h:panelGrid columns="2">
<h:column>
<h:form id="secondFormHeader" prependId="false" >
<h:selectOneMenu id="videoGenereHeaderId" value="#{homePageVideoLoader.videoCategory}" required="true" onchange="submit()" valueChangeListener="#{homePageVideoLoader.getSelectedCatagoryList}">
<f:selectItem id="item0" itemLabel="#{select.category}" itemValue="" />
<f:selectItem id="item1" itemLabel="#{select.animation}" itemValue="23" />
<f:selectItem id="item2" itemLabel="#{select.autos}" itemValue="15" />
<f:selectItem id="item3" itemLabel="#{select.comedy}" itemValue="10" />
<f:selectItem id="item4" itemLabel="#{select.documentary}" itemValue="19" />
<f:selectItem id="item5" itemLabel="#{select.drama}" itemValue="4" />
<f:selectItem id="item6" itemLabel="#{select.education}" itemValue="16" />
<f:selectItem id="item7" itemLabel="#{select.hiphop}" itemValue="5" />
<f:selectItem id="item8" itemLabel="#{select.guragigna}" itemValue="12" />
<f:selectItem id="item9" itemLabel="#{select.news}" itemValue="6" />
<f:selectItem id="item10" itemLabel="#{select.oldies}" itemValue="7" />
<f:selectItem id="item11" itemLabel="#{select.reggae}" itemValue="8" />
<f:selectItem id="item12" itemLabel="#{select.harari}" itemValue="13" />
<f:selectItem id="item13" itemLabel="#{select.oromigna}}" itemValue="14" />
<!-- <f:selectItem id="item7" itemLabel="#{select.entertainment}" itemValue="ent" />
<f:selectItem id="item8" itemLabel="#{select.gaming}" itemValue="gam" />
<f:selectItem id="item9" itemLabel="#{select.health}" itemValue="hea" />
<f:selectItem id="item10" itemLabel="#{select.howto}" itemValue="how" /> -->
<f:selectItem id="item14" itemLabel="#{select.music}" itemValue="3" />
<f:selectItem id="item15" itemLabel="#{select.politics}" itemValue="18" />
<!-- <f:selectItem id="item13" itemLabel="#{select.nonprofit}" itemValue="non" />
<f:selectItem id="item14" itemLabel="#{select.blog}" itemValue="blo" />
<f:selectItem id="item15" itemLabel="#{select.animals}" itemValue="anm" />
<f:selectItem id="item16" itemLabel="#{select.science}" itemValue="sci" />
<f:selectItem id="item17" itemLabel="#{select.sport}" itemValue="spo" />
<f:selectItem id="item18" itemLabel="#{select.travel}" itemValue="tra" /> -->
</h:selectOneMenu>
</h:form>
</h:column>
<h:column>
<h:outputText rendered="#{userAuthentication.userLogged and userAuthentication.user.usersValid}" value="#{label.hello} "/>
<h:link rendered="#{userAuthentication.userLogged and userAuthentication.user.usersValid}" value="#{userAuthentication.user.usersFirst}" outcome="userhome?uName=#{userAuthentication.user.usersUname}">
</h:link>
</h:column>
</h:panelGrid>
</h:column>
</h:panelGrid>
<h:panelGrid border="0" columns="2" styleClass="menuPostion">
<h:column>
<h:link outcome="home" value="#{label.home}" /> |
<h:link outcome="upload" value="#{label.upload}" /> |
<h:form id="thridFormHeader" prependId="false" >
<h:commandLink rendered="#{userAuthentication.userLogged}" value="#{label.signout}" action="#{userAuthentication.doSignOut}" immediate="true"/>
</h:form>
<h:link rendered="#{!userAuthentication.userLogged}" value="#{label.createAccount}" outcome="registration" />
<h:outputText rendered="#{!userAuthentication.userLogged}" value=" | "/>
<h:link rendered="#{!userAuthentication.userLogged}" value="#{label.signin}" outcome="signin" />
</h:column>
<h:column>
<h:form prependId="false" id="languageForm">
<h:selectOneMenu value="#{language.localeCode}" onchange="submit()"
valueChangeListener="#{language.countryLocaleCodeChanged}">
<f:selectItems value="#{language.countriesInMap}" />
</h:selectOneMenu>
</h:form>
</h:column>
</h:panelGrid>
</div>
</div>
</div>
</ui:composition>
The second <h:form>
is the one that does not work.
Update: sorry is not working. it is not even going to doSignOut method.. once I reach the page bla.jsf?uName=dino and see the source code regarding the signout link it shows me
<form id="j_idt31" enctype="application/x-www-form-urlencoded" action="/myapp/content/bla.jsf" method="post" name="j_idt31" target="">
...
and obviously bla.jsf gives me error message because it's waiting for uName to have a value. why it is doing so? is it a bug ?
Also, you might have noticed that I have h:selectOneMenu that send data to the bean when the value changes, but once I'm on bla.jsf?uName=dino and try to change the value of h:selectOneMenu it wont work for it does not redirected to the bean for some reason so is h:commandLink yet h:link(s) work fine.. how can I can resolve it BalusC.. Thank you so much for taking the time and answering by the way