I believe HDIV (www.hdiv.org) provided something like this. On Tue, Dec 23, 2008 at 3:18 PM, Givler, Eric <egiv...@state.pa.us> wrote: > Can't you do something like this: > > StringBuffer sb = new StringBuffer(255); > > Map fields = BeanUtils.describe( xmlbean ); > Iterator iter = fields.keySet().iterator(); > while (iter.hasNext()) { > String key = (String) iter.next(); > String value = String.valueOf( fields.get( key ) ) ; > if (value != null && ! value.trim().equals("") ) { > sb.append( key.charAt(0) ); // use first letter > sb.append( "=" ); > sb.append( URLEncoder.encode( value, "UTF-8" ) ); > sb.append( "&" ); > } > } > > String queryString = sb.toString(); > queryString = queryString.substring(0, queryString.length() -1); > > ActionForward fwd = new ActionForward( > mapping.findForward("searchresults") ); > fwd.setPath( fwd.getPath() + "?" + queryString ); > fwd.setRedirect( true ); > return fwd; > > > -----Original Message----- > From: farmer2008 [mailto:ee...@ncf.ca] > Sent: Sunday, December 21, 2008 3:33 PM > To: user@struts.apache.org > Subject: Struts 1: how to use different parameter names from html field names > > > > Hi, > > My html form uses "get" method to send data to server to do a search. > > <html:form action="/searchresult.do" method="get"> > City: <html:text property="city"/><br/><br/> > ... > <html:submit value="Search"/> > </html:form> > > So in the result page, the url will be .../searchresult.do?city=.... > > Since the form contains many fields and some fields' values are pretty long, > I plan to use one letter to name each field so that the length of the result > url won't exceed 255 characters. E.g. if c is used to represent the city > filed, the above code would be like this: > > <html:form action="/searchresult.do" method="get"> > City: <html:text property="c"/><br/><br/> > ... > <html:submit value="Search"/> > </html:form> > > and the result page's url would be .../searchresult.do?c=..., which is what I > expect. > > Now a problem comes up. I have to use the single character to name the > property in the view and in the action form class, which is not good as it's > not meaningful. > > I'd like to use "city" to name the City field but when the form is submitted, > the result page url would use a signle character to pass the City's value, > like .../searchresult.do?c=... instead of .../searchresult.do?city=.... Is > there a way to do that? Is there a mapping between url parameter names and > html fileld names we can establish in struts 1? > > Many thanks. > > -- > View this message in context: > http://www.nabble.com/Struts-1%3A-how-to-use-different-parameter-names-from-html-field-names-tp21118866p21118866.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org