You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "seloha ." <se...@hotmail.com> on 2005/03/01 16:35:56 UTC

Simple Multiple Submit Queston

I have searched the list but have not been able to come up with a definitive 
answer to this problem.

This will display my ignorance but hopefully I will learn about tapestry 
variables:

I have multiple submit buttons in the template:

<input type="submit" jwcid="@Submit" value="Change Shift" 
listener="ognl:listeners.changeDate"/>

<input type="submit" jwcid="@Submit" value="Save" 
listener="ognl:listeners.saveAllocations"/>

these are inside a form:

<form jwcid="@Form" listener="ognl:listeners.formSubmit" 
id="allocationForm">

I have read the Wiki Gotchas 4. Form and Submit Listeners: Order Matters.

I have written a java class with:

    // flag to indicate change date button has been selected
    boolean changeDateFlag = false;
    // flag to indicate save button has been selected
    boolean saveAllocationsFlag = false;

    public void formSubmit(IRequestCycle cycle) {
        if (changeDateFlag) {
            // Process the submitted date.
            changeDateRequested();
            return;
        }
        if (saveAllocationsFlag) {
            // Process the save request.
            saveAllocationsRequested();
            return;
        }
        ...
    }

    public void changeDate(IRequestCycle cycle) {
        changeDateFlag = true;
    }

    public void changeDateRequested() {
     ...
    }

    public void saveAllocations(IRequestCycle cycle) {
        saveAllocationsFlag = true;
    }

    public void saveAllocationsRequested() {
    ...
    }

This seems like a problem could a rise due to the way I have defined the 
flags.

There are two different entry points, through either of the submit buttons.

Do I need to assign the flags to the user session (visit)?

Thanks in advance.,

Paul



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


Re: Simple Multiple Submit Queston

Posted by "seloha ." <se...@hotmail.com>.
I like this even better since it involves fewer changes to the original.

Thanks alot

Paul

&gt;From: &quot;Bryan Lewis&quot; &lt;bryan@maine.rr.com&gt;
&gt;Reply-To: &quot;Tapestry users&quot; 
&lt;tapestry-user@jakarta.apache.org&gt;
&gt;To: &quot;Tapestry users&quot; &lt;tapestry-user@jakarta.apache.org&gt;
&gt;Subject: Re: Simple Multiple Submit Queston
&gt;Date: Tue, 1 Mar 2005 14:47:27 -0500
&gt;
&gt;One small improvement... you don't need the two flags in your code and 
the
&gt;two listener methods.  The Submit component will take 'selected' and 
'tag'
&gt;parameters, and will update the 'selected' property with the tag.  
Something
&gt;like:
&gt;
&gt;html:
&gt;    &lt;input type=&quot;submit&quot; jwcid=&quot;@Submit&quot; 
value=&quot;Change Shift&quot;
&gt;        selected=&quot;ognl:whichButton&quot; 
tag=&quot;change&quot;/&gt;
&gt;
&gt;page:
&gt;     &lt;property-specification name=&quot;whichButton&quot; 
type=&quot;java.lang.String&quot;/&gt;
&gt;
&gt;java:
&gt;     public void formSubmit(IRequestCycle cycle) {
&gt;         if (getWhichButton().equals(&quot;change&quot;)) {
&gt;               // Process the submitted date.
&gt;               changeDateRequested();
&gt;               return;
&gt;           }
&gt;
&gt;Saves a few lines.
&gt;
&gt;
&gt;---------------------------------------------------------------------
&gt;To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
&gt;For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
&gt;



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


Re: Simple Multiple Submit Queston

Posted by Bryan Lewis <br...@maine.rr.com>.
One small improvement... you don't need the two flags in your code and the
two listener methods.  The Submit component will take 'selected' and 'tag'
parameters, and will update the 'selected' property with the tag.  Something
like:

html:
   <input type="submit" jwcid="@Submit" value="Change Shift"
       selected="ognl:whichButton" tag="change"/>

page:
    <property-specification name="whichButton" type="java.lang.String"/>

java:
    public void formSubmit(IRequestCycle cycle) {
        if (getWhichButton().equals("change")) {
              // Process the submitted date.
              changeDateRequested();
              return;
          }

Saves a few lines.


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