This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Question on list values set on bean  RSS feed

Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim and others,

I have a slightly different approach in one of my apps.

The list values(for dropdown selects) on page is created by external framework. On page display the list is set in HttpRequest by external framework and passed to bean(which has request scope). This works fine during display since I can read the value(if available) in the bean constructor.

On the submit process I call the external framework to save data. I have a callback mechanism that allows external framework to set the list value in my bean. As you know call to save happens only during invoke application phase.

The problem is I get a JSF exception during update model values phase since the list is null.

At this moment I don't want to change the approach of using external framework.

Is there anyway I can manupilate the JSF phases? I don't have much experience with custom componenets; would that help?

Please let me know.


Posts: 19996
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a strange one, and I'm not really sure what the benefit is, but any attempt to manually attach a selection list to a JSF SelectOneMenu control has major problems. The list isn't just output as a display, its backing model is also used to validate the user's selection. So if you submit a SelectOneMenu item and your selection isn't in the SelectItems collection for that control, you'll have a validation failure.

If you can obtain the list values using a web service or REST request, you can make the "get" method make that request internally to build the SelectItems model on the server side. Although I'm not 100% sure that you can make a selection model object have request scope, since it has to be present both on the outbound response for the page and the inbound request with the selection made. You may need to attach the list to something with a longer scope. In JSF2, View scope might work. In JSF1, you'd need session scope (or application scope), and since it sounds like your list is fairly dynamic, you would need to figure out when it was appropriate to fetch updates to the list.
Naveen Sampra
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your points.

I see... the list values are needed for validation phase.
Isn't this is a constraing in JSF model? I cannot defer initialization upto just before page rendering, in the case of SelectOneMenu.
This would happen if list is dynamic and is determined after invoke application phase.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!