Konrad Billewicz wrote:
Dave Newton <newton <at> pingsite.com> writes:
I've never put a parameter in a form's action attribute--why would you
want to do that? Wouldn't it be much cleaner to use a hidden form field
with the appropriate parameter name?
So your original example would be (minus whatever silly syntax mistakes
because I'm groggy):
<html:form action="createDictionaryEntity">
<html:hidden property="dictionary"/>
<!-- ... -->
</html:form>
and whatever loads the form puts the appropriate dictionaryId value into
the ActionForm?
I wish to pass the dictionary variable using GET - make it visible in the URL.
Secondly, this action (createDictionaryEntity) can be accessed both from form
and from link (using <a href="...">). I wish to have one, clear method of
passing parameters to it. Of course, I can at first check the request and
secondly the form (or inversely) but it is not, in my opinion, elegant solution.
I thing it is not compulsory.
Firstly, you can combine get with forms; if you use method="GET" the hidden
parameter Dave suggested will show up in the URL. Either way, you wouldn't
have to 'check the request and secondly the form' since GET and POST
parameters are both accessed the same way, though request.getParameter() or
via your form bean.
If you really still want to construct the URL with a query parameter,
though, you have a few options. Using JSTL:
<html:form action="createDictionaryEntity.do?
dictionary=${requestScope['dictionaryId'}">
Alternatively you might be able to do something along the lines of (off the
top of my head; check the docs for syntax):
<c:url var="action" value="createDictionaryEntity.do">
<c:param name="dictionary">
<bean:write name="dictionaryId" scope="request"/>
<%= dictionaryId %>"
</c:param>
</c:url>
<html:form action="<% action %>">
But that still uses JSTL tags; I don't know if you can get to the same
result with only Struts tags an on EL or runtime expressions.
L.
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]