Skip to main content

Using Flash scope bean causing problem

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
vishi999
Offline
Joined: 2011-01-07

Hi all,

I am using JSF 2.0.3 with IceFaces 2.0.Beta2 in my application. Further, I am using Flash scope for implementing pagination as follows:

In the JSF bean, I have a method getAllUsers() which fetches the users from database and put them in Flash map as:

public String getAllUsers() {
...
FacesContext.getCurrentInstance().getExternalContext().getFlash().put("userList", userList);
...
}

In the facelet, I use the flash variable as:
<ice:form>
<ice:dataTable value="#{flash.userList}" var="item" ....>
...
...
</ice:dataTable>
...
...
<!-- the code below will make the variable available on next page-->
<c:set target="#{flash}" property="userList" value="#{flash.userList}" />
</ice:form>

On the UI I have a "Search" button which calls the bean method getAllUsers(). Next, the bean fetches users, puts the list on flash map, and finally the facelet renders it.

But, the behavior of this implementation is slightly erroneous as mentioned below:
1) I click "Search" button for the first time, the bean puts the list on flash map, but a warning is thrown on console saying "WARNING: JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored...". But still, I can see the user list on UI
2) I click on the next page (i.e. pagination link to next page), but the records are GONE (i.e. flash map has been cleared)
3) I click "Search" button again, but this time there is no any warning JSF1095 on console, and I see the user list on UI
4) I click on the next page (i.e. pagination link to next page), and now the records on next page are visible (i.e. flash map retains the list)
5) On any subsequent clicks on "Search" button, the records are visible on all pages (i.e. flash map retains the list)

So, it is only the first time that the list is not retained by flash map.

Can anyone help me with this problem!!! Is there something else that I need to do while putting the userList on flash map?

Any help is appreciated.

-vishi999

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
healeyb
Offline
Joined: 2010-01-26

I logged a fault report for this very problem with the Mojarra team some time ago but haven't
heard anything from them, although the entry is marked for resolution in v2.2, although I
don't know who updated this (it could have been a default value used when the issue
tracker was migrated for all I know). I have had nothing but problems with using the flash
and now use view parameters instead. This is a cumbersome solution involving quite a
lot of code (converters and obfuscation) but it works. Frustratingly I've never been able to
reproduce the JSF1095 error in a test environment and had to give up trying after a while.
One other point that isn't always obvious is that I think the general concensus is that the
JSTL functions like c:set don't work reliably in JSF 2.
http://java.net/jira/browse/JAVASERVERFACES-1874
Regards,
Brendan.

vishi999
Offline
Joined: 2011-01-07

Hi Brendan,
Thanks for the reply.
I just saw that JSF 2.0.4 has been released. Although I did not find the JIRA issue 1874 in the issues resolved, I will still try my app with JSF 2.0.4 (may be it works) and let you know by Monday.
Regards,
Vishal

vishi999
Offline
Joined: 2011-01-07

I tried it with JSF 2.0.4, but in vain.