You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Travis Romney <tr...@inpowered.com> on 2004/08/04 02:28:23 UTC

Help!!! Strange behavior occuring with ListEdit component

I'm fairly new with Tapestry and so far everything has gone quite well.
However, I have hit a large road block, and am losing all of my hair 
over it.  I have a page that contains a list of products that are added
dynamically by the user.  I am using a ListEdit component to maintain
this list. The list contains prices and quantities that can be edited
by the user. At the bottom of the page I have a submit button that
processes the page and updates the list.  There are two problems that
I am having when this page is submitted.  The first problem that
is occuring is that any changes that I make in the list are lost
when the page is submitted.  The second problem is the one that is
causing me the greatest stress.  The submit button at the bottom of
the page is tied to a specific listener method.  If I click on the 
submit button before any items are added to the list the listener
method gets called without any problems.  If I add a single product
to the list, my listener method will not get called.  If I place
the submit button above my ListEdit component the method will
get called but the list is empty.  I have been at this for
3 days now and can't make any sense of it.
Please help before I end up in the nut house!


Here is a snippet of code that I am working with

public abstract SaleLineItem getLineItem();
public abstract void setLineItem(SaleLineItem item);

public void pageBeginRender(PageEvent pe) {
	this.lineItems = getSaleLineItems();
	readLineItems();
}

private void readLineItems() throws java.sql.SQLException {
         ListEditMap map = new ListEditMap();
         int count = Tapestry.size(lineItems);
         for (int i = 0; i < count; i++) {
             SaleLineItem item = (SaleLineItem)lineItems.get(i);
             map.add(new Long(item.getSaleLineItemID()), item);
         }
         setLineItemEditMap(map);
}

public void synchronizeLineItem(IRequestCycle cycle) {
         ListEditMap map = getLineItemEditMap();
         SaleLineItem item = (SaleLineItem)map.getValue();

         if(item == null) {
             throw new PageRedirectException(this);
         }
         setLineItem(item);
}

//Listener Method Is Not Getting Called
//If line items are added to the list
public void completeSale(IRequestCycle cycle) {
	//The following lines are never printed after
	//an item is added to the list of line items
         System.out.println("*************************");
         System.out.println("finalizing Sale");
         ListEditMap lineItemMap = getLineItemEditMap();

         List items = lineItemMap.getValues();

         for(int i = 0, n = items.size(); i < n; i++) {
             System.out.println(items.get(i));
         }
}


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


Re: Help!!! Strange behavior occuring with ListEdit component

Posted by Travis Romney <tr...@inpowered.com>.
I've tried that.
I'm getting the same problem either way.


