Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Assign Values in Java Bean  RSS feed

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My JSP provides several text fields for visitors to fill out. And my Java bean stores those provided information this way:

However, I have to supply a number of additional properties in the Java bean for the business tier to process. For example, the property threadType is to be assigned to zero manually and the property parentPostID is to be found from another class, how do I code them in the Java bean? Do I use get methods shown below (without set methods)?
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if threadType is a javabean property then you can assign a value directly to it once you instantiate the bean. You will have no setters then. It'd depend how your business rules are.
For example, the property threadType is to be assigned to zero manually and the property parentPostID is to be found from another class
You can also do that when you instantiate the bean using useBean tag. I don't remember the syntax correctly, but you can have a block of code that it is only executed if the container doesn't find the bean in the scope you specified in the useBean tag. Something like:

hope it helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!