Home Struts Struts Struts2.2.1 Tags Struts2.2.1 updownselect Tag Example

Ask Questions?

View Latest Questions


 
 

Struts2.2.1 updownselect Tag Example
Posted on: January 17, 2011 at 12:00 AM
Advertisement
The updownselect tag is a UI tag that creates a HTML select component with buttons to move up and down the elements in the select component.

Struts2.2.1 updownselect Tag Example

The updownselect tag is a UI tag that creates a HTML select component with buttons to move up and down the elements in the select component. When the containing form is submitted, its elements will be submitted in the order they are arranged (top to bottom).

The following Example will shows how to implement the updownselect tag in the Struts2.2.1 --

First we create a JSP file named UpDownSelectTag.jsp as follows.

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

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

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>UpdownSelect Tag Example</title>

</head>

<body>

UpdownSelect Tag Example

<s:form action="ResultUpDownSelect">

<s:updownselect

list="#{'Fun Cinema':'Fun Cinema','PVR':'PVR','WAVE':'WAVE'

,'INOX':'INOX','EROSE':'EROSE'}"

name="favMultiplex" headerKey="-1" headerValue="--- Please Select ---"

size="4" />

<s:updownselect

list="#{'Titanic':'Titanic','300':'300','Van Helsing':'Van Helsing',

'Lagaan':'Lagaan','3 Idiot':'3 Idiot'}"

name="favMovies" headerKey="-1" headerValue="--- Please Select ---"

size="4" />

<s:submit></s:submit>

</s:form>

</body>

</html>

The Struts mapping file Struts.xml is as follows-

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<constant name="struts.devMode" value="false" />

<constant name="struts.custom.i18n.resources" value="ApplicationResources" />

<package name="default" namespace="/" extends="struts-default">

<action name="UpDownSelectTag" class="roseindia.UpDownSelectTag"

method="display">

<result name="none">/UpDownSelectTag.jsp</result>

</action>

<action name="ResultUpDownSelect" class="roseindia.UpDownSelectTag">

<result name="success">/result.jsp</result>

</action>

</package>

</struts>

The action class UpDownSelectTag.java is as follows.

package roseindia;

import com.opensymphony.xwork2.ActionSupport;

public class UpDownSelectTag extends ActionSupport {

private String favMovies;

private String favMultiplex;

public String execute() throws Exception {

return SUCCESS;

}

public String getFavMultiplex() {

return favMultiplex;

}

public void setFavMultiplex(String favMultiplex) {

this.favMultiplex = favMultiplex;

}

public String getFavMovies() {

return favMovies;

}

public void setFavMovies(String favMovies) {

this.favMovies = favMovies;

}

public String display() {

return NONE;

}

}

This Program produces output on the basis of the UpDownSelect Tag  evaluation, This  give the output as-

Output:-

Download Select Source Code

Related Tags for Struts2.2.1 updownselect Tag Example:


DMCA.com