aspose file tools*
The moose likes Struts and the fly likes doubleselect tag in Struts 2.1.6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "doubleselect tag in Struts 2.1.6" Watch "doubleselect tag in Struts 2.1.6" New topic
Author

doubleselect tag in Struts 2.1.6

shivdayal Kushwaha
Greenhorn

Joined: Feb 07, 2009
Posts: 4
i am try to list out data in a combobox using struts 2.1.6 but not able to run it pleasae help me...

My comboboxTag.jsp class like this..

<html>
<head>
<title>Combobox (Form Tag) Tag Example!</title>
<link href="<s:url value="/css/main.css"/>" rel="stylesheet"
type="text/css"/>
</head>
<body>
<h1><span style="background-color: #FFFFcc">Combobox Tag Example!</span></h1>
<s:form>
<s:combobox label="Colors Name" name="colorNames"
headerValue="--- Please Select ---"
headerKey="1" list="{'Black','Green','White','Yellow',
'Red','Pink'}" /><br>

<!-- Use array list --><br>
<s:combobox label="Fruits Name" name="fruitsNames"
headerValue="--- Please Select ---"
headerKey="1" list="fruits" />
</s:form>
</body>
</html>


and my struts Actionclass like this;;

comboboxTag.java

package masterdata;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class comboboxTag extends ActionSupport
{
private List fruits;
public String execute()throws Exception{
fruits = new ArrayList();
fruits.add("Apple");
fruits.add("Mango");
fruits.add("Orange");
fruits.add("Pine Apple");
return SUCCESS;

}

public List getFruits()
{
return fruits;
}

}


and Struts.xml is like this:

<action name="comboboxTag" class="masterdata.comboboxTag">
<result>/masterdata/comboboxTag.jsp</result>
</action>

i m getting following JasperException:---

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: tag 'combobox', field 'list', name 'fruitsNames': You must specify a collection/array/map/enumeration/iterator. Example: people or people.{name} - [unknown location]
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)


root cause

tag 'combobox', field 'list', name 'fruitsNames': You must specify a collection/array/map/enumeration/iterator. Example: people or people.{name} - [unknown location]
org.apache.struts2.components.Component.fieldError(Component.java:230)
org.apache.struts2.components.Component.findValue(Component.java:351)
org.apache.struts2.components.ComboBox.findListValue(ComboBox.java:156)
org.apache.struts2.components.ComboBox.evaluateExtraParams(ComboBox.java:115)
org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
org.apache.struts2.components.UIBean.end(UIBean.java:510)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.masterdata.comboboxTag_jsp._jspx_meth_s_005fcombobox_005f1(comboboxTag_jsp.java:203)
org.apache.jsp.masterdata.comboboxTag_jsp._jspx_meth_s_005fform_005f0(comboboxTag_jsp.java:137)
org.apache.jsp.masterdata.comboboxTag_jsp._jspService(comboboxTag_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.14




please help me i am stucking with problem last 15 days....
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags--without them it's much harder to read code and configs.

15 days? That's amazing. I think I would have asked sooner.

You're providing a "name" for the combobox. S2 is trying to use that value to pre-populate the combobox. Your action doesn't have a fruitNames property, so it throws an exception. Create a fruitNames property.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubleselect tag in Struts 2.1.6
 
Similar Threads
Select Tag Problem
populate items using struts2 <s:select>
How to display a list box with values from an "Array List" in "Struts2"
Struts 2 - page error
s:select Error The requested list key 'encoder' could not be resolved as a collection