You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Ritesh.S" <ri...@avibha.com> on 2007/11/20 15:23:28 UTC

T5 persisting select component selection after form submission

Hello everybody,

I am newbie to Tapestry. I am using Tapestry 5 for developing 
an application and I encountered following problem if anyone 
suggest a solution it will be very helpful for me. :)

I have a select component with GenericSelectModel which shows 
values well on first display. When I select some option from this 
select component and submit the form I have to persist the selected 
option, but it does not. :<

I am fetching values for this model from database 
on @SetupRender phase (tried onActivate(), pageLoaded() also - same problem
occurred).
When I don't use any render phase or event it persists the value but 
when some options are added in database from other page it does not 
fetch the current saved options in drop down list (since no render phase or
event).

This the source code I am using -

@SetupRender
void setValues(){	
        List<SomeBean> bean= new ArrayList<SomeBean>();	
	bean.addAll(myDao.getBeanList());		
	someBeans = new
GenericSelectModel<SomeList>(dev,SomeList.class,"name","id",access);		
}
	
public GenericSelectModel<SomeList> getSomeModel() {	    
	return someBeans;
}	

Does anyone faced this problem and have solution please let me know. 

Thanks in advance. :)

From,
Ritesh Sandupatla
-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a13857687
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 persisting select component selection after form submission

Posted by "Ritesh.S" <ri...@avibha.com>.
Hello Thiago H de Paula Figueiredo-2 and All Tapestry Developers,

If you remember you helped me in the problem of persisting the value of
select component
in action request, it is working correctly now.

I have some thing different now. 

When I save new value in database which is actually shown in this select
component,
after saving and rendering the page the select component shows the new
value.

But when I select this new value to perform action it doesn't persist in
action request
it is received as null while other previous values of this select component
never received null
on action after saving new value.
Only new value received null in action so it does not persists on page after
action request.

Can anyone tell why this happening? Am I wrong somewhere?

Any help is appreciated... Thanks in advance...

With Regards,
S. Ritesh

Following is my previous conversation with Thiago -

Ritesh.S wrote:
> 
> OK I will study the links you provided. Thanks for your help.
> 
> 
> Thiago H de Paula Figueiredo-2 wrote:
>> 
>> On Wed, 21 Nov 2007 10:57:46 -0200, Ritesh.S <ri...@avibha.com> wrote:
>> 
>>> If I am not bothering you, I will like to ask you for which classes or
>>> situations this equals method overriding is necessary. If you like to  
>>> answer I would
>>> like to know.
>> 
>> If your objects can be added to a collection, you need to at least  
>> override the equals() method. If they can be added to a map (including  
>> hash tables), you need to override both equals() and hashCode(). On the  
>> othher hand, it is a good practice to override both equals() and  
>> hashCode() for every entity class.
>> 
>> For more information, take a look at  
>> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)  
>> and  
>> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode().
>> 
>> -- 
>> Thiago H. de Paula Figueiredo
>> Desenvolvedor, Instrutor e Consultor de Tecnologia
>> Eteg Tecnologia da Informação Ltda.
>> http://www.eteg.com.br
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a14058751
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 persisting select component selection after form submission

Posted by "Ritesh.S" <ri...@avibha.com>.
OK I will study the links you provided. Thanks for your help.


Thiago H de Paula Figueiredo-2 wrote:
> 
> On Wed, 21 Nov 2007 10:57:46 -0200, Ritesh.S <ri...@avibha.com> wrote:
> 
>> If I am not bothering you, I will like to ask you for which classes or
>> situations this equals method overriding is necessary. If you like to  
>> answer I would
>> like to know.
> 
> If your objects can be added to a collection, you need to at least  
> override the equals() method. If they can be added to a map (including  
> hash tables), you need to override both equals() and hashCode(). On the  
> othher hand, it is a good practice to override both equals() and  
> hashCode() for every entity class.
> 
> For more information, take a look at  
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)  
> and  
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode().
> 
> -- 
> Thiago H. de Paula Figueiredo
> Desenvolvedor, Instrutor e Consultor de Tecnologia
> Eteg Tecnologia da Informação Ltda.
> http://www.eteg.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a13876854
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 persisting select component selection after form submission

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 21 Nov 2007 10:57:46 -0200, Ritesh.S <ri...@avibha.com> wrote:

> If I am not bothering you, I will like to ask you for which classes or
> situations this equals method overriding is necessary. If you like to  
> answer I would
> like to know.

If your objects can be added to a collection, you need to at least  
override the equals() method. If they can be added to a map (including  
hash tables), you need to override both equals() and hashCode(). On the  
othher hand, it is a good practice to override both equals() and  
hashCode() for every entity class.

For more information, take a look at  
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)  
and  
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode().

-- 
Thiago H. de Paula Figueiredo
Desenvolvedor, Instrutor e Consultor de Tecnologia
Eteg Tecnologia da Informação Ltda.
http://www.eteg.com.br

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


Re: T5 persisting select component selection after form submission

Posted by "Ritesh.S" <ri...@avibha.com>.
If I am not bothering you, I will like to ask you for which classes or
situations
this equals method overriding is necessary. If you like to answer I would
like to know.
Thanks.


