Struts2.2.1 updownselect Tag Example
Posted on: January 17, 2011 at 12:00 AM
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.ADS_TO_REPLACE_1

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

pageEncoding="UTF-8"%>

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

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

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

<html>ADS_TO_REPLACE_3

<head>

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

<title>UpdownSelect Tag Example</title>ADS_TO_REPLACE_4

</head>

<body>

UpdownSelect Tag ExampleADS_TO_REPLACE_5

<s:form action="ResultUpDownSelect">

<s:updownselect

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

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

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

size="4" />ADS_TO_REPLACE_7

<s:updownselect

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

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

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

size="4" />

<s:submit></s:submit>ADS_TO_REPLACE_9

</s:form>

</body>

</html>

The Struts mapping file Struts.xml is as follows-ADS_TO_REPLACE_10

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

<!DOCTYPE struts PUBLIC

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

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

<struts>

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

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

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

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

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

method="display">

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

</action>

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

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

</action>

</package>

</struts>

The action class UpDownSelectTag.java is as follows.ADS_TO_REPLACE_16

package roseindia;

import com.opensymphony.xwork2.ActionSupport;

public class UpDownSelectTag extends ActionSupport {ADS_TO_REPLACE_17

private String favMovies;

private String favMultiplex;

public String execute() throws Exception {ADS_TO_REPLACE_18

return SUCCESS;

}

public String getFavMultiplex() {ADS_TO_REPLACE_19

return favMultiplex;

}

public void setFavMultiplex(String favMultiplex) {ADS_TO_REPLACE_20

this.favMultiplex = favMultiplex;

}

public String getFavMovies() {ADS_TO_REPLACE_21

return favMovies;

}

public void setFavMovies(String favMovies) {ADS_TO_REPLACE_22

this.favMovies = favMovies;

}

public String display() {ADS_TO_REPLACE_23

return NONE;

}

}

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

Output:-

ADS_TO_REPLACE_25

Download Select Source Code

Related Tags for Struts2.2.1 updownselect Tag Example:

Advertisements

Ads

Ads

 
Advertisement null

Ads