You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matheus Eduardo Machado Moreira <ma...@gmail.com> on 2005/12/01 03:12:37 UTC

Problem using LookupDispatchAction

    Hi,

    I have a problem using LookupDispatchAction. I already tried
looking for the solution on Google, this list archive and other
resources but I wasn't able to fix the problem. Maybe some of you can
help me.

    My action extends LookupDispatchAction and implements the
getKeyMethodMap() method. In my ApplicationResources.properties file I
define all the keys for the buttons that can be shown in my
interfaces. Everything seems to be ok but every time I try to access
my pages I receive the following error:
"javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
resource 'comando.iniciar' in key method map".

    I did everything as shown in the LookupDispatchAction's javadoc
but the application doesn't work. Can someone help me with this
frustrating error?

    Thanks,

Matheus Eduardo Machado Moreira

matheus.eduardo@gmail.com
Belo Horizonte - MG
(31) 8724-8041

Sun Certified Programmer for the Java 2 Plataform 1.4
--
"Valeu a pena? Tudo vale a pena
Se a alma não é pequena."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using LookupDispatchAction

Posted by Dakota Jack <da...@gmail.com>.
Don't bother with this.  This is just the purloined nutso version.  Try the
original which is simple and works at www.michaelmcgrady.com.



On 11/30/05, Michael Jouravlev <jm...@gmail.com> wrote:
>
> On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com>
> wrote:
> >     Hi,
> >
> >     I have a problem using LookupDispatchAction. I already tried
> > looking for the solution on Google, this list archive and other
> > resources but I wasn't able to fix the problem. Maybe some of you can
> > help me.
> >
> >     My action extends LookupDispatchAction and implements the
> > getKeyMethodMap() method. In my ApplicationResources.properties file I
> > define all the keys for the buttons that can be shown in my
> > interfaces. Everything seems to be ok but every time I try to access
> > my pages I receive the following error:
> > "javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
> > resource 'comando.iniciar' in key method map".
> >
> >     I did everything as shown in the LookupDispatchAction's javadoc
> > but the application doesn't work. Can someone help me with this
> > frustrating error?
>
> Source code snippet would be nice. Can you access other resources from
> this file? Is it in proper location?
>
> Anyway, do you want to try a better alternative? Here it is:
> http://struts.sourceforge.net/strutsdialogs/selectaction.html
>
> This class is not available as separate download, so you need to get
> the whole library, but it is very small.
>
> The latest update in version 1.24 allows you to use this action as
> utility class, that is, your action does not have to extend it, you
> can just instantiate it and call it. Check the samples for example of
> how to do that.
>
> Michael.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

Re: Problem using LookupDispatchAction

Posted by Oles <os...@lohika.odessa.ua>.
Michael Jouravlev wrote:

>On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com> wrote:
>  
>
>>    Hi,
>>
>>    I have a problem using LookupDispatchAction. I already tried
>>looking for the solution on Google, this list archive and other
>>resources but I wasn't able to fix the problem. Maybe some of you can
>>help me.
>>
>>    My action extends LookupDispatchAction and implements the
>>getKeyMethodMap() method. In my ApplicationResources.properties file I
>>define all the keys for the buttons that can be shown in my
>>interfaces. Everything seems to be ok but every time I try to access
>>my pages I receive the following error:
>>"javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
>>resource 'comando.iniciar' in key method map".
>>
>>    I did everything as shown in the LookupDispatchAction's javadoc
>>but the application doesn't work. Can someone help me with this
>>frustrating error?
>>    
>>
>
>Source code snippet would be nice. Can you access other resources from
>this file? Is it in proper location?
>
>Anyway, do you want to try a better alternative? Here it is:
>http://struts.sourceforge.net/strutsdialogs/selectaction.html
>
>This class is not available as separate download, so you need to get
>the whole library, but it is very small.
>
>The latest update in version 1.24 allows you to use this action as
>utility class, that is, your action does not have to extend it, you
>can just instantiate it and call it. Check the samples for example of
>how to do that.
>
>Michael.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using LookupDispatchAction

