velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shankar Banerjee <sbaner...@casecentral.com>
Subject Re: Map-backed ActionFrom with velocity
Date Wed, 22 Sep 2004 17:26:59 GMT
Shinobu Kawai <shinobu.kawai <at> gmail.com> writes:

> 
> Hi Shankar,
> 
> > the form. Now, I am trying to use a map-backed ActionForm with the same
> > velocity module and I have doen the various steps:
> > Defined a DynamicActionForm with a map field and getValue , setValue
> > configured the ActionForm in struts-config.xml using <FormBean tag and then
> > referred it by the name in the corresponding <Action tag. The problem is 
that
> > its not autoloading the form fields from the screen. That is, whatever I 
type
> > in on the screen is not getting into the ActionForm inside the execute 
method
> > of the corresponding Action. Everything works fine when I use static 
formbean.
> > Any idea or clue what might be happening ?
> Can you share with us how you did it?  A minimal sample code to
> reproduce your problem would be nice.  (I didn't know you could
> configure getter/setter methods for DynaActionForm via the
> struts-config.xml...)
> 
> Best regards,


Hi Shinobu,

Here are the code and config snippets that I used. Also I am using a map-
backed ActionForm and not a DynaActionForm. I think the name that I am using 
DynamicActionForm has confused you. But thats just a name this is an 
ActionForm that has a Map to contain all the field values in the html form.
I am trying to submit the Form from a velocity module and I do not see 
the auto population happening : 

The velocity fragment looks is asfollows: 
<form id="searchform" 
   method="POST" 
   target="top" 
   action="$link.setAction('/SearchSubmit')"> 

Search for: <input name="searchCriteria" size=20 
type="text" value="$!searchForm.value("searchCriteria")"> 
<input name="searchType" size=20 type="text" 
value="$!searchForm.value("searchType")"> 
<br><br> 
<input type="submit" value="Search Now"> 

</form> 

The ActionForm class is as follows: 
public class DynamicActionForm extends ActionForm 
{ 
private Map values = new HashMap(); 
public DynamicActionForm() { 
super(); 
} 

/*public void setMap(Map aMap) 
{ 
values = aMap; 
} 
public Map getMap() 
{ 
return values; 
}*/ 
public void setValue(String key, Object value) { 
values.put(key, value); 
} 

public Object getValue(String key) { 
return values.get(key); 
} 
public void reset( 
ActionMapping arg0, 
HttpServletRequest arg1) { 
/*setValue("searchCriteria", 
"Bill Clinton"); 
setValue("searchType", 
"Advanced"); 
arg1.setAttribute( 
"TOP_MAP",values); */ 

} 


} 

struts-confgi.xml is as follows: 

<form-bean 
name="searchForm" 
type="com.casecentral.search.DynamicActionForm"/> 
</form-beans> 

Anybody has any idea what might be going wrong ? Appreciate 
any feedback. 

Thanks 
--Shankar




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message