You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kazda Juraj <ka...@ditec.sk> on 2003/06/06 15:50:28 UTC

Initializing of DynaValidatorForm.

Hello everyone,

this was several times on the list, but I lost myself in all mail
archives. What doesn't work for me is this:

One of my action returns list of records. Every record is actually a
link to other action, which should have to display a form with this
records details to edit. What I need, is to fill this form with data.
The link sends a parameter with record ID and action should ask for data
from the source and fill a form with them.

Here's my code & config:

  <form-beans>
    <form-bean name="editRecForm" type="sk.jerryk.EditRecForm">
    	<form-property name="idrec" type="java.lang.Integer"/>
    	<form-property name="name" type="java.lang.String"/>
    	<form-property name="desc" type="java.lang.String"/>
    </form-bean>
  </form-beans>

  <action path="/listRec" type="sk.jerryk.ListRecsAction">
    <forward name="listRec" path="list.recs" />
  </action>
    
  <action path="/showRec" type="sk.jerryk.ShowRecAction"
scope="request">
    <forward name="showRec" path="edit.rec" />
  </action>

  <action path="/editRec" type="sk.jerryk.EditRecAction"
name="editRecForm" validate="true" input="edit.rec">
    <forward name="editRec" path="edit.rec" />
  </action>

All paths are tiles definitions.

  
<-- snippet from sk.jerryk.ShowRecAction.execute(...) -->
  ModuleConfig moduleConfig =
(ModuleConfig)request.getAttribute(Globals.MODULE_KEY);
  FormBeanConfig config =
moduleConfig.findFormBeanConfig("editRecForm");
  DynaActionFormClass dynaClass =
DynaActionFormClass.createDynaActionFormClass(config);
  DynaValidatorForm dvf = (DynaValidatorForm) dynaClass.newInstance();
  dvf.set("name", new String("Hello"));

  request.setAttribute("editRecForm", db);
  forward = mapping.findForward("showRec");
  return (forward);
<-- end snippet -->

<-- snippet from tile edit.rec -->
<html:form action="editRole" method="post">
	<table>
		<tr>
			<td><bean:message key="editRec.name"/></td>
			<td>
				<html:text property="name" />
			</td>
		</tr>
		<tr>
			<td><bean:message key="editRec.desc"/></td>
			<td>
				<html:textarea property="desc" rows="5"
cols="20" />
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<html:hidden property="idrec" />
				<html:submit value="Change" />
			</td>
		</tr>
	</table>
</html:form>
<-- end snippet -->


First, when I say that the link should goto editRec, it will never reach
the action and it goes to the input. Second, when I say that it should
go to showRec, it goes there, execute the above code, continues to
specified forward, but nothing's filled in the text box.

What should I do to make it working?

TIA and have a nice day

Best regards

-jerryk.

===============
ICQ#: 135207538
===============
 


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


Re: Initializing of DynaValidatorForm.

Posted by Gemes Tibor <ti...@i-trade.hu>.
Kazda Juraj írta:

>  <action path="/listRec" type="sk.jerryk.ListRecsAction">
>    <forward name="listRec" path="list.recs" />
>  </action>
>    
>  <action path="/showRec" type="sk.jerryk.ShowRecAction"
>scope="request">
>    <forward name="showRec" path="edit.rec" />
>  </action>
>
>  <action path="/editRec" type="sk.jerryk.EditRecAction"
>name="editRecForm" validate="true" input="edit.rec">
>    <forward name="editRec" path="edit.rec" />
>  </action>
>  
>
The forms are not in the same context.

Tib




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