• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

h:inputHidden and request scoped Managed Beans

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a managed bean I have configured in faces-config for request scope.

I have a page that uses it to load, but I need to recreate it on the next post.

I had thought that all I needed to do was the following:

<h:inputHidden value="#{mymanagedbean.aproperty}"/>

I later have another tag:

<h:commandLink action="#{anothermanagedbean.dosomething}">

In the dosomething method, I look in the requestMap for the managed bean "mymanagedbean" but it is not there. I had assumed that the JSF controller would rebuild it (and then set the property "aproperty" to the value it had before.)

Is there some minor problem in my approach -- or is there another established way of recreating request-scoped managed beans?

Thanks,
ken
[ May 11, 2006: Message edited by: Ken D Clark ]
 
Ken D Clark
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added immediate=true to inputHidden, and that at least ensures that the managed bean exists, but the property aproperty is not yet set when my other managed bean first gets called.

It turns out that the first calls to the other managed bean (which is handling the model for a dataTable):

<h ataTable id="myTable" ... rows="#{myTable.noOfRows}"

are for the method noOfRows.

Unfortunately, in this case, the value of that is dependent on reloading data as keyed by the value of aProperty.

In fact, the getNoOfRows method is called 16 times in all, and the first 4 times aProperty has not been set. Everything seems to work out ok regardless, so apparently returning a zero those first 4 times has no ill effect (so I am not sure why it is called at all.)

Is it possible to force the controller to set the inputHidden value prior to executing the dataTable methods?

Note: I am using MyFaces 1.1

Thanks,
ken
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have couple of options here,

1] First, the easiest option is to use the plain vanilla request parameter idea and the scriptlet tags in JSF page

<INPUT type="hidden" name="aproperty" value='<%= request.getParameter("aproperty") %>'>

2] The second one which you are trying to use is
<h:inputHidden value="#{mymanagedbean.aproperty}" id="aproperty"/>
With this you would need to find the component with the id "aproperty" in the JSF tree. This requires more work but is pure JSF.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic