You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "SIRAGHER, JOEL" <JO...@appsig.com> on 2006/03/01 20:34:20 UTC

MESS!: multiple submit buttons: LookupDispatchAction / ActionForward formdata missing

I got the ok on switching to 1.2.8, and I will also try your method this
afternoon. I appreciate everyones responses. In the mean time, I have
some design issues and questions: 

Does the old lookupdispatch action sometimes loose stuff that lives on
the form??

I have a very complicated form. I am trying to find an easier way of
programming it. 

Leave the page via google type links; or leave the page via sortNow
button; or leave the page via selectNow button; or leave the screen via
select/unselect entire set; select/unselect entire page.


Google type links look like this for me:
=========================
 <html:link action="/actions/RetrieveInit?movegroup=firstset"> 

<logic:iterate id="folder" name="RetrieveFormBean"
property="recNumLinkText" type="com.xxx.struts.action.RecNumLinkText">
	<html:link action ="/actions/SortRetrieveInit"
paramId="clickwindow"  paramName="folder"

	 <bean:write name="folder" property="linkText" /> </html:link>
 </logic:iterate>

<html:link action="/actions/RetrieveInit?movegroup=lastset"> 

Then I have a group of dropdowns to select sorting criteria. Clicking
the sort button goes thru the old lookupdispatchAction. They have their
own in the lookup dispatch as:

<html:submit property="method">
	<bean:message key="button.SortNow" />
</html:submit>
 
<html:submit property="method">
	<bean:message key="button.UpdatePage" />  // click a few
checkboxes 
</html:submit>
 
<html:submit  property="method">
	<bean:message key="button.SelectCurrentPage" />
</html:submit>
 
<html:submit  property="method">   //current page of results
	<bean:message key="button.UnselectCurrentPage" />  
</html:submit>
 
<html:submit  property="method">   //all results in the results table.
	<bean:message key="button.SelectAllResults" /> 
</html:submit>
 
Then I also have other functionality called: SelectNow which allows
selecting groups of records based on criteria. 


On the design side, I have 2 actions: an InitAction which pulls the
records out of the database and puts them in  queryResults[] that lives
in the form bean. 

Then I have the actions which go thru the old lookupdispatch thing,
except for the google type links which send processing via html:link
forward to the RetrieveInitAction

The most disturbing issues I've run across now is that If I use the
dispatch button that checks All records on the screen. The data gets to
the database, and redraws the records on the screen as checked. But when
I go to uncheck a few, and hit the update page button, which reads the
form and looks for checkboxes unchecked or checked... they all show up
as checked again.

What a mess. 

All this lives on one screen. Any ideas on redesign or how to make it
easier to program?

-----Original Message-----
From: Michael Jouravlev [mailto:jmikus@gmail.com] 
Sent: Wednesday, March 01, 2006 11:17 AM
To: Struts Users Mailing List
Subject: Re: multiple submit buttons: LookupDispatchAction /
ActionForward formdata missing

You don't need to switch, you just need the two classes I mentioned.
You dont need a keymethodmap either.

=== cut here ===
jsp:
====
<html:form action="/actions/retrieve"  method="post">
  <html:submit property="updateEvent">
    <bean:message key="button.UpdatePage" />
  </html:submit>
</html:form>


Action Class:
=========
public class RetrieveAction extends Action {

  /**
   * Instantiate event dispatcher
   */
  protected ActionDispatcher dispatcher =
      new EventDispatcher(this, false);

  /**
   * Use event dispatcher to call an appropriate event handler.
   * By using a dispatcher an action class does not have
   * to extend a DispatchAction flavor.
   */
  public ActionForward execute(ActionMapping mapping,
                               ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response)
      throws Exception {
      return dispatcher.execute(mapping, form, request, response);
  }