Posted by Michael Jouravlev <jm...@gmail.com>.
On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com> wrote:
>     Hi,
>
>     I have a problem using LookupDispatchAction. I already tried
> looking for the solution on Google, this list archive and other
> resources but I wasn't able to fix the problem. Maybe some of you can
> help me.
>
>     My action extends LookupDispatchAction and implements the
> getKeyMethodMap() method. In my ApplicationResources.properties file I
> define all the keys for the buttons that can be shown in my
> interfaces. Everything seems to be ok but every time I try to access
> my pages I receive the following error:
> "javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
> resource 'comando.iniciar' in key method map".
>
>     I did everything as shown in the LookupDispatchAction's javadoc
> but the application doesn't work. Can someone help me with this
> frustrating error?

Source code snippet would be nice. Can you access other resources from
this file? Is it in proper location?

Anyway, do you want to try a better alternative? Here it is:
http://struts.sourceforge.net/strutsdialogs/selectaction.html

This class is not available as separate download, so you need to get
the whole library, but it is very small.

The latest update in version 1.24 allows you to use this action as
utility class, that is, your action does not have to extend it, you
can just instantiate it and call it. Check the samples for example of
how to do that.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using LookupDispatchAction

Posted by Matt Morton <ma...@gmail.com>.
In your url you have acao=comando.pesquisar, I have always used the
form where acao=Pesquisar or the value of the key in the map.  Also
are you sure that your Constants class is providing the Map to the
LookupDispatchAction?

Matt Morton

On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com> wrote:
>     I have the following key-value mappings in the .properties file
> (keys and values in Portuguese, I know all of you know Portuguese
> :-)).
>
> comando.pesquisar=Pesquisar (search)
> comando.editar=Editar (edit)
> comando.salvar=Salvar (save)
> comando.iniciar=iniciar (init, used as default entry point)
>
>     I have a class where I put all the constants used throughout the
> application and this class declares a "default" key-method map:
>
> Map<String, String> defaultKeyMethodMap = new HashMap<String, String>();
> defaultKeyMethodMap.put("comando.pesquisar", "pesquisar");
> defaultKeyMethodMap.put("comando.editar", "editar");
> defaultKeyMethodMap.put("comando.salvar", "salvar");
> defaultKeyMethodMap.put("comando.iniciar", "iniciar");
>
>     My getKeyMethodMap() method is as below:
>
> protected Map getKeyMethodMap() {
>     return Constants.defaultKeyMethodMap;
> }
>
>     My action is simple. One detail, I don't define (yet) all the
> methods present in the key-method map because I'm constructing the
> action class method by method and testing each one.
>
> public class CadastroIngredienteAction extends LookupDispatchAction {
>     public ActionForward iniciar(ActionMapping mapping,
>         ActionForm form, HttpServletRequest request,
>         HttpServletResponse response) {
>
>         return mapping.findForward("refresh");
>     }
>
>     // other action methods here
>
>     // getKeyMethodMap() as before comes here
> }
>
>     In my .jsp file I have my buttons like this:
>
> <html:form action="/pesquisaIngrediente">
>     <html:submit property="acao">
>         <fmt:message key="comando.pesquisar"/>
>     </html:submit>
> </html:form>
>
>     Finally the action mapping in struts-config:
>
> <action
>     path="/pesquisaIngrediente"
>     type="br.com.patrulleros.manjar.action.CadastroIngredienteAction"
>     name="cadastroIngredienteFormBean"
>     scope="session"
>     parameter="acao">
>
>     <forward
>         name="refresh"
>         path="/WEB-INF/paginas/cadastroIngrediente/pesquisaIngrediente.jsp"/>
> </action>
>
>     One more thing, I try to access the page typing the page's address
> directly in my browser:
> http://localhost:8084/pesquisaIngrediente.do?acao=comando.pesquisar. I
> do this way because I don't have a menu or something like this yet.
>
>     Thanks,
>
> Matheus Eduardo Machado Moreira
>
> matheus.eduardo@gmail.com
> Belo Horizonte - MG
> (31) 8724-8041
>
> Sun Certified Programmer for the Java 2 Plataform 1.4
> --
> "Valeu a pena? Tudo vale a pena
> Se a alma não é pequena."
>
> 2005/11/30, Wendy Smoak <ws...@gmail.com>:
> > On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com> wrote:
> > >     My action extends LookupDispatchAction and implements the
> > > getKeyMethodMap() method. In my ApplicationResources.properties file I
> > > define all the keys for the buttons that can be shown in my
> > > interfaces. Everything seems to be ok but every time I try to access
> > > my pages I receive the following error:
> > > "javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
> > > resource 'comando.iniciar' in key method map".
> >
> > My guess is that you've got things backwards in getKeyMethodMap, but
> > it's hard to tell without seeing some code.  Can you post the relevant
> > bits of getKeyMethodMap, your .properties file, and one of your
> > buttons?
> >
> > --
> > Wendy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using LookupDispatchAction

Posted by Matheus Eduardo Machado Moreira <ma...@gmail.com>.
    I have the following key-value mappings in the .properties file
(keys and values in Portuguese, I know all of you know Portuguese
:-)).

comando.pesquisar=Pesquisar (search)
comando.editar=Editar (edit)
comando.salvar=Salvar (save)
comando.iniciar=iniciar (init, used as default entry point)

    I have a class where I put all the constants used throughout the
application and this class declares a "default" key-method map:

Map<String, String> defaultKeyMethodMap = new HashMap<String, String>();
defaultKeyMethodMap.put("comando.pesquisar", "pesquisar");
defaultKeyMethodMap.put("comando.editar", "editar");
defaultKeyMethodMap.put("comando.salvar", "salvar");
defaultKeyMethodMap.put("comando.iniciar", "iniciar");

    My getKeyMethodMap() method is as below:

protected Map getKeyMethodMap() {
    return Constants.defaultKeyMethodMap;
}

    My action is simple. One detail, I don't define (yet) all the
methods present in the key-method map because I'm constructing the
action class method by method and testing each one.

public class CadastroIngredienteAction extends LookupDispatchAction {
    public ActionForward iniciar(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {

        return mapping.findForward("refresh");
    }

    // other action methods here

    // getKeyMethodMap() as before comes here
}

    In my .jsp file I have my buttons like this:

<html:form action="/pesquisaIngrediente">
    <html:submit property="acao">
        <fmt:message key="comando.pesquisar"/>
    </html:submit>
</html:form>

    Finally the action mapping in struts-config:

<action
    path="/pesquisaIngrediente"
    type="br.com.patrulleros.manjar.action.CadastroIngredienteAction"
    name="cadastroIngredienteFormBean"
    scope="session"
    parameter="acao">

    <forward
        name="refresh"
        path="/WEB-INF/paginas/cadastroIngrediente/pesquisaIngrediente.jsp"/>
</action>

    One more thing, I try to access the page typing the page's address
directly in my browser:
http://localhost:8084/pesquisaIngrediente.do?acao=comando.pesquisar. I
do this way because I don't have a menu or something like this yet.

    Thanks,

Matheus Eduardo Machado Moreira

matheus.eduardo@gmail.com
Belo Horizonte - MG
(31) 8724-8041

Sun Certified Programmer for the Java 2 Plataform 1.4
--
"Valeu a pena? Tudo vale a pena
Se a alma não é pequena."

2005/11/30, Wendy Smoak <ws...@gmail.com>:
> On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com> wrote:
> >     My action extends LookupDispatchAction and implements the
> > getKeyMethodMap() method. In my ApplicationResources.properties file I
> > define all the keys for the buttons that can be shown in my
> > interfaces. Everything seems to be ok but every time I try to access
> > my pages I receive the following error:
> > "javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
> > resource 'comando.iniciar' in key method map".
>
> My guess is that you've got things backwards in getKeyMethodMap, but
> it's hard to tell without seeing some code.  Can you post the relevant
> bits of getKeyMethodMap, your .properties file, and one of your
> buttons?
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using LookupDispatchAction

Posted by Wendy Smoak <ws...@gmail.com>.
On 11/30/05, Matheus Eduardo Machado Moreira <ma...@gmail.com> wrote:
>     My action extends LookupDispatchAction and implements the
> getKeyMethodMap() method. In my ApplicationResources.properties file I
> define all the keys for the buttons that can be shown in my
> interfaces. Everything seems to be ok but every time I try to access
> my pages I receive the following error:
> "javax.servlet.ServletException: Action[/pesquisaIngrediente] missing
> resource 'comando.iniciar' in key method map".

My guess is that you've got things backwards in getKeyMethodMap, but
it's hard to tell without seeing some code.  Can you post the relevant
bits of getKeyMethodMap, your .properties file, and one of your
buttons?

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org