Hi Terence
Good idea it would work ;-) if I new, how many image-buttons would be on the JSP-Page. But I'm implementing a shopping-cart and don't have any Idea about the amount of items.
<input type="image" name="pos[0]" src=""graphics/editWarenkorb.gif;jsessionid=B392B8213370E48175705649C4B483B3"" value="dummy">
<input type="image" name="pos[1]" src=""graphics/editWarenkorb.gif;jsessionid=B392B8213370E48175705649C4B483B3"" value="dummy">
<input type="image" name="pos[2]" src=""graphics/editWarenkorb.gif;jsessionid=B392B8213370E48175705649C4B483B3"" value="dummy">
I tryed to implement methode as follows:
public void getPos(int index )
{
intPosition = Integer.parseInt(index )
}
but this methode never gets called. Instead the method ' getPos() ' is called. I could implement fifty getPosX-Methods, but this might not be best solution.
Any further going ideas?
Thanks for your help
Beat Friedli
----------------------
Hi.
Let's say that you have a JSP page with the following tags:
<html:image pageKey="resources.images.login" property="login"/>
<html:image pageKey="resources.images.cancel" property="cancel"/>
In the ActionForm that is associated to that page, you would have
something like this:
protected boolean m_cancelPressed = false;
protected boolean m_loginPressed = false;
public int getLogin() {
m_loginPressed = true;
return 0;
}
public boolean isLoginPressed() {
return m_loginPressed;
}
public int getCancel() {
m_cancelPressed = true;
return 0;
}
public boolean isCancelPressed() {
return m_cancelPressed;
}
public void reset(ActionMapping mapping, HttpServletRequest request)
{
m_cancelPressed = false;
m_loginPressed = false;
}
Struts would call getLogin() or getCancel(), depending on whether the
user clicked "Login" or "Cancel". You can then test which button was
clicked by calling isCancelPressed() and isCancelPressed(). Trust me.
It works.
"Friedli Beat [UFA AG Her]" wrote:
>
>
> As you said, I have a form with a few image buttons and I just want to
> know which one of them is clicked.
>
> I just don't understand, how tha my getter-Mehode would have to look
> like in order to work. Can you give me an example?
>
> Thanks for your help
>
> Beat Friedli
>
> --------------
>
> Hi.
>
> There are two solutions, depending on what you want to do.
>
> If you want to have an image map (i.e. you want to recover the
> coordinates of the image that was clicked), you can follow the
> directions for the image tag
> (http://jakarta.apache.org/struts/struts-html.html#image).
>
> However, if you have a form with a few image buttons and you just want
>
> to know which one of them is clicked, it is the getter and not the
> setter method that is called (don't ask me why; all I know is that is
> works).
>
> Hope it helps.
>
> "Friedli Beat [UFA AG Her]" wrote:
>
> >
> >
> > In a jsp Form this code works works perfect:
> > <html:submit property="editPos" > Position<%= val %> </html:submit>
> >
> > Now I decided to use an image instead of a button like this:
> > <html:image property="editPos" src=""graphics/editWarenkorb.gif"
> > value="Position<%= val %>" />
> >
> > The generated Code looks fine to me:
> > <input type="image" name="editPos"
> >
> src=""graphics/editWarenkorb.gif;jsessionid=F3C57101544373C1913436E0277103C7"
>
> > value="Position0">
> >
> > But the value 'Position0' is never filled up in the Formbean as the
> > setter-method never is called. And I know, that the Formbean and all
>
> > works correct as it works fine withe the submit-Button. Is my
> > html:image Tag not good?
> >
> > Thanks for any help or idea
> >
> > Beat Friedli
>
> --
> ---------------------
> Terence JACYNO
> Galasoft Inc.
--
---------------------
Terence JACYNO
Galasoft Inc.