Home Struts Struts2 Struts2uitags Doubleselect Tag (Form Tag) Example
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Doubleselect Tag (Form Tag) Example

Advertisement
In this section, we are going to describe the doubleselect tag . The doubleselect tag is a UI tag that renders two HTML select elements with second one changing displayed values depending on selected entry of first one.

Doubleselect Tag (Form Tag) Example

     

In this section, we are going to describe the doubleselect tag. The doubleselect tag is a UI tag that renders two HTML select elements with second one changing displayed values depending on selected entry of first one.

Add the following code snippet into the struts.xml file.
struts.xml

<action name="doubleselectTag">
  <result>/pages/uiTags/doubleselectTag.jsp</result>
</action>

Create a jsp using the tag <s:doubleselect> that renders two HTML select elements with second one changing displayed values depending on selected entry of first one. This tag contains various parameters:

The headerKey parameter sets the header key of the second list. Must not be empty. In our case we have set it to"1"
The headerValue parameter sets the header value of the second list.  In our case we have set it to "--- Please Select ---"
The doubleName parameter sets the name for complete component. In our case we have set it as : doubleName="dishes" 
The doubleList sets the second iterable source to populate from. In our case we have set it as :

   doubleList="top == 'Color' ? {'Black','Green','White',
  'Yellow','Red','Pink'} : { 'Apple','Banana','Grapes','Mango'}" 

doubleselectTag.jsp

<%taglib prefix="s" uri="/struts-tags" %>

<html>
  <head>
  <title>Doubleselect Tag Example!</title>
  </head>
  <body>
<h1><span style="background-color: #FFFFcc">Doubleselect Tag Example!
</span></h1>

  <s:form>
  <s:doubleselect label="Select Item"  
  headerValue="--- Please Select ---"
  headerKey="1" list="{'Color','Fruits'}" 
  doubleName="dishes" 
  doubleList="top == 'Color' ? {'Black','Green','White',
 'Yellow','Red','Pink'} : { 'Apple','Banana','Grapes','Mango'}"/>
  </s:form>
  </body>
</html>

Output of the doubleselectTag.jsp:

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 28, 2007

Ask Questions?    Discuss: Doubleselect Tag (Form Tag) Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Kutty
January 28, 2012
Error in your program

your pre defined successfull programs are not properly working. Hereafter well check and post it..
DMCA.com