Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Setting Value of html:text from a Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Setting Value of html:text from a Bean" Watch "Setting Value of html:text from a Bean" New topic
Author

Setting Value of html:text from a Bean

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I have a bean defined in my JSP page as
<jsp:useBean id="userDefsBean" class="com.gthought.holocron.struts.beans.UserDefsBean" scope="session"/>
And I need a value from that bean set in my <html:text.. which I have done like:
<html:text property="userdef1" name="userDefsBean" value="userDef1" />
where userDef1 is one of my Bean properties. If I use a regular non struts html tag with a jsp:usebean like so:
<input name='userdef1' type='text' size="35" value='<jsp:getProperty name="userDefsBean" property="userDef1"/>'>
it works just fine. So am I doing something wrong the STRUTS way?
[ October 02, 2003: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Let me explain a little more about what I am doing. Maybe I am going about this wrong in the first place.
I have a database table called userdefs_table. This basically has a userid column and 10 colums labeled userdef1 - userdef10. Each user has their own 10 User Defined Elements that they can name whatever they want.
I have a form called AddReference where there are some static fields as well as the 10 User Defined Fields. So when this form is pulled up, the Labels for the 10 User Defined fields are given the values of the 10 entries found in the userdefs_table for the specific user. This is no big deal. I am using a plain JavaBean with getters and setters for each of those 10 fields. I gather this information when the user logs into the app and store it in the Session.
So the problem I am having is with the form called ModifyProfile which allows the user to define those user defined labels with whatever text they want (URL, Email, Page, etc). Anything they want, they just put that in the text fields and click update. I then update my JavaBean with the most current values.
Now, when I load this form, before I converted to struts, I used the JavaBean I created to prefill the values of each textfield with the current properties of the Bean. That way, the user can see what they have defined as what.
This is why I need to get those Bean elements and prefill the values of each text field when the form loads.
What I am worried about is that this is going to conflict with my ActionForm, which is really a DynaValidatorForm because it was so simple. Am I going about this the wrong way? Is there a better way to do this?
Any input to this would be greatly appreciated.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ok, I figured out the whole tag problem and I am getting the value I need. I am however still curious as to other opinions/options on this approach.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Value of html:text from a Bean
 
Similar Threads
dynamic beans
How to display string array value in jsp for html:text box
Problem in hiding the row of data
useBean in JSP for bean within a bean
Using struts tag, retrieve value from Map & Vector