At 13:45 -0700 9/18/03, Zimmerman, Steven R. wrote:
I cannot seem to get this to work
        <html:link
page="/collaborator.do?mode=edit&code=<%=code%>">Edit</html:link>

You can only use a runtime expression as the complete content of a JSP tag attribute, if at all. So, you could do something like this:


<bean:define name="temp" type="java.lang.String">/collaborator.do?mode=edit&code=<%=code%></bean:define
<html:link page="<%=temp%>">Edit</html:link>


or better yet this instead
        <html:link
action="collaborator.do?mode=edit&code=<%=code%>">Edit</html:link>

To pass parameters to URLs built from the "action" attribute, you can use paramId, paramName, paramProperty, and paramScope to pass a single parameter, or name (and optionally property) to identify a Map whose keys are parameter names and whose values are corresponding parameter values. See http://jakarta.apache.org/struts/userGuide/struts-html.html#link for details.


Actually, you can use these to pass parameters to any url, but if you use the "action" attribute, this is the only way to do it.

For what you define above, you may prefer to establish the "mode=edit" state by using a different ActionMapping. Something like:

<action path="/CollaboratorEdit" parameter="edit" type="com.example.CollaboratorAction" ... />
<action path="/CollaboratorView" parameter="view" type="com.example.CollaboratorAction" ... />


Your action class can use "mapping.getParameter()" to find out whether it's in edit or view mode just as easily as it could consult the "mode" property of an ActionForm (or the "mode" request parameter).

In my opinion, this is more elegant, and it saves the hassle of appending multiple parameters in html:link using a Map.

The <c:url> tag in the JSTL supports a <c:param> subtag for adding an arbitrary number of parameters to a URL. Of course, it doesn't know how to dereference an action path. There's been some talk about adding a similar tag in Struts, but no one has been motivated to write it yet.

Joe

--
--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "If nature worked that way, the universe would crash all the time." --Jaron Lanier


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to