  public ActionForward updatePage(ActionMapping mapping, ActionForm
form,
         HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException {

    RetrieveFormBean dataForm = (RetrieveFormBean) form;
    .....
    return mapping.findForward("retrieve");
  }
}


struts-config.xml
========
<action path="/actions/retrieve"
       name="RetrieveFormBean"
       type="com.struts.action.RetrieveAction"
       scope="session"
       parameter="updateEvent=updatePage">
       <forward name="Retrieve" path="/tiles/Retrieve.jsp"/>
</action>
=== cut here ===

On 3/1/06, SIRAGHER, JOEL <JO...@appsig.com> wrote:
> we are unfortunately using 1.1. I will check with the techspert team
to see if we can switch over.
> thank you for the suggestion
>
> ________________________________
>
> From: Michael Jouravlev [mailto:jmikus@gmail.com]
> Sent: Tue 2/28/2006 4:15 PM
> To: Struts Users Mailing List
> Subject: Re: multiple submit buttons: LookupDispatchAction /
ActionForward formdata missing
>
>
>
> > On 2/28/06, SIRAGHER, JOEL <JO...@appsig.com> wrote:
> <skipped/>
>
> By the way, LookupDispatchAction is not the best choice to dispatch
> events. I suggest you to use this one:
> http://issues.apache.org/bugzilla/attachment.cgi?id=17724 You will
> also need ActionDispatcher class from Struts 1.2.7+ distro.
>
> 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: MESS!: multiple submit buttons: LookupDispatchAction / ActionForward formdata missing

Posted by Dakota Jack <da...@gmail.com>.
The Action class is not the controller.  The controller is the class that
chooses the Action class.

On 3/1/06, Michael Jouravlev <jm...@gmail.com> wrote:
>
> On 3/1/06, SIRAGHER, JOEL <JO...@appsig.com> wrote:
> > I got the ok on switching to 1.2.8, and I will also try your method this
> > afternoon. I appreciate everyones responses. In the mean time, I have
> > some design issues and questions:
> >
> > Does the old lookupdispatch action sometimes loose stuff that lives on
> > the form??
>
> An action (if you mean action class) cannot lose stuff from the form.
> An action is just a "C in MVC" and it is stateless. I will answer the
> checkbox question further in this reply.
>
> > I have a very complicated form. I am trying to find an easier way of
> > programming it.
>
> You can have either one solid page or a composite page that contains
> different self-sufficient components.
>
> If you have one solid page, then I would say process it with one (or
> two) actions. Make the submit action a dispatch-type action (like you
> already did) and channel all page events to submit action. The render
> action would fill out and display the page. This is what you are
> already doing.
>
> If you prefer to have a composite page, then you can either use
> something like Tiles (never used it) or you can use other component
> technology. In this case you can have as many actions as many
> subcomponents you have. I don't want to advise any specific component
> technology, it all depends on taste. I have my own implementation, but
> it is in alpha stage so I don't want to mess your production
> environment.
>
> <skipped/>
>
> > Then I also have other functionality called: SelectNow which allows
> > selecting groups of records based on criteria.
> >
> >
> > On the design side, I have 2 actions: an InitAction which pulls the
> > records out of the database and puts them in  queryResults[] that lives
> > in the form bean.
> >
> > Then I have the actions which go thru the old lookupdispatch thing,
> > except for the google type links which send processing via html:link
> > forward to the RetrieveInitAction
> >
> > The most disturbing issues I've run across now is that If I use the
> > dispatch button that checks All records on the screen. The data gets to
> > the database, and redraws the records on the screen as checked. But when
> > I go to uncheck a few, and hit the update page button, which reads the
> > form and looks for checkboxes unchecked or checked... they all show up
> > as checked again.
>
> This is a known issue, more like HTTP thing than Struts. Unchecked
> radiobuttons and checkboxes are not sent to the server by browser, so
> when you submit a form, you need to clear checkboxes before ActionForm
> is populated. The only place to do this is ActionForm.reset() method.
> Clear all checkboxes and do not set them with data from database. When
> form is populated from the request, the checked checkboxes will be
> set.
>
> 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: MESS!: multiple submit buttons: LookupDispatchAction / ActionForward formdata missing

Posted by Michael Jouravlev <jm...@gmail.com>.
On 3/1/06, SIRAGHER, JOEL <JO...@appsig.com> wrote:
> I got the ok on switching to 1.2.8, and I will also try your method this
> afternoon. I appreciate everyones responses. In the mean time, I have
> some design issues and questions:
>
> Does the old lookupdispatch action sometimes loose stuff that lives on
> the form??

An action (if you mean action class) cannot lose stuff from the form.
An action is just a "C in MVC" and it is stateless. I will answer the
checkbox question further in this reply.

> I have a very complicated form. I am trying to find an easier way of
> programming it.

You can have either one solid page or a composite page that contains
different self-sufficient components.

If you have one solid page, then I would say process it with one (or
two) actions. Make the submit action a dispatch-type action (like you
already did) and channel all page events to submit action. The render
action would fill out and display the page. This is what you are
already doing.

If you prefer to have a composite page, then you can either use
something like Tiles (never used it) or you can use other component
technology. In this case you can have as many actions as many
subcomponents you have. I don't want to advise any specific component
technology, it all depends on taste. I have my own implementation, but
it is in alpha stage so I don't want to mess your production
environment.

<skipped/>

> Then I also have other functionality called: SelectNow which allows
> selecting groups of records based on criteria.
>
>
> On the design side, I have 2 actions: an InitAction which pulls the
> records out of the database and puts them in  queryResults[] that lives
> in the form bean.
>
> Then I have the actions which go thru the old lookupdispatch thing,
> except for the google type links which send processing via html:link
> forward to the RetrieveInitAction
>
> The most disturbing issues I've run across now is that If I use the
> dispatch button that checks All records on the screen. The data gets to
> the database, and redraws the records on the screen as checked. But when
> I go to uncheck a few, and hit the update page button, which reads the
> form and looks for checkboxes unchecked or checked... they all show up
> as checked again.

This is a known issue, more like HTTP thing than Struts. Unchecked
radiobuttons and checkboxes are not sent to the server by browser, so
when you submit a form, you need to clear checkboxes before ActionForm
is populated. The only place to do this is ActionForm.reset() method.
Clear all checkboxes and do not set them with data from database. When
form is populated from the request, the checked checkboxes will be
set.

Michael.

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