Glen Stampoultzis wrote:
> Regarding the submit button...
> 
> You're better off attaching the listener to the form and using the 
> selected and tag parameters of the submit buttons to determine which 
> button was pressed.
> 
> It's all got to do with the order in which listeners are called in the 
> rewind sequence.
> 
> Regards,
> 
> Glen
> 
> At 10:28 AM 4/08/2004, Travis Romney wrote:
> 
>> I'm fairly new with Tapestry and so far everything has gone quite well.
>> However, I have hit a large road block, and am losing all of my hair 
>> over it.  I have a page that contains a list of products that are added
>> dynamically by the user.  I am using a ListEdit component to maintain
>> this list. The list contains prices and quantities that can be edited
>> by the user. At the bottom of the page I have a submit button that
>> processes the page and updates the list.  There are two problems that
>> I am having when this page is submitted.  The first problem that
>> is occuring is that any changes that I make in the list are lost
>> when the page is submitted.  The second problem is the one that is
>> causing me the greatest stress.  The submit button at the bottom of
>> the page is tied to a specific listener method.  If I click on the 
>> submit button before any items are added to the list the listener
>> method gets called without any problems.  If I add a single product
>> to the list, my listener method will not get called.  If I place
>> the submit button above my ListEdit component the method will
>> get called but the list is empty.  I have been at this for
>> 3 days now and can't make any sense of it.
>> Please help before I end up in the nut house!
>>
>>
>> Here is a snippet of code that I am working with
>>
>> public abstract SaleLineItem getLineItem();
>> public abstract void setLineItem(SaleLineItem item);
>>
>> public void pageBeginRender(PageEvent pe) {
>>         this.lineItems = getSaleLineItems();
>>         readLineItems();
>> }
>>
>> private void readLineItems() throws java.sql.SQLException {
>>         ListEditMap map = new ListEditMap();
>>         int count = Tapestry.size(lineItems);
>>         for (int i = 0; i < count; i++) {
>>             SaleLineItem item = (SaleLineItem)lineItems.get(i);
>>             map.add(new Long(item.getSaleLineItemID()), item);
>>         }
>>         setLineItemEditMap(map);
>> }
>>
>> public void synchronizeLineItem(IRequestCycle cycle) {
>>         ListEditMap map = getLineItemEditMap();
>>         SaleLineItem item = (SaleLineItem)map.getValue();
>>
>>         if(item == null) {
>>             throw new PageRedirectException(this);
>>         }
>>         setLineItem(item);
>> }
>>
>> //Listener Method Is Not Getting Called
>> //If line items are added to the list
>> public void completeSale(IRequestCycle cycle) {
>>         //The following lines are never printed after
>>         //an item is added to the list of line items
>>         System.out.println("*************************");
>>         System.out.println("finalizing Sale");
>>         ListEditMap lineItemMap = getLineItemEditMap();
>>
>>         List items = lineItemMap.getValues();
>>
>>         for(int i = 0, n = items.size(); i < n; i++) {
>>             System.out.println(items.get(i));
>>         }
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
> 
> 
> Glen Stampoultzis
> gstamp@iinet.net.au
> http://members.iinet.net.au/~gstamp/glen/
> 


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


Re: Help!!! Strange behavior occuring with ListEdit component

Posted by Glen Stampoultzis <gs...@iinet.net.au>.
Regarding the submit button...

You're better off attaching the listener to the form and using the selected 
and tag parameters of the submit buttons to determine which button was pressed.

It's all got to do with the order in which listeners are called in the 
rewind sequence.

Regards,

Glen

At 10:28 AM 4/08/2004, Travis Romney wrote:
>I'm fairly new with Tapestry and so far everything has gone quite well.
>However, I have hit a large road block, and am losing all of my hair over 
>it.  I have a page that contains a list of products that are added
>dynamically by the user.  I am using a ListEdit component to maintain
>this list. The list contains prices and quantities that can be edited
>by the user. At the bottom of the page I have a submit button that
>processes the page and updates the list.  There are two problems that
>I am having when this page is submitted.  The first problem that
>is occuring is that any changes that I make in the list are lost
>when the page is submitted.  The second problem is the one that is
>causing me the greatest stress.  The submit button at the bottom of
>the page is tied to a specific listener method.  If I click on the submit 
>button before any items are added to the list the listener
>method gets called without any problems.  If I add a single product
>to the list, my listener method will not get called.  If I place
>the submit button above my ListEdit component the method will
>get called but the list is empty.  I have been at this for
>3 days now and can't make any sense of it.
>Please help before I end up in the nut house!
>
>
>Here is a snippet of code that I am working with
>
>public abstract SaleLineItem getLineItem();
>public abstract void setLineItem(SaleLineItem item);
>
>public void pageBeginRender(PageEvent pe) {
>         this.lineItems = getSaleLineItems();
>         readLineItems();
>}
>
>private void readLineItems() throws java.sql.SQLException {
>         ListEditMap map = new ListEditMap();
>         int count = Tapestry.size(lineItems);
>         for (int i = 0; i < count; i++) {
>             SaleLineItem item = (SaleLineItem)lineItems.get(i);
>             map.add(new Long(item.getSaleLineItemID()), item);
>         }
>         setLineItemEditMap(map);
>}
>
>public void synchronizeLineItem(IRequestCycle cycle) {
>         ListEditMap map = getLineItemEditMap();
>         SaleLineItem item = (SaleLineItem)map.getValue();
>
>         if(item == null) {
>             throw new PageRedirectException(this);
>         }
>         setLineItem(item);
>}
>
>//Listener Method Is Not Getting Called
>//If line items are added to the list
>public void completeSale(IRequestCycle cycle) {
>         //The following lines are never printed after
>         //an item is added to the list of line items
>         System.out.println("*************************");
>         System.out.println("finalizing Sale");
>         ListEditMap lineItemMap = getLineItemEditMap();
>
>         List items = lineItemMap.getValues();
>
>         for(int i = 0, n = items.size(); i < n; i++) {
>             System.out.println(items.get(i));
>         }
>}
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/

Re: Help!!! Strange behavior occuring with ListEdit component

Posted by Travis Romney <tr...@inpowered.com>.
That was it!
Thanks for your help!


Jamie Orchard-Hays wrote:
> You need to handle the rewind. You don't want to set your list up again
> during rewind:
> 
> public void pageBeginRender(PageEvent pe) {
>     if(pe.getRequestCycle().isRewinding()){
>         return;
>     }
>     this.lineItems = getSaleLineItems();
>     readLineItems();
> }
> 
> Also, you'll want your list to be persistent.
> 
> Jamie
> 
> ----- Original Message ----- 
> From: "Travis Romney" <tr...@inpowered.com>
> To: <ta...@jakarta.apache.org>
> Sent: Tuesday, August 03, 2004 8:28 PM
> Subject: Help!!! Strange behavior occuring with ListEdit component
> 
> 
> 
>>I'm fairly new with Tapestry and so far everything has gone quite well.
>>However, I have hit a large road block, and am losing all of my hair
>>over it.  I have a page that contains a list of products that are added
>>dynamically by the user.  I am using a ListEdit component to maintain
>>this list. The list contains prices and quantities that can be edited
>>by the user. At the bottom of the page I have a submit button that
>>processes the page and updates the list.  There are two problems that
>>I am having when this page is submitted.  The first problem that
>>is occuring is that any changes that I make in the list are lost
>>when the page is submitted.  The second problem is the one that is
>>causing me the greatest stress.  The submit button at the bottom of
>>the page is tied to a specific listener method.  If I click on the
>>submit button before any items are added to the list the listener
>>method gets called without any problems.  If I add a single product
>>to the list, my listener method will not get called.  If I place
>>the submit button above my ListEdit component the method will
>>get called but the list is empty.  I have been at this for
>>3 days now and can't make any sense of it.
>>Please help before I end up in the nut house!
>>
>>
>>Here is a snippet of code that I am working with
>>
>>public abstract SaleLineItem getLineItem();
>>public abstract void setLineItem(SaleLineItem item);
>>
>>public void pageBeginRender(PageEvent pe) {
>>this.lineItems = getSaleLineItems();
>>readLineItems();
>>}
>>
>>private void readLineItems() throws java.sql.SQLException {
>>         ListEditMap map = new ListEditMap();
>>         int count = Tapestry.size(lineItems);
>>         for (int i = 0; i < count; i++) {
>>             SaleLineItem item = (SaleLineItem)lineItems.get(i);
>>             map.add(new Long(item.getSaleLineItemID()), item);
>>         }
>>         setLineItemEditMap(map);
>>}
>>
>>public void synchronizeLineItem(IRequestCycle cycle) {
>>         ListEditMap map = getLineItemEditMap();
>>         SaleLineItem item = (SaleLineItem)map.getValue();
>>
>>         if(item == null) {
>>             throw new PageRedirectException(this);
>>         }
>>         setLineItem(item);
>>}
>>
>>//Listener Method Is Not Getting Called
>>//If line items are added to the list
>>public void completeSale(IRequestCycle cycle) {
>>//The following lines are never printed after
>>//an item is added to the list of line items
>>         System.out.println("*************************");
>>         System.out.println("finalizing Sale");
>>         ListEditMap lineItemMap = getLineItemEditMap();
>>
>>         List items = lineItemMap.getValues();
>>
>>         for(int i = 0, n = items.size(); i < n; i++) {
>>             System.out.println(items.get(i));
>>         }
>>}
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: Help!!! Strange behavior occuring with ListEdit component

Posted by Jamie Orchard-Hays <ja...@dang.com>.
You need to handle the rewind. You don't want to set your list up again
during rewind:

public void pageBeginRender(PageEvent pe) {
    if(pe.getRequestCycle().isRewinding()){
        return;
    }
    this.lineItems = getSaleLineItems();
    readLineItems();
}

Also, you'll want your list to be persistent.

Jamie

----- Original Message ----- 
From: "Travis Romney" <tr...@inpowered.com>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, August 03, 2004 8:28 PM
Subject: Help!!! Strange behavior occuring with ListEdit component


> I'm fairly new with Tapestry and so far everything has gone quite well.
> However, I have hit a large road block, and am losing all of my hair
> over it.  I have a page that contains a list of products that are added
> dynamically by the user.  I am using a ListEdit component to maintain
> this list. The list contains prices and quantities that can be edited
> by the user. At the bottom of the page I have a submit button that
> processes the page and updates the list.  There are two problems that
> I am having when this page is submitted.  The first problem that
> is occuring is that any changes that I make in the list are lost
> when the page is submitted.  The second problem is the one that is
> causing me the greatest stress.  The submit button at the bottom of
> the page is tied to a specific listener method.  If I click on the
> submit button before any items are added to the list the listener
> method gets called without any problems.  If I add a single product
> to the list, my listener method will not get called.  If I place
> the submit button above my ListEdit component the method will
> get called but the list is empty.  I have been at this for
> 3 days now and can't make any sense of it.
> Please help before I end up in the nut house!
>
>
> Here is a snippet of code that I am working with
>
> public abstract SaleLineItem getLineItem();
> public abstract void setLineItem(SaleLineItem item);
>
> public void pageBeginRender(PageEvent pe) {
> this.lineItems = getSaleLineItems();
> readLineItems();
> }
>
> private void readLineItems() throws java.sql.SQLException {
>          ListEditMap map = new ListEditMap();
>          int count = Tapestry.size(lineItems);
>          for (int i = 0; i < count; i++) {
>              SaleLineItem item = (SaleLineItem)lineItems.get(i);
>              map.add(new Long(item.getSaleLineItemID()), item);
>          }
>          setLineItemEditMap(map);
> }
>
> public void synchronizeLineItem(IRequestCycle cycle) {
>          ListEditMap map = getLineItemEditMap();
>          SaleLineItem item = (SaleLineItem)map.getValue();
>
>          if(item == null) {
>              throw new PageRedirectException(this);
>          }
>          setLineItem(item);
> }
>
> //Listener Method Is Not Getting Called
> //If line items are added to the list
> public void completeSale(IRequestCycle cycle) {
> //The following lines are never printed after
> //an item is added to the list of line items
>          System.out.println("*************************");
>          System.out.println("finalizing Sale");
>          ListEditMap lineItemMap = getLineItemEditMap();
>
>          List items = lineItemMap.getValues();
>
>          for(int i = 0, n = items.size(); i < n; i++) {
>              System.out.println(items.get(i));
>          }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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