You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Chelimsky <da...@chelimsky.org> on 2003/04/26 05:52:09 UTC
static resources shared across modules
Hi all,
I'm trying to common images and stylesheets across multiple modules and
I'm finding that you have to do some silly things to do this. Example:
<!-- in struts-config-myModule.xml -->
<global-forwards>
<forward
name="images"
path="/images"
contextRelative="true"
/>
<forward
name="css"
path="/css"
contextRelative="true"
/>
</global-forwards>
<!-- on a .jsp page -->
<link rel="stylesheet" type="text/css" href="<html:rewrite
forward="css"/>/myCss.css">
<img src="<html:rewrite forward="images"/>/anImage.gif">
Alternatively:
//in ApplicationResources.properties
img.myImage=/contextRoot/images/myImage.gif
<!-- on a .jsp page -->
<html:img srcKey="img.myImage"/>
Both of these solutions strike me as problematic. In the first, I've got
to write the <html:rewrite> tag in the middle of the <img> and <link>
tags. In the second, I have to write the name of my contextRoot in my
ApplicationResources file. If I decide to change the name, I'm likely to
forget to change it in the properties file. Any my coworkers are even
more likely to.
I'd much rather be able to write:
<html:image src="/images/anImage.gif" contextRelative="true"/>
Anybody have any approaches to this? Or any arguments against the notion
of adding contextRelative to the jsp tags?
Thanks,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Request[/save] does not contain handler parameter named dispatch
Posted by David Chelimsky <da...@chelimsky.org>.
Thanks James. I tried your suggestion as follows:
<!-- in the jsp -->
<html:form action="save">.....
<!-- in struts-config-user -->
<action path="save"...
and got this error:
[ServletException in:/user/form.jsp] Cannot retrieve mapping for
action /save'
Looks like struts is resolving the form action to /tools/user/save.do
even though I left the slash out. So I changed the action path back to
/save in struts-config-user.xml and left the action in the <html:form>
tag as "save" and got my original error message: Request[/save] does not
contain handler parameter named dispatch
Any other ideas?
Thx
David
James Mitchell wrote:
>On Saturday 26 April 2003 12:12 am, David Chelimsky wrote:
>
>
>>I'm converting my Struts app into Strutst 1.1 modular app. I moved my
>>user admin component to its own module and I'm experiencing a new
>>problem. I'm using a LookupDispatchAction to execute save or delete
>>methods depending on which submit button is clicked. This worked fine
>>until I separated out the user module. The thing is that I can do all of
>>the other things I was doing before w/ the user module. I can view a
>>list of users, view data for a single user that includes all of the
>>roles associated w/ that user, etc. All of that is done in true Struts
>>fashion (i.e. using Actions to pass data up to the .jsp pages). It's
>>only when I go to save the user data that this problem comes up and I
>>get this error:
>>
>>Request[/save] does not contain handler parameter named dispatch
>>
>>Thanks in advance for your advice.
>>
>>David
>>
>>****************
>>
>><!-- on the jsp -->
>><html:submit property="dispatch" styleClass="formbutton">
>> <bean:message key="user.form.button.save"/>
>></html:submit>
>><html:submit property="dispatch" styleClass="formbutton">
>> <bean:message key="user.form.button.delete"/>
>></html:submit>
>><html:reset styleClass="formbutton" value="Cancel"/>
>>
>><!-- in struts-config-user.xml -->
>> <action
>> path="/save"
>> type="org.chelimsky.user.UserSaveAction"
>> name="userForm"
>> scope="request"
>> input=".userEdit"
>> parameter="dispatch">
>>
>>
> ^^^^^^^^
>Isn't that supposed to be "save"?
>
>
>
>
>> <forward name="userSaved" path="/list.do" />
>> <forward name="userDelete" path="/edit.do" />
>> </action>
>>
>>/* in the UserSaveAction.java file */
>>public class UserSaveAction extends LookupDispatchAction {
>>
>> public UserSaveAction() { }
>>
>> protected Map getKeyMethodMap() {
>> Map map = new HashMap();
>> map.put("user.form.button.save", "save");
>> map.put("user.form.button.delete", "delete");
>> return map;
>> }
>>
>> public ActionForward save (
>> ActionMapping mapping,
>> ActionForm form,
>> HttpServletRequest request,
>> HttpServletResponse res
>> ) throws ServletException {
>> ......
>>
>> public ActionForward delete (
>> ActionMapping mapping,
>> ActionForm form,
>> HttpServletRequest request,
>> HttpServletResponse res
>> ) throws ServletException {
>> ......
>>
>>// in ApplicationResources.properties
>>
>>user.form.button.save=Save
>>user.form.button.delete=Delete
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Request[/save] does not contain handler parameter named dispatch
Posted by James Mitchell <jm...@apache.org>.
On Saturday 26 April 2003 12:12 am, David Chelimsky wrote:
> I'm converting my Struts app into Strutst 1.1 modular app. I moved my
> user admin component to its own module and I'm experiencing a new
> problem. I'm using a LookupDispatchAction to execute save or delete
> methods depending on which submit button is clicked. This worked fine
> until I separated out the user module. The thing is that I can do all of
> the other things I was doing before w/ the user module. I can view a
> list of users, view data for a single user that includes all of the
> roles associated w/ that user, etc. All of that is done in true Struts
> fashion (i.e. using Actions to pass data up to the .jsp pages). It's
> only when I go to save the user data that this problem comes up and I
> get this error:
>
> Request[/save] does not contain handler parameter named dispatch
>
> Thanks in advance for your advice.
>
> David
>
> ****************
>
> <!-- on the jsp -->
> <html:submit property="dispatch" styleClass="formbutton">
> <bean:message key="user.form.button.save"/>
> </html:submit>
> <html:submit property="dispatch" styleClass="formbutton">
> <bean:message key="user.form.button.delete"/>
> </html:submit>
> <html:reset styleClass="formbutton" value="Cancel"/>
>
> <!-- in struts-config-user.xml -->
> <action
> path="/save"
> type="org.chelimsky.user.UserSaveAction"
> name="userForm"
> scope="request"
> input=".userEdit"
> parameter="dispatch">
^^^^^^^^
Isn't that supposed to be "save"?
> <forward name="userSaved" path="/list.do" />
> <forward name="userDelete" path="/edit.do" />
> </action>
>
> /* in the UserSaveAction.java file */
> public class UserSaveAction extends LookupDispatchAction {
>
> public UserSaveAction() { }
>
> protected Map getKeyMethodMap() {
> Map map = new HashMap();
> map.put("user.form.button.save", "save");
> map.put("user.form.button.delete", "delete");
> return map;
> }
>
> public ActionForward save (
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse res
> ) throws ServletException {
> ......
>
> public ActionForward delete (
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse res
> ) throws ServletException {
> ......
>
> // in ApplicationResources.properties
>
> user.form.button.save=Save
> user.form.button.delete=Delete
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Request[/save] does not contain handler parameter named dispatch
Posted by David Chelimsky <da...@chelimsky.org>.
I'm converting my Struts app into Strutst 1.1 modular app. I moved my
user admin component to its own module and I'm experiencing a new
problem. I'm using a LookupDispatchAction to execute save or delete
methods depending on which submit button is clicked. This worked fine
until I separated out the user module. The thing is that I can do all of
the other things I was doing before w/ the user module. I can view a
list of users, view data for a single user that includes all of the
roles associated w/ that user, etc. All of that is done in true Struts
fashion (i.e. using Actions to pass data up to the .jsp pages). It's
only when I go to save the user data that this problem comes up and I
get this error:
Request[/save] does not contain handler parameter named dispatch
Thanks in advance for your advice.
David
****************
<!-- on the jsp -->
<html:submit property="dispatch" styleClass="formbutton">
<bean:message key="user.form.button.save"/>
</html:submit>
<html:submit property="dispatch" styleClass="formbutton">
<bean:message key="user.form.button.delete"/>
</html:submit>
<html:reset styleClass="formbutton" value="Cancel"/>
<!-- in struts-config-user.xml -->
<action
path="/save"
type="org.chelimsky.user.UserSaveAction"
name="userForm"
scope="request"
input=".userEdit"
parameter="dispatch">
<forward name="userSaved" path="/list.do" />
<forward name="userDelete" path="/edit.do" />
</action>
/* in the UserSaveAction.java file */
public class UserSaveAction extends LookupDispatchAction {
public UserSaveAction() { }
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("user.form.button.save", "save");
map.put("user.form.button.delete", "delete");
return map;
}
public ActionForward save (
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse res
) throws ServletException {
......
public ActionForward delete (
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse res
) throws ServletException {
......
// in ApplicationResources.properties
user.form.button.save=Save
user.form.button.delete=Delete
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org