Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts, How to get at bean properties

Reply
Thread Tools

Struts, How to get at bean properties

 
 
Dave
Guest
Posts: n/a
 
      07-13-2004
I think this is a simple struts question....

I want to display information on a page in a static way. That is, not
as part of text elements. I can't find an appropriate struts tag to
use.

This what I did find. The form bean will be named the same as the
"name" attribute of the <form-bean> element in the struts-config.xml.

So if I have a form bean with 2 string properties, such as str1 and
str2, I can get the values on my jsp this way:

<jsp:useBean
id="DataForm"
scope="session"
type="com.mycompany.DataForm" />
...
<p>Str1 : <%=DataForm.getStr1()%></p>
<p>Str2 : <%=DataForm.getStr2()%></p>

But that doesn't seem like the right way to do this. I expected some
kind of special tag that I'll call "getprop":

<p>Str1 : <html:getprop property="str1"></p>
<p>Str2 : <html:getprop property="str2"></p>

What is the right way to do this?
 
Reply With Quote
 
 
 
 
Murray
Guest
Posts: n/a
 
      07-13-2004

"Dave" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed).. .
> I think this is a simple struts question....
>
> I want to display information on a page in a static way. That is, not
> as part of text elements. I can't find an appropriate struts tag to
> use.
>
> This what I did find. The form bean will be named the same as the
> "name" attribute of the <form-bean> element in the struts-config.xml.
>
> So if I have a form bean with 2 string properties, such as str1 and
> str2, I can get the values on my jsp this way:
>
> <jsp:useBean
> id="DataForm"
> scope="session"
> type="com.mycompany.DataForm" />
> ...
> <p>Str1 : <%=DataForm.getStr1()%></p>
> <p>Str2 : <%=DataForm.getStr2()%></p>
>
> But that doesn't seem like the right way to do this. I expected some
> kind of special tag that I'll call "getprop":
>
> <p>Str1 : <html:getprop property="str1"></p>
> <p>Str2 : <html:getprop property="str2"></p>
>
> What is the right way to do this?


<bean:write name="DataForm" property="str1"/>


 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      07-13-2004
In article <40f3e814$0$16103$(E-Mail Removed)> ,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> <bean:write name="DataForm" property="str1"/>


Thank you so much!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Framework for mapping bean properties from one bean to another cmi@ch.ibm.com Java 0 04-10-2006 07:33 AM
[HELP] Bean Newbie: C++ library to Java bean. How? Takeshi Java 0 01-28-2004 11:36 AM
Differnce between Java Bean and Enterprise Java Bean Markku Salminen Java 3 01-21-2004 09:25 AM
can a session bean return a local entity bean object? David Thielen Java 2 09-12-2003 07:45 AM
To bean or not to bean... Benjamin Stewart Java 0 06-30-2003 12:34 AM



Advertisments