struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Hodson" <d...@messagecast.net>
Subject Re: Problem populating form bean with multiple parameters of same name
Date Sun, 07 Jul 2002 05:04:34 GMT
I found the post below in the mail archives, but could not find any followups.
Anyone have an idea how to get around the issue of "how Struts can read multiple text input
fields, all with the same name (akin to ServletRequest.getParameterValues(String s) ), and

properly populate those same fields when the JSP is displayed again"?
Dave


  _____  



*	From: Steven Valin 

*	Subject: Re: Problem populating form bean with multiple parameters of same name 

*	Date: Sun, 21 Oct 2001 06:03:15 -0700 

  _____  

Renaud,



I appreciate your response, but unfortunately when the JSP is regenerated and

displayed, Struts places the toString() value of the String array into the

<html:text property="propertyName" size="20"/> tags, such as:



    [Ljava.lang.String;@262bf4



I have also tried a twist on this strategy, with:



    private String propertyName[];

    private int propertyNameIndex;



    public void setPropertyName(String[] propertyName) {

        this.propertyName = propertyName;

        propertyNameIndex = 0;

   }



    public String getPropertyName() {  // send default value if index out of

range

        return ((propertyNameIndex < propertyName.length) ?

propertyName[propertyNameIndex++] : "");

    }



I was hoping that this strategy would allow the JSP to populate each <html:text

.../> field with successive calls to getPropertyName() but this then results in:



javax.servlet.jsp.JspException: Exception thrown by getter for property fileName

of bean org.apache.struts.taglib.html.BEAN

 at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:513)





If anybody has any other ideas on how Struts can read multiple text input

fields, all with the same name (akin to ServletRequest.getParameterValues(String

s) ), and properly populate those same fields when the JSP is displayed again, I

would greatly appreciate your thoughts!



TIA, Steve





Renaud Waldura wrote:



> Have you tried declaring your property as an array of strings?

>

> private String propertyName[];

> public String[] getPropertyName() { ... }

> public void setPropertyName(String[] propertyName) { ... }

>

> It may just work. In general I've found Struts to be amazingly flexible with

> properties and their types. Kudos to the Struts developers!

>

> --Renaud

>



--

Steven Valin

steven.valin@javelinsoftware.com
---
Dave Hodson 
MessageCast, inc.
Email: dave@messagecast.net
www.messagecast.net
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message