Ritesh.S wrote:
> 
> Thanks Thiago H de Paula Figueiredo-2.
> You are right I didn't have the overriden method equals for select option.
> After adding it working correctly. Thank you very much for your reply.
> 
> 
> Thiago H de Paula Figueiredo-2 wrote:
>> 
>> On Wed, 21 Nov 2007 03:46:22 -0200, Ritesh.S <ri...@avibha.com> wrote:
>> 
>>> Means select component shows first default option after action performed  
>>> though there is a persisted value from previous
>>> request in variable.
>> 
>> Have your select options class overrides the equals() method? If not,  
>> there's a large probability of it being the source of the problem. ;)
>> 
>> -- 
>> Thiago H. de Paula Figueiredo
>> Desenvolvedor, Instrutor e Consultor de Tecnologia
>> Eteg Tecnologia da Informação Ltda.
>> http://www.eteg.com.br
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a13876492
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 persisting select component selection after form submission

Posted by "Ritesh.S" <ri...@avibha.com>.
Thanks Thiago H de Paula Figueiredo-2.
You are right I didn't have the overriden method equals for select option.
After adding it working correctly. Thank you very much for your reply.


Thiago H de Paula Figueiredo-2 wrote:
> 
> On Wed, 21 Nov 2007 03:46:22 -0200, Ritesh.S <ri...@avibha.com> wrote:
> 
>> Means select component shows first default option after action performed  
>> though there is a persisted value from previous
>> request in variable.
> 
> Have your select options class overrides the equals() method? If not,  
> there's a large probability of it being the source of the problem. ;)
> 
> -- 
> Thiago H. de Paula Figueiredo
> Desenvolvedor, Instrutor e Consultor de Tecnologia
> Eteg Tecnologia da Informação Ltda.
> http://www.eteg.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a13876491
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 persisting select component selection after form submission

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 21 Nov 2007 03:46:22 -0200, Ritesh.S <ri...@avibha.com> wrote:

> Means select component shows first default option after action performed  
> though there is a persisted value from previous
> request in variable.

Have your select options class overrides the equals() method? If not,  
there's a large probability of it being the source of the problem. ;)

-- 
Thiago H. de Paula Figueiredo
Desenvolvedor, Instrutor e Consultor de Tecnologia
Eteg Tecnologia da Informação Ltda.
http://www.eteg.com.br

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


Re: T5 persisting select component selection after form submission

Posted by "Ritesh.S" <ri...@avibha.com>.
Hello Jeffrey,

Thanks for your reply. :)

>And you say if you use any render phase the value is not persisted.
>Persists to where?

I mean to say that when I  don't use any render phase or event 
it [the select component] persists the value after page is been called
on action.[In this case I used constructor to fetch database values]
 
>Do you just mean, in the action request, the value is correctly set to a
variable in your page?

No, the selected option value persists in action request but it doesn't get 
set to select component. Means select component shows first default option
after action performed though there is a persisted value from previous
request in variable.
I can't set this value to select component again. I tried everything in my
knowledge
to do that. 

Did you got the problem now? 


jeffrey ai wrote:
> 
> Hi Ritesh,
> 
> I am not quite clear of your problem.
> 
>> When I don't use any render phase or event it persists the value 
> 
> And you say if you use any render phase the value is not persisted.
> Persists to where? Do you just mean, in the action request, the value is
> correctly set to a variable in your page?
> 
> Jeffrey Ai
> 

-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a13871490
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 persisting select component selection after form submission

Posted by jeffrey ai <jf...@gmail.com>.
Hi Ritesh,

I am not quite clear of your problem.

> When I don't use any render phase or event it persists the value 

And you say if you use any render phase the value is not persisted.
Persists to where? Do you just mean, in the action request, the value is
correctly set to a variable in your page?

Jeffrey Ai


Ritesh.S wrote:
> 
> Hello everybody,
> 
> I am newbie to Tapestry. I am using Tapestry 5 for developing 
> an application and I encountered following problem if anyone 
> suggest a solution it will be very helpful for me. :)
> 
> I have a select component with GenericSelectModel which shows 
> values well on first display. When I select some option from this 
> select component and submit the form I have to persist the selected 
> option, but it does not. :<
> 
> I am fetching values for this model from database 
> on @SetupRender phase (tried onActivate(), pageLoaded() also - same
> problem occurred).
> When I don't use any render phase or event it persists the value but 
> when some options are added in database from other page it does not 
> fetch the current saved options in drop down list (since no render phase
> or event).
> 
> This the source code I am using -
> 
> @SetupRender
> void setValues(){	
>         List<SomeBean> bean= new ArrayList<SomeBean>();	
> 	bean.addAll(myDao.getBeanList());		
> 	someBeans = new
> GenericSelectModel<SomeList>(dev,SomeList.class,"name","id",access);		
> }
> 	
> public GenericSelectModel<SomeList> getSomeModel() {	    
> 	return someBeans;
> }	
> 
> Does anyone faced this problem and have solution please let me know. 
> 
> Thanks in advance. :)
> 
> From,
> Ritesh Sandupatla
> 

-- 
View this message in context: http://www.nabble.com/T5-persisting-select-component-selection-after-form-submission-tf4843731.html#a13861834
Sent from the Tapestry - User mailing list archive at Nabble.com.


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