• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Question on list values set on bean

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


Thanks,
Sampra



 
Saloon Keeper
Posts: 28494
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim,

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.







 
Get out of my mind! Look! A tiny ad!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic