Struts, How to get at bean properties

D

Dave

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?
 
M

Murray

Dave said:
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"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,249
Members
46,846
Latest member
BettinaOsw

Latest Threads

Top