Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Value bean or backing bean?

 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Just a general query... Is it better/easier to use a backing bean (a bean that contains input objects that are "bound" to the front end screens) or a value bean (a bean that contains the "values" entered/to be displayed on the front end) to managed the front end of an application. I've tried both of them and they both seem to have pros and cons. All opinions welcome!

Cheers,

Kev
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do a slight combination of both. For very simple pages I use the managed beans that are stricktly related to the page itself. For more complex pages I'll have a managed beans but I might also have a value object that I have in the session.

For example, in one of my applications I have a page where I gather information about a Help Desk Issue. I have a VO called Issue that stores all the important information. I always have an instance of a current issue in another VO called Visit which is stored in the session. On my newissue.jsp I just update the current issue directly instead of gathering up values in the managed bean and then copying them over. So I'll have something like:

<h:inputText value="#{visit.currentIssue.machineName}" .../>

I haven't ran into any snags with this approach yet.
 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,

I have a reasonably complex page and I'm using a value bean to present data to the front end, but I'm seeing some inconsistencies... Sometimes the data is displayed correctly and sometimes it isn't. I'm wondering if I should just use a backing bean to present/receive the data and just transfer the values to/from the value bean...
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd so go with what works.

That being said, how are you storing your value bean? Session, Request, etc? When and how are you updating it?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a combination of both and seems to wrok fine till now.
Originally posted by Kev D'Arcy:
Greg,

I have a reasonably complex page and I'm using a value bean to present data to the front end, but I'm seeing some inconsistencies... ...


What kind of inconsistencies ?
 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,

I'm storing the value bean in a session object. It get's updated either via front end forms (through value links to inputs), or via code in the app to clear down values.

Kev
 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varun,

What I'm seeing is that when the value bean gets cleared down (either explicitly through the application or by going to a new page) and a user returns to the page displaying the value bean properties, some of the value beans properties don't get displayed on the JSP.

Kev
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kev D'Arcy:
Varun,

What I'm seeing is that when the value bean gets cleared down (either explicitly through the application or by going to a new page) and a user returns to the page displaying the value bean properties, some of the value beans properties don't get displayed on the JSP.

Kev


What do you mean by "cleared down" and how are they returning to the previous page? I think your problem may just be a logic issue rather than a technical issue. I have no problems updating the properties in session objects from pages or code.
 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably easier if I show you the code. Can i upload it somewhere or will I just embed it into a post?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just post the code in here. Be sure and use UBB code tags


[/code]

And disable smilies.
 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,

This is the JSP 1.:


This is an example of one of the jspfs:


And the code in the action bean:
 
Kev D'Arcy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,

What happens is that when I'm clearing down the form, I use a javascript function to clear the form values and the blank fields get sent up and handled by and "immediate" action funtion. If someone leaves this page (via a hyperlink), and then returns to it with the value bean having already been populated with new values (via the getIssueData() method), the new values are not displayed on the screen (the default values form the form clear are though).
 
Zafar Hakim
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does any one know solution to this problem. I too am facing similar problem.

Problem:
I have a page with data table --- I open a new modal dialog window (window.showModalDialog) on click of menu item on a page --> It opens the page to view details of the item. When I close it and select different row of the table and open to see the details it shows the previous data.

The data on the form fields are populated from a backing bean which is session scoped. I am sure the backing bean is updated with new data. Only that it is not displayed/refreshed in the page rendered.

Thanks for your time.

Regards,
Hakim
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not resurrect old topics nor hijack otherĀ“s topics. Start your own for each independent problem. Users here usually respond to the topicstarter only.
 
Zafar Hakim
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke,
thanks for your suggestion..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic