简体   繁体   English

非ajax方法在ViewScoped托管bean中给出相同的结果

[英]Non-ajax method giving same result in ViewScoped managed bean

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. 我的UserTable托管Bean具有视图作用域。 Functionality is like when user will click on commandLink that it will my method will get details of user. 功能就像用户单击commandLink时,我的方法将获取用户的详细信息。 After getting details dataTable will hide and panel will be shown. 获取详细信息后,dataTable将隐藏并显示面板。 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. 问题在于,当用户单击任何userId(commandLink)时,他将完美地获取详细信息。 Then he can use browser back button and try to get details by clicking another userId. 然后,他可以使用浏览器的后退按钮,并尝试通过单击另一个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. 我发现在某个范围内的可管理bean中,非ajax操作方法存在此问题。 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. 提前致谢。

The back button on a keyboard doens't really invoke a NEW HTTP request. 键盘上的后退按钮实际上并不会调用新的HTTP请求。 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 请参阅: 使用键盘上的后退按钮时,jsf actionListener(param)和propertyListener之间的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM