0

I have a dataTable like following

<p:dataTable value="#{userTable.tempLists}" var="user"
    sortBy="#{user.userId}" sortOrder="descending"      
    paginator="true"
    rows="10" paginatorPosition="bottom">           
    <p:column headerText="User ID" sortBy="#{user.userId}">
        <p:commandLink ajax="false" value="#{user.userId}" action="#{userTable.showDetails(user.userId)}"/>
    </p:column>
    <p:column headerText="User Name" sortBy="#{user.userName}">
        <h:outputText value="#{user.userName}">
        </h:outputText>
    </p:column>
</p:dataTable>

And I have a panel name as details like following

<p:panel>
      <h:outputText value="#{userTable.userId}"/>
      <h:outputText value="#{userTable.userName}"/>
</p:panel>

My UserTable managed bean is view scoped. Functionality is like when user will click on commandLink that it will my method will get details of user. After getting details dataTable will hide and panel will be shown. For user it almost seems like a different page.

Problem is here that when user will click any userId(commandLink) he will get details perfectly. Then he can use browser back button and try to get details by clicking another userId. But in this case user is getting same result as previous one. And nothing there in error log.

I found somewhere that in view scope managed bean this problem exist with non-ajax action method. But I need to keep it in viewscoped to maintain table state with sorting and pagination. So whenever user press back button I can show same screen before selection.

Please help. Thanks in advance.

Kush Sahu
  • 399
  • 1
  • 13
  • 33
  • I'm confused about your flow: you want the user to stay on the same page, just show different elements on it? How about having a `f:viewParam name="userId"` that when empty shows the table, and loads the user entity if not (use a `f:viewAction` if you can). – mabi Feb 07 '14 at 09:44
  • @mabi Yes you are right about implementation. But f:viewParam is used for setting values in url for get request. While in my case I have post request by command link. – Kush Sahu Feb 07 '14 at 10:38
  • And you want it to stay that way? Because if you allow back-navigation, putting that state in the URL is a good idea. – mabi Feb 07 '14 at 10:48
  • @Mabi Yes I want it to stay that way because I need to save state of table and some other fields too. and for that URL will not be a good idea. – Kush Sahu Feb 07 '14 at 11:42
  • @KushSahu - Where is your implementation of `userTable.showDetails`? – kolossus Feb 07 '14 at 14:16
  • @kolossus Its just an example. I found that problem is with view scope and non-ajax action method in this type of condition. So in implementation of userTable.showDetails you can have anything. – Kush Sahu Feb 07 '14 at 16:00

1 Answers1

0

The back button on a keyboard doens't really invoke a NEW HTTP request. Guessing this is what's going wrong. It's actually beter to use a list and details page. I've been struggling with the same error myself for some hours.

See: Difference between jsf actionListener(param) and propertyListener when using back button on keyboard

Community
  • 1
  • 1
GregD
  • 1,884
  • 2
  • 28
  • 55
  • I have some other fields which do partial request(ajax). after browser back those components stops working. It all happens after non-ajax action method and then browser back. – Kush Sahu Feb 08 '14 at 10:06
  • Could you explain this in detail with code? It's hard to figure out what's going wrong by text. – GregD Feb 08 '14 at 17:58
  • its same as given above code. You can have anything inside showDetails() method of my viewscoped managed bean UserTable. – Kush Sahu Feb 08 '14 at 22:01
  • http://stackoverflow.com/questions/10305718/avoid-back-button-on-jsf-web-application This might help you explain the behaviour. It's actually "normal" that the next click will show the previous detail. You should really consider making a list and details page. – GregD Feb 09 '14 at 13:03