Thibaut wrote:
Thank you for your quick reply.
I use dyna form. Therefore i have to create a new instance of the dynaform.
You should never have to do this manually. Struts will create the form
for you provided your action mapping specifies the form name via the
'name' attribute.
//get the parameter I want to put by default
String secteurDefault = request.getParameter("secteur");
if(secteurDefault!=null)
{
if(form == null)
{
FormBeanConfig cfg =
mapping.getModuleConfig().findFormBeanConfig("CorrespondanceForm");
form = (CorrespondanceForm)
DynaActionFormClass.createDynaActionFormClass(cfg).newInstance();
}
//form = (DynaActionForm)form;
form.set("partner_id",secteurDefault);
}
But the "form.set ..." doesn't work. Why ?
Because you've created a form object Struts knows nothing about. As I
said above, you shouldn't need to do this. If for some reason you really
want to, you need to put the resulting form into request or session
scope so it's accessible from the JSP:
Second question : how do i put the form in a scope to be taken into
account by the jsp ?
request.setAttribute("myform", form);
L.
Thibaut wrote the following on 1/19/2006 1:09 PM:
Hi,
I'd like to choose the default value of my html:select in the action
class. What is the parameter to set ?
Set the value of the form bean property in your Action before you go
to the form and that will be the default. Or, you could even set the
value in the formBean itself if you know it's always going to be the
same default value.
ie in Action:
MyForm myForm = (MyForm)form;
myForm.setPartner_id( defaultId );
in ActionForm:
int partner_id = 20; //or whatever you want it to be
Action :
request.setAttribute("partnerslist",
getPartnerListFromDataBase(dataSource));
JSP:
<html:select property="partner_id">
<html:options collection="partnerslist" property="value"
labelProperty="label"/>
</html:select>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]