• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to learn Struts Custom Tags?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to Struts and I am trying to learn custom tags in Struts. I am finding it difficult to understand the different tags. Is there a good tutorial or article which explains with examples about the tags in Struts?

Thanks a lot,
Abi
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm not sure of a good site - I normally used the official struts site when I had a query about tags... but here are just a few basic and common tags:

** all formVariable's must exist on the form with getters/setters

TEXTFIELD
<html:text property="formVariable" size="15"/>

CHECKBOX
<html:checkbox property="booleanFormVariable"/>

DROP DOWN BOX (SET OPTIONS)
<html:select property="formVariable">

<html:option value="toBeMappedToForm">Displayed</html:option>
<html:option value="1">February</html:option>
<html:option value="2">March</html:option>
<html:option value="3">April</html:option>

</html:select>
** the form must contain a variable called formVariable wih getter/setter. If March is selected, the value of formVariable would be 2.. if Displayed was selected, the value would be toBeMappedToForm

DROP DOWN BOX (From DATABASE)
**Set a collection of objects as an attribute...

<html:select property="myFormId">
<html :o ptions collection="collectionBeans" property="beanId" labelProperty="description"/>
</html:select>

**myFormId must exist as a variable in the form with getters and setters. When getting a collection to display from the database we are generally mainly concerned with the id of the selected item, not the description - hence why that was used in this example - it doesnt have to be an id.
**beanId is the property of the object that you want set to the form. eg:
Collection of people
beanId: 1 description: Sue
beanId: 2 description: Harry
beanId: 3 description: John

If the user selects Harry, the value 2 would be set to the form on the variable formId.
beanId must be a variable in the object with a getter/setter, description must also be... obviously you can give these variables your own names.


RADIO BUTTONS
<html:radio property="radioGroupName" value="H" /> House<br>
<html:radio property="radioGroupName" value="CL" /> Cluster <br>
<html:radio property="radioGroupName" value="TH" /> Town House <br>
<html:radio property="radioGroupName" value="A" /> Apartment<br>
<html:radio property="radioGroupName" value="L" /> Land </td>

** radioGroupName should be a variable in your form with getters and setters and if the user selects Apartment, the value of radioGroupName will be set to "A"


Hope this helps and I havn't bored you to tears.
Kim
[ September 23, 2004: Message edited by: Kim Lilienfeld ]
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic