You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Letícia Álvares Barbalho <le...@gmail.com> on 2005/08/22 19:43:39 UTC
Action[/UpdateDeleteColecao] missing resource 'button.delete' in key method map
Hey guys, how's everything?
I'm trying to call a LookupDispatchAction from a link, and I'm getting
the error above. I'd like you to help me find the reason...
my jsp is like this:
<font size=2><pre>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="auge.conexao.ColecaoService" %>
<%@ page import="java.util.*" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html:html locale="true">
<head>
<title>Coleção</title>
<html:base/>
</head>
<body bgcolor="white">
<span style="font-family:Sans-serif;">
<table width="100%" align="center">
<tr><td> Coleção </td></tr>
<tr bgcolor="#000000"> <td></td></tr>
</table>
<br><br><br><br>
<html:errors/>
<br>
<html:form action="/UpdateDeleteColecao.do" method="post" focus="colecao">
<table border="0" align="center">
<tr><td width="50%"> Coleção </td><td width="50%"><html:text
property="colecao" value="${requestScope.col.colecao}"
readonly="true"/></td></tr>
<tr><td width="50%"> Descricão </td><td
width="50%"><html:text property="descricao"
value="${requestScope.col.descricao}"/></td></tr>
<tr>
<td width="50%" align="center">
<html:link action="/UpdateDeleteColecao.do">
<bean:message key="button.add"/> </html:link>
</td>
<td width="50%" align="center">
<html:submit property="method"><bean:message
key="button.delete"/></html:submit>
</td>
</tr>
</table><br/>
</html:form>
</span>
</html:html>
</pre></font>
My action is like:
<font size=2><pre>
package auge.action;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.LookupDispatchAction;
import org.hibernate.HibernateException;
import auge.conexao.ColecaoService;
import auge.bean.Colecao;
import auge.form.AddColecaoForm;
public class UpdateDeleteColecaoAction extends LookupDispatchAction {
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("button.add", "update");
map.put("button.delete", "delete");
return map;
}
public ActionForward update(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
try {
AddColecaoForm addColecaoForm = (AddColecaoForm) form;
Colecao colecao;
try {
Long colec = Long.valueOf(request.getParameter("colecao"));
colecao = ColecaoService.getInstance().getColecao(colec);
} catch (Exception e){
colecao = new Colecao();
}
if (addColecaoForm.getDescricao() != null) {
colecao.setDescricao(addColecaoForm.getDescricao());
colecao.setColecao(addColecaoForm.getColecao());
ColecaoService.getInstance().updateColecao(colecao);
addColecaoForm.clear();
return mapping.findForward("success");
}
} catch(Exception e){
return mapping.findForward("error");
}
return mapping.findForward("error");
}
public ActionForward delete(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
try {
AddColecaoForm addColecaoForm = (AddColecaoForm) form;
Long colec = Long.valueOf(request.getParameter("colecao"));
Colecao colecao = ColecaoService.getInstance().getColecao(colec);
try {
ColecaoService.getInstance().delColecao(colecao);
} catch(HibernateException e){
// nada a fazer
}
addColecaoForm.clear();
} catch(Exception e){
return mapping.findForward("error");
} finally{
return mapping.findForward("success");
}
}
}
</pre></font>
and my struts-config:
<font size=2><pre>
<action path="/UpdateDeleteColecao"
type="auge.action.UpdateDeleteColecaoAction"
name="addColecaoForm"
scope="request"
input="/colecao.jsp"
parameter="method">
<forward name="success"
path="/pages/confirmacao.jsp"/>
<forward name="error" path="/pages/erro.jsp"/>
</action>
</pre></font>
does anyone know why I'm getting this error? I'd appreciate any help. Thanks.
--
Letícia Álvares Barbalho
leticia.barbalho@gmail.com
Re: Action[/UpdateDeleteColecao] missing resource 'button.delete' in key method map
Posted by Letícia Álvares Barbalho <le...@gmail.com>.
Wendy, thank you a lot for the help
I ended up solving the problem using smart forwarding... it seemed a little
better (and I must say, it worked faster hehe)
anyways, I'll try the solution you gave so I'll know it the next time
thank you
On 8/22/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
>
> > <a href="javascript:void(0);" onclick="javascript:dispatchIt();"
> > property="method"> <bean:message key="button.add"/></a>
> >
> > Well, if it worked like the html:button, it would send the method with
> the
> > value from the bean. But it obviously doesn't. So, I put this js
> function
> > to
> > be called onclick:
> >
> > function dispatchIt()
> > {
> > document.addColecaoForm.action=
> "/AugeProducao/UpdateDeleteColecao.do?method=
> > button.add";
> > document.addColecaoForm.submit();
> > }
> >
> > And that's causing the error. So, if the property=method doesn't work,
> and
> > passing it literally doesn't work... that means I cannot use links to
> > submit
> > the form? Or am I doing it totally wrong?
>
> You're on the right track... but I admit to just hardcoding the text value
> for the
> button. :)
>
> Change it to method=Add (or whatever the value is from
> ApplicationResources.properties) and it should start working. From there,
> you can figure out how to retrieve the value for the right locale. Without
> actually trying it, I think possibly <c:set> and <msg:format> (JSTL) and
> then use an expression inside the script.
>
> --
> Wendy Smoak
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Letícia Álvares Barbalho
leticia.barbalho@gmail.com
Re: Action[/UpdateDeleteColecao] missing resource 'button.delete' in key method map
Posted by Wendy Smoak <ja...@wendysmoak.com>.
> <a href="javascript:void(0);" onclick="javascript:dispatchIt();"
> property="method"> <bean:message key="button.add"/></a>
>
> Well, if it worked like the html:button, it would send the method with the
> value from the bean. But it obviously doesn't. So, I put this js function
> to
> be called onclick:
>
> function dispatchIt()
> {
> document.addColecaoForm.action="/AugeProducao/UpdateDeleteColecao.do?method=
> button.add";
> document.addColecaoForm.submit();
> }
>
> And that's causing the error. So, if the property=method doesn't work, and
> passing it literally doesn't work... that means I cannot use links to
> submit
> the form? Or am I doing it totally wrong?
You're on the right track... but I admit to just hardcoding the text value
for the
button. :)
Change it to method=Add (or whatever the value is from
ApplicationResources.properties) and it should start working. From there,
you can figure out how to retrieve the value for the right locale. Without
actually trying it, I think possibly <c:set> and <msg:format> (JSTL) and
then use an expression inside the script.
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action[/UpdateDeleteColecao] missing resource 'button.delete' in key method map
Posted by Michael Jouravlev <jm...@gmail.com>.
Seems to me that you do not really understand what
LookupDispatchAction is for and how does it work. Do you have property
file that maps button caption to "button.add" property name? Well,
even if you do, you do not have to use LookupDispatchAction, because
you use a link.
Use standard DispathAction instead. Or use something else, like
SelectAction, which works uniformly with pushbuttons, links and
imagebuttons:
http://struts.sourceforge.net/strutsdialogs/selectaction.html
---
Struts Dialogs:
http://struts.sourceforge.net/strutsdialogs
On 8/22/05, Letícia Álvares Barbalho <le...@gmail.com> wrote:
> Well, I should be embarrassed by now. Actually, you're 100% correct:
> something is sending literally 'button.delete' as the value of method param,
> instead of the value from the .properties file. And this something would be
> me.
>
> It happens that I am not using html:submit buttons to call the dispatch
> action. Instead of it, I'm trying to use links, like this:
>
> <a href="javascript:void(0);" onclick="javascript:dispatchIt();"
> property="method"> <bean:message key="button.add"/></a>
>
> Well, if it worked like the html:button, it would send the method with the
> value from the bean. But it obviously doesn't. So, I put this js function to
> be called onclick:
>
> function dispatchIt()
> {
> document.addColecaoForm.action="/AugeProducao/UpdateDeleteColecao.do?method=
> button.add";
> document.addColecaoForm.submit();
> }
>
>
> And that's causing the error. So, if the property=method doesn't work, and
> passing it literally doesn't work... that means I cannot use links to submit
> the form? Or am I doing it totally wrong?
>
> Sorry, thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action[/UpdateDeleteColecao] missing resource 'button.delete' in key method map
Posted by Letícia Álvares Barbalho <le...@gmail.com>.
Well, I should be embarrassed by now. Actually, you're 100% correct:
something is sending literally 'button.delete' as the value of method param,
instead of the value from the .properties file. And this something would be
me.
It happens that I am not using html:submit buttons to call the dispatch
action. Instead of it, I'm trying to use links, like this:
<a href="javascript:void(0);" onclick="javascript:dispatchIt();"
property="method"> <bean:message key="button.add"/></a>
Well, if it worked like the html:button, it would send the method with the
value from the bean. But it obviously doesn't. So, I put this js function to
be called onclick:
function dispatchIt()
{
document.addColecaoForm.action="/AugeProducao/UpdateDeleteColecao.do?method=
button.add";
document.addColecaoForm.submit();
}
And that's causing the error. So, if the property=method doesn't work, and
passing it literally doesn't work... that means I cannot use links to submit
the form? Or am I doing it totally wrong?
Sorry, thanks.
On 8/22/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
>
> > I'm trying to call a LookupDispatchAction from a link, and I'm getting
> > the error above. I'd like you to help me find the reason...
>
> It looks like something is sending (literally) 'button.delete' as the
> value
> of the 'method' param, instead of using value from
> ApplicationResources.properties.
>
> What HTML does this turn into?
>
> > <html:submit property="method">
> > <bean:message key="button.delete"/>
> > </html:submit>
>
> Assuming your properties file is in place and properly configured, that
> should work.
>
> --
> Wendy Smoak
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Letícia Álvares Barbalho
leticia.barbalho@gmail.com
Re: Action[/UpdateDeleteColecao] missing resource 'button.delete' in key method map
Posted by Wendy Smoak <ja...@wendysmoak.com>.
> I'm trying to call a LookupDispatchAction from a link, and I'm getting
> the error above. I'd like you to help me find the reason...
It looks like something is sending (literally) 'button.delete' as the value
of the 'method' param, instead of using value from
ApplicationResources.properties.
What HTML does this turn into?
> <html:submit property="method">
> <bean:message key="button.delete"/>
> </html:submit>
Assuming your properties file is in place and properly configured, that
should work.
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org