You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ronald Rotteveel <r....@its.tudelft.nl> on 2003/12/30 13:44:43 UTC
html:link LookupDispatchAction
Dear struts users,
In every webapplication there are links. As I read in "Struts in Action",
it's better to make links with actions.
I'm now working on some part of the application where we have to do a lot of
CRUD actions, so I want to use the LookupDispatchAction. Inserting/creating
records in the database works great now, but I also would like to use the
LookupDispatchAction for initiating the forms I'm using, but then without
having to use submit buttons.
Therefore I read some postings on this mailinglist that discussed the
opportunity to use the html:link tag to do this. Unfortunately I can't get
it working, so if somebody would have a look at the code I would be very
happy!
#### LookupDispatchAction (CustomerLookupDispatchAction) ###
public Map getKeyMethodMap()
{
Map map = new HashMap();
map.put("customer.form.button.initcreateform", "initCreateForm");
map.put("customer.form.button.initupdateform", "initUpdateForm");
map.put("form.button.create", "create");
map.put("form.button.read", "read");
map.put("form.button.update", "update");
map.put("form.button.delete", "delete");
return map;
}
public ActionForward initCreateForm(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
resetToken(request);
removeFormBean(mapping,request);
return mapping.findForward("form");
}
### JSP code (part of it) ###
<bean:define id="CustomerCreateForm"
value="customer.form.button.initcreateform"/>
<html:link action="/maintenance/lookupDispatchCustomerSubmit.do"
paramId="method" paramName="CustomerCreateForm" styleClass="tree"
transaction="true"><bean:message key="customer.form.button.initcreateform"
/></html:link>
### application.resources ###
customer.form.button.initcreateform=Add customer
customer.form.button.initupdateform=Update customer
### struts-config.xml ###
<action input=".maintenance.CustomerForm" name="CustomerForm"
parameter="method" path="/maintenance/lookupDispatchCustomerSubmit"
scope="request"
type="com.mit.op.actions.maintenance.CustomerLookupDispatchAction"
validate="true">
<forward name="form" path="/maintenance/CustomerForm.do"
redirect="false"/>
</action>
Any suggestions are welcome!
Thanks in advance!
Beste regards,
Ronald Rotteveel
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: html:link LookupDispatchAction
Posted by Kris Schneider <kr...@dotech.com>.
<bean:define id="initCreateForm">
<bean:message key="customer.form.button.initcreateform"/>
</bean:define>
<html:link action="/maintenance/lookupDispatchCustomerSubmit"
paramId="method"
paramName="initCreateForm"
styleClass="tree"
transaction="true">
<bean:write name="initCreateForm"/>
</html:link>
Another suggestion. Unless the map returned by getKeyMethodMap is dynamic,
create it once as a static field:
private static final Map KEY_METHOD_MAP = new HashMap();
static {
// populate map
}
protected Map getKeyMethodMap() {
return KEY_METHOD_MAP;
}
Quoting Ronald Rotteveel <r....@its.tudelft.nl>:
> Dear struts users,
>
> In every webapplication there are links. As I read in "Struts in Action",
> it's better to make links with actions.
>
> I'm now working on some part of the application where we have to do a lot
> of
> CRUD actions, so I want to use the LookupDispatchAction. Inserting/creating
> records in the database works great now, but I also would like to use the
> LookupDispatchAction for initiating the forms I'm using, but then without
> having to use submit buttons.
>
> Therefore I read some postings on this mailinglist that discussed the
> opportunity to use the html:link tag to do this. Unfortunately I can't get
> it working, so if somebody would have a look at the code I would be very
> happy!
>
> #### LookupDispatchAction (CustomerLookupDispatchAction) ###
> public Map getKeyMethodMap()
> {
> Map map = new HashMap();
> map.put("customer.form.button.initcreateform", "initCreateForm");
> map.put("customer.form.button.initupdateform", "initUpdateForm");
> map.put("form.button.create", "create");
> map.put("form.button.read", "read");
> map.put("form.button.update", "update");
> map.put("form.button.delete", "delete");
>
> return map;
> }
>
> public ActionForward initCreateForm(
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response)
> throws Exception
> {
> resetToken(request);
> removeFormBean(mapping,request);
>
> return mapping.findForward("form");
> }
>
> ### JSP code (part of it) ###
> <bean:define id="CustomerCreateForm"
> value="customer.form.button.initcreateform"/>
> <html:link action="/maintenance/lookupDispatchCustomerSubmit.do"
> paramId="method" paramName="CustomerCreateForm" styleClass="tree"
> transaction="true"><bean:message key="customer.form.button.initcreateform"
> /></html:link>
>
> ### application.resources ###
> customer.form.button.initcreateform=Add customer
> customer.form.button.initupdateform=Update customer
>
> ### struts-config.xml ###
> <action input=".maintenance.CustomerForm" name="CustomerForm"
> parameter="method" path="/maintenance/lookupDispatchCustomerSubmit"
> scope="request"
> type="com.mit.op.actions.maintenance.CustomerLookupDispatchAction"
> validate="true">
> <forward name="form" path="/maintenance/CustomerForm.do"
> redirect="false"/>
> </action>
>
>
> Any suggestions are welcome!
>
>
> Thanks in advance!
>
>
> Beste regards,
>
> Ronald Rotteveel
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org