Hi,
I have read old mails regarding the html:image implementation and the
recommendations related to identifying which image is clicked in the form.
For
reference is used Ted's - '
Struts Tip #1 - Use an ImageButtonBean to
represent
an image button' @
http://husted.com/struts/tips/001.html My problem is a step further in the same. I will try my best to explain it,
I
hope I get it right.
I have a mainpage which has many image buttons, they all map to different
actions that they must perform. Once the image is clicked, I identify the
image
and perform the relevant action by forwarding the call to the relevant
action
mapping. Most actions have a .jsp (UI) and action class and are defined in
the
struts-config.xml part shown below:
<struts-config>
<form-beans>
<form-bean name="dataForm" type="com.data.struts.form.DataForm">
</form-bean>
</form-beans>
<global-forwards>
<forward name="getData" path="/getData.do"/>
<forward name="resetData" path="/resetData.do"/>
</global-forwards>
<action-mappings>
<action path="/getData" type="com.data.struts.action.DataAction"
name="dataForm" scope="request" input="/jsp/dataForm.jsp">
<forward name="success" path="/jsp/dataForm.jsp"/>
</action>
<action path="/resetData" type="com.data.struts.action.ResetDataAction"
name="dataForm" scope="request" >
<forward name="success" path="/getData.do"/>
</action>
</action-mappings>
<message-resources parameter="ApplicationResources"/>
</struts-config>
In my case DataAction class receives the click event and forward the call to
/resetData.
//as below
if (dataForm.getRestButton().pressed() && errors == null) {
Log.debug("RESET BUTTON :"+ dataForm. getRestButton ().getName()
+", X : "+ dataForm. getRestButton ().getX()
+", Y : "+ dataForm. getRestButton ().getY());
return (mapping.findForward("resetData"));
}
The ResetDataAction process the request (does some thing) and must return
back
to the caller - forward to /getData finally.
//as below
mapping.findForward("getData")
All button handling working fine and I can do the processing in
ResetDataAction
but the problem start when I forward the call back to /getData. The call
forward
to DataAction class but the button click is identified and the call gets
forwarded back to /resetData and then back.... here I get into a loop.
I tried to reset on the form (which is common to both action classes) but no
success, I tried explicitly setting the button beans X & Y values to null,
still
no success.
What I could do was do the process I was doing in ResetDataAction in
DataAction
but that is not what I would like to do.
I want to keep the two implementations separate as one only delegates and
the
other does some processing. Can someone throw more light onto this? I have
been
reading a lot but have not come across a person who faced a similar problem.
It
may be something really basic but I can't solve it the way I want and it's
bothering me.
Any help on this will be much appreciated.
Thanks in advance,
Anuj