tags:

views:

424

answers:

3

In order to have multiple actions on one form, I use dispatchAction. I'm starting with a lonely action which works when I use standard action with execute method. Before adding several action I start to convert this one.

At first load of the jsp, before any submit, I get the error :

Error 400: Request[/rechercheUtilisateur] does not contain handler parameter named hidden

Here is my configuration :

struts-config :

<action path="/rechercheUtilisateur" type="lan.poujoulat.osac.actions.RechercheUtilisateurAction" name="formRechercheUtilisateur" validate="true" input="/Administration/acces.jsp" scope="request" parameter="hidden">
    <forward name="réussiteRecherche" path="/Administration/acces.jsp">
    </forward>

jsp Administration/acces.jsp :

<SCRIPT>
   function setHidden(value){document.formRechercheUtilisateur.hidden.value=value;}
</SCRIPT>

<html:form action="/rechercheUtilisateur"
    name="formRechercheUtilisateur"
    type="lan.poujoulat.osac.forms.FormRechercheUtilisateur">
...
<td align="center" width="80"><a href="#"
    title='"Rechercher" />'> <input type=image
    value=submit src="./image/btnRech.gif" width="22" height="20"
    border="0" onclick="setHidden('recherche');"> </a></td> 
 </a>
...
          <html:hidden property="hidden" value="recherche"/>
</html:form>

RechercheUtilisateurAction.java :

public class RechercheUtilisateurAction extends DispatchAction
{

    public ActionForward recherche(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {

I add the hidden property to my form :

public class FormRechercheUtilisateur extends ValidatorForm
{
...
    private String hidden = " ";
...
A: 

I think your code is in conflict with the hidden property of the form. The JavaScript form object has a hidden object that represents a hidden form field which is used for client server communications.

I am not sure that the following code:

function setHidden(value) {
  document.formRechercheUtilisateur.hidden.value=value;
}

will set the value of the hidden field you've setup with this:

<html:hidden property="hidden" value="recherche"/>

I've never used this object before so I can't really say.

The message is pretty clear, you don't get the parameter that DispatchAction needs on the request. The issue is simple to debug, see what parameters arrive on the request at the server. You could set the form method to GET for a quick look, just to see if the parameter is in the URL.

First check where the problem is (server side/client side), then the solution might be as simple as changing the name of the field (a name of "hidden" doesn't tell a thing of what it represents) or you could do something like:

function setHidden(value) {
  document.formRechercheUtilisateur.hidden.value=value;
  document.formRechercheUtilisateur.hidden.name='hidden';
}

but I am not sure if this will work though.

dpb
Indeed the name "hidden" was just because of the tu I follow to make this works. The real name is "method", once I have to put it in the CVS, but nvm. One of the right way to acceed to this variable is : this.form.method.value. And indeed the message was clear my parameter wasn't initialize.
jayjaypg22
A: 

I program my index to pass in my action in order to initializee some data before my jsp. Index didn't provide hidden parameter so.

Solution : my jsp do not really need initialization (a null list doesn't provide problem in my display tag) so index action forward is the Administration/acces.jsp. No need to execute the action implies no need to initialize my parameter.

And the initialization in the jsp is made by

this.form.hidden.value = value

jayjaypg22
A: 

You can't find the real problem because the real problem was this code :

<forward name="acces" path="/rechercheUtilisateur.do">

Which I did not provide. Indeed this goes to

<action path="/rechercheUtilisateur" type="lan.poujoulat.osac.actions.RechercheUtilisateurAction" name="formRechercheUtilisateur" validate="true" input="/Administration/acces.jsp" scope="request" parameter="hidden">
    <forward name="réussiteRecherche" path="/Administration/acces.jsp">
    </forward>

with Hidden not initialized.

Solution :

 <forward name="acces" path="/acces.jsp">

Indeed I did not need initilisation before accessing to my jsp (the list in my display tag can be null)

jayjaypg22