You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jun Tsai <ju...@gmail.com> on 2005/09/12 11:10:12 UTC

How to avoid rewind a list?

hi ,all
I have a form includes a checkbox group component.I find If I submit the 
form,it will call my getListData method again.How to avoid this?I want to 
get the checkbox value(primary key value) only!
Thanks.
Jun Tsai

-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

RE: How to avoid rewind a list?

Posted by Patrick Casey <pa...@adelphia.net>.
	Perhaps if you moved your database code from getListData() to
PageBeginRender and went with:

public void pageBeginRender(PageEvent event) {
		if (event.getRequestCycle().isRewinding())
			return;
		setupListData();
	}

	?

	

> -----Original Message-----
> From: Jun Tsai [mailto:jun.tsai@gmail.com]
> Sent: Monday, September 12, 2005 6:18 PM
> To: Tapestry users
> Subject: Re: How to avoid rewind a list?
> 
> Thank your reply.But when I submit my form ,It will fire my getListData
> method which fetch data from database.
> 
> ps:cycle.getRequestContext().getRequest()
> .getParameterNames();
> It will be deprecated in TP4.
> 
> On 9/13/05, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >
> > Something like this might work for you.
> >
> > --- Pat
> > Public void doDeletes(IRequestCycle cycle) {
> > Enumeration en = cycle.getRequestContext().getRequest()
> > .getParameterNames();
> > ArrayList keys = new ArrayList();
> > while (en.hasMoreElements()) {
> > String s = (String) en.nextElement();
> > String value =
> > cycle.getRequestContext().getParameter(s);
> >
> > if (s.startsWith(FastGrid.POST_HEADER)) {
> > String id =
> > s.substring(FastGrid.POST_HEADER.length());
> > if (value.equals("on"))
> > keys.add(id);
> > }
> > }
> > if (keys.size() > 0) {
> > HibHelper.beginTransaction();
> > Criteria c =
> > HibHelper.getSession().createCriteria(fObjectClass);
> > c.add(Expression.in("id", keys));
> > List l = c.list();
> > for (int x = 0; x < l.size(); x++) {
> > HibHelper.getSession().delete(l.get(x));
> > }
> > HibHelper.commitTransaction();
> > fMessage = "Successfully deleted " + l.size() + "
> > records.";
> > }
> >
> > > -----Original Message-----
> > > From: news [mailto:news@sea.gmane.org] On Behalf Of Ron Piterman
> > > Sent: Monday, September 12, 2005 4:30 AM
> > > To: tapestry-user@jakarta.apache.org
> > > Subject: Re: How to avoid rewind a list?
> > >
> > > Forms in Tapestry always rewind. If you don't want to get the list
> from
> > > the database again, you can "persist" it in the session.
> > >
> > > ציטוט Jun Tsai:
> > > > hi ,all
> > > > I have a form includes a checkbox group component.I find If I submit
> > the
> > > > form,it will call my getListData method again.How to avoid this?I
> want
> > > to
> > > > get the checkbox value(primary key value) only!
> > > > Thanks.
> > > > Jun Tsai
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
> 
> 
> --
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net



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


Re: How to avoid rewind a list?

Posted by Jun Tsai <ju...@gmail.com>.
Thank your reply.But when I submit my form ,It will fire my getListData 
method which fetch data from database.

ps:cycle.getRequestContext().getRequest()
.getParameterNames();
It will be deprecated in TP4.

On 9/13/05, Patrick Casey <pa...@adelphia.net> wrote:
> 
> 
> Something like this might work for you.
> 
> --- Pat
> Public void doDeletes(IRequestCycle cycle) {
> Enumeration en = cycle.getRequestContext().getRequest()
> .getParameterNames();
> ArrayList keys = new ArrayList();
> while (en.hasMoreElements()) {
> String s = (String) en.nextElement();
> String value =
> cycle.getRequestContext().getParameter(s);
> 
> if (s.startsWith(FastGrid.POST_HEADER)) {
> String id =
> s.substring(FastGrid.POST_HEADER.length());
> if (value.equals("on"))
> keys.add(id);
> }
> }
> if (keys.size() > 0) {
> HibHelper.beginTransaction();
> Criteria c =
> HibHelper.getSession().createCriteria(fObjectClass);
> c.add(Expression.in("id", keys));
> List l = c.list();
> for (int x = 0; x < l.size(); x++) {
> HibHelper.getSession().delete(l.get(x));
> }
> HibHelper.commitTransaction();
> fMessage = "Successfully deleted " + l.size() + "
> records.";
> }
> 
> > -----Original Message-----
> > From: news [mailto:news@sea.gmane.org] On Behalf Of Ron Piterman
> > Sent: Monday, September 12, 2005 4:30 AM
> > To: tapestry-user@jakarta.apache.org
> > Subject: Re: How to avoid rewind a list?
> >
> > Forms in Tapestry always rewind. If you don't want to get the list from
> > the database again, you can "persist" it in the session.
> >
> > ציטוט Jun Tsai:
> > > hi ,all
> > > I have a form includes a checkbox group component.I find If I submit 
> the
> > > form,it will call my getListData method again.How to avoid this?I want
> > to
> > > get the checkbox value(primary key value) only!
> > > Thanks.
> > > Jun Tsai
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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
> 
> 


-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

RE: How to avoid rewind a list?

Posted by Patrick Casey <pa...@adelphia.net>.
	Something like this might work for you.

	--- Pat
Public void doDeletes(IRequestCycle cycle) {
Enumeration en = cycle.getRequestContext().getRequest()
				.getParameterNames();
		ArrayList keys = new ArrayList();
		while (en.hasMoreElements()) {
			String s = (String) en.nextElement();
			String value =
cycle.getRequestContext().getParameter(s);

			if (s.startsWith(FastGrid.POST_HEADER)) {
				String id =
s.substring(FastGrid.POST_HEADER.length());
				if (value.equals("on"))
					keys.add(id);
			}
		}
		if (keys.size() > 0) {
			HibHelper.beginTransaction();
			Criteria c =
HibHelper.getSession().createCriteria(fObjectClass);
			c.add(Expression.in("id", keys));
			List l = c.list();
			for (int x = 0; x < l.size(); x++) {
				HibHelper.getSession().delete(l.get(x));
			}
			HibHelper.commitTransaction();
			fMessage = "Successfully deleted " + l.size() + "
records.";
		}		

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Ron Piterman
> Sent: Monday, September 12, 2005 4:30 AM
> To: tapestry-user@jakarta.apache.org
> Subject: Re: How to avoid rewind a list?
> 
> Forms in Tapestry always rewind. If you don't want to get the list from
> the database again, you can "persist" it in the session.
> 
> ציטוט Jun Tsai:
> > hi ,all
> > I have a form includes a checkbox group component.I find If I submit the
> > form,it will call my getListData method again.How to avoid this?I want
> to
> > get the checkbox value(primary key value) only!
> > Thanks.
> > Jun Tsai
> >
> 
> 
> ---------------------------------------------------------------------
> 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: How to avoid rewind a list?

Posted by Ron Piterman <rp...@gmx.net>.
Forms in Tapestry always rewind. If you don't want to get the list from 
the database again, you can "persist" it in the session.

ציטוט Jun Tsai:
> hi ,all
> I have a form includes a checkbox group component.I find If I submit the 
> form,it will call my getListData method again.How to avoid this?I want to 
> get the checkbox value(primary key value) only!
> Thanks.
> Jun Tsai
> 


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


Re: How to avoid rewind a list?

Posted by Paul Cantrell <ca...@pobox.com>.
If you implement it using the For component, you can set  
volatile=true. (This is risky business, though.)

Cheers,

Paul

On Sep 12, 2005, at 4:10 AM, Jun Tsai wrote:

> hi ,all
> I have a form includes a checkbox group component.I find If I  
> submit the
> form,it will call my getListData method again.How to avoid this?I  
> want to
> get the checkbox value(primary key value) only!
> Thanks.
> Jun Tsai
>
> -- 
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net
>


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