Reloading data model when page in session scope accessed.
I'm looking for a better solution to a page refresh problem I've encountered.
I am working with a POJO managed bean in Session scope which displays data for one of my domain objects. When I navigate to the page, I would like it to re-load the data for this domain object from the database and refresh the view on the page. To get this to work, I have created a hidden form element on my page. In the 'getter' for this element I make a call to refresh the data model and rely on the JSF lifecycle to call the 'getter' for my hidden field and thus refresh my page when I navigate to it.
This is now causing some difficulties when the user stays on the page and it navigates back to itself instead of coming in from another page (Data is being reset when I don't want it to be). Being fairly new to JSF, I'm sure there has got to be a better way to accomplish what I'm trying to do. Has anyone out there encountered this same situation and come up with a better solution?
Thanks in advance.
# 2
I am using JSF 1.2_04 with facelets and the 'beforePhase' and 'afterPhase' attributes of the f:view tag aren't available for some reason. They show up as unknown attributes in my IDE and when I go ahead and compile and use them, they don't call the specified methods as they should. I'm thinking that's due to facelets.
There is no 'isRenderResponse()' method that I can find. The 'getRenderResponse()' method doesn't seem to provide me with what I need. I tried calling it from the code that reloads my data only to find that my method that reloads the data doesn't always get called before the RenderResponse method has been called.
Message was edited by:
ryanskeller
# 3
> I am using JSF 1.2_04 with facelets and the
> 'beforePhase' and 'afterPhase' attributes of the
> f:view tag aren't available for some reason. They
> show up as unknown attributes in my IDE and when I go
> ahead and compile and use them, they don't call the
> specified methods as they should. I'm thinking that's
> due to facelets.
I wasn't aware of this limitation.
>
> There is no 'isRenderResponse()' method that I can
> find. The 'getRenderResponse()' method doesn't seem
> to provide me with what I need. I tried calling it
> from the code that reloads my data only to find that
> my method that reloads the data doesn't always get
> called before the RenderResponse method has been
> called.
Isn't that the point? You only want to reload the data when you are in the RenderResponse phase, otherwise use the existing data.