File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Populating actionform elements outside html:form etc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Populating actionform elements outside html:form etc" Watch "Populating actionform elements outside html:form etc" New topic

Populating actionform elements outside html:form etc

darin sanana

Joined: Sep 02, 2005
Posts: 2
Hello all,

let's say I have a action form called FoobarForm that populates <html:form> but I wan't to write some of the elements outside of the form.

E.g: some static values that cannot be changed (#ID, etc ... )

Is there some way to do this ? (<bean:write name="???" .. ), or is the only way to put the FoorbarForm also to the request scope (request.setAttribute(""))

Another question is about the <logic:iterate>-tag. Is there any way to limit the amount on iterations ? For example, If I want to iterate only the first five elements.

How about a situation where there is only one element to be iterated. Do I have to use <logic:iterate> then also or is there any alternative method to print the element ?

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

You can use bean:write and specify the name of the form that you used in the struts-config.xml.
<bean:write name="myFormName" property="myValue"/>

You could also use JSTL
<c ut value='${myFormName.myValue}'/>

As far as your logic:iterate question... why would you use a collection when you know you have only one element? There's nothing to iterate over.

A good workman is known by his tools.
I agree. Here's the link:
subject: Populating actionform elements outside html:form etc
It's not a secret anymore!