You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Pierre Henry <ph...@proconcept.ch> on 2003/01/23 17:16:44 UTC
Tricky behavior with JSP portlet and forms
I had a very strange behavior with my form in a JSP portlet. I have 2 forms,
one is submitted with a normal submit button, the other by a Javascript. The
one with javascript always works fine. For the other, when I submitted it
with the button, the corresponding action method (doUpdatefilter) was
called, but when I submitted it by pressing the enter key, the
buildNormalContext was called. (?!?!) This in IE5 and IE6.
I found out where it came from, I still post it in case other people are
experiencing it :
IE, depending on the method used to post the form, sends or doesn't send the
submit field (eventSubmit_doUpdatefilter=OK) in the url/request headers. Of
course if it doesn't send it, the default buildNormalContext is called, else
the corresponding method is called.
The solution seems to be to put the evenSubmit as a hidden field with value
1 or whatever, and rename the submit to something else. This works with
IE5/6.
I also tried with Mozilla and here the behavior is different : if the form
uses POST, the buildNormalContext is always method is always called (mo
matter if I have a hidden ebentSubmit field or not) and if it uses a GET,
the right method is called, but the url is really ugly :)
Beside that, I tried hard to get this action working, and this is what I
found out, and this differs slightly but viciously from the tutorial :
- the form in the JSP doesn't need any action attribute
- the ony needed hidden field is js_peid which contains the portlet's ID.
When I put a hidden field for the action :
<INPUT TYPE="hidden" name="action" value="CustomizableXsqlPortlet1Action">
the right method was called but the portlet argument of the doUpdatefilter
method was null, so the action class couldn't do much.
final working form :
<FORM METHOD=POST> put GET for Mozilla
<INPUT TYPE="text" NAME="find" value="2000%">
... other data inputs
<INPUT TYPE="hidden" name="eventSubmit_doUpdatefilter"
value="1">
<INPUT TYPE="submit" name="go" value="OK">
<INPUT TYPE="hidden" NAME="js_peid"
VALUE="P-f2dc3b8cfd-10001">
</FORM>
Form submitted with JavaScript, IE only (I use this to make the column
header clickable) :
<script type="text/javascript">
function columnHeaderSubmit(column){
window.document.forms['sortForm'].sort.value=column;
sortForm.submit();
}
</script>
<form method=POST name="sortForm">
<input TYPE="hidden" name="sort">
<input TYPE="hidden" name="eventSubmit_doUpdatesortcol"
value="1">
<input TYPE="hidden" NAME="js_peid"
VALUE="P-f2dc3b8cfd-10001">
</form>
<table cellpadding=4>
<tr>
<th><a
href="javascript:columnHeaderSubmit('PERIOD')">PĂ©riode</a></th>
<th><a
href="javascript:columnHeaderSubmit('SUBSET')">Sous-Ensemble</a></th>
etc...
I hope this can help...
Comments/corrections welcome !
Pierre Henry