You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by robnangle <ro...@gmail.com> on 2011/04/13 12:41:02 UTC

T5: Select wont find selected value in edit?

Hi I have a problem when I am trying to edit values that the selected value
does not appear? My code is below and I thought you just put into
value="team.keeper" which would return the keeper. The two classes both have
@Property+@Persist annotations.

tml for edit class:



insert for creating the values Work method is a regex which replaces part of
the string value:

String statement = "INSERT INTO teams(goalkeeper) VALUES(?)";
		prep = conn.prepareStatement(statement);
		team = new Team();
		prep.setString(1, work(keeper));
		team.setKeeper(keeper);
                 prep.executeUpdate();
		return index;

Any help is greatly appreciated as always..
Cheers

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300292.html
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: Select wont find selected value in edit?

Posted by robnangle <ro...@gmail.com>.
Richard Hill-7 wrote:
> 
> It depends. If you have a static list of players then you can store your
> select model in the session. If it's dynamic, you prob want to reload
> from the db each time.
> 
> To be honest I'm not sure that storing stuff like this as an SSO is
> best-practice - it's more for user session state. And you want to limit
> what you store in the session anyway as it contributes to your
> application's overhead - small objects, primitive data types, not huge
> lists of complex objects. These should come from the db.
> 
> Although a more experienced Tapestry dev can confirm.
> 

Yes thats what I thought. What is strange is that it works for editing user
details? But wont for editing the team. Thats why I thought it was to do
with the way im adding the team(keeper...). As i change the string value
when adding it to the database.

prep.setString(3, work(keeper)); // the work method changes the string to
say 'Steven Gerrard'
team.setKeeper(keeper); // this is the whole value 'Liverpool - Steven
Gerrard'

Does this changes things?


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300442.html
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: Select wont find selected value in edit?

Posted by Richard Hill <ri...@su3analytics.com>.
It depends. If you have a static list of players then you can store your
select model in the session. If it's dynamic, you prob want to reload
from the db each time.

To be honest I'm not sure that storing stuff like this as an SSO is
best-practice - it's more for user session state. And you want to limit
what you store in the session anyway as it contributes to your
application's overhead - small objects, primitive data types, not huge
lists of complex objects. These should come from the db.

Although a more experienced Tapestry dev can confirm.





On Wed, 2011-04-13 at 04:56 -0700, robnangle wrote:
> Richard Hill-7 wrote:
> > 
> > are "add" and "edit" page classes?
> > 
> > 
> 
> They are yes.. All values are @Persist, @Property
> 
> So is the only way to get the default value up by setting all players as
> sso's?
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300407.html
> 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
> 



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


Re: T5: Select wont find selected value in edit?

Posted by robnangle <ro...@gmail.com>.
Richard Hill-7 wrote:
> 
> are "add" and "edit" page classes?
> 
> 

They are yes.. All values are @Persist, @Property

So is the only way to get the default value up by setting all players as
sso's?


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300407.html
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: Select wont find selected value in edit?

Posted by Richard Hill <ri...@su3analytics.com>.
are "add" and "edit" page classes?

If you instantiate an object in one page it won't be set in another,
unless you persist as an SSO

@Persist is only scoped to a particular page, i.e saves values between
requests. An @Persist'd object is not visible to other pages.




On Wed, 2011-04-13 at 04:41 -0700, robnangle wrote:
> Richard Hill-7 wrote:
> > 
> > the value attribute will set (choose) the drop down value from the
> > options defined in goalkeepers. Does this option/value exist in your
> > model?
> > 
> > 
> > 
> > 
> > On Wed, 2011-04-13 at 04:30 -0700, robnangle wrote:
> >> t:select t:id="goalkeeper" model="goalkeepers" value="team.keeper"
> >> blankOption="never"/
> >> 
> >> --
> >> View this message in context:
> >> http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300356.html
> >> 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
> >> 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> 
> It does yes, its just a list of all the goalkeepers so there is no way that
> one is missng. It seems to be saying the keeper property is null in the edit
> class, but that shouldn't be as its beeing set when a user creates it in the
> add class?
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300371.html
> 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
> 



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


Re: T5: Select wont find selected value in edit?

Posted by robnangle <ro...@gmail.com>.
Richard Hill-7 wrote:
> 
> the value attribute will set (choose) the drop down value from the
> options defined in goalkeepers. Does this option/value exist in your
> model?
> 
> 
> 
> 
> On Wed, 2011-04-13 at 04:30 -0700, robnangle wrote:
>> t:select t:id="goalkeeper" model="goalkeepers" value="team.keeper"
>> blankOption="never"/
>> 
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300356.html
>> 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
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

It does yes, its just a list of all the goalkeepers so there is no way that
one is missng. It seems to be saying the keeper property is null in the edit
class, but that shouldn't be as its beeing set when a user creates it in the
add class?


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300371.html
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: Select wont find selected value in edit?

Posted by Richard Hill <ri...@su3analytics.com>.
the value attribute will set (choose) the drop down value from the
options defined in goalkeepers. Does this option/value exist in your
model?




On Wed, 2011-04-13 at 04:30 -0700, robnangle wrote:
> t:select t:id="goalkeeper" model="goalkeepers" value="team.keeper"
> blankOption="never"/
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300356.html
> 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
> 



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


Re: T5: Select wont find selected value in edit?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 13 Apr 2011 09:44:43 -0300, robnangle <ro...@gmail.com> wrote:

> Ok and this method should be in the getKeepers()?

It should be in the class of the objects used as options.

> What do i check if its equal to?

It varies depending on the class itself, what it means and how object  
identity is defined for it.

> Apologies for what probably are stupid questions, I just hevnt yet
> encountered them..

This is basic Java knowledge. Check this:  
http://www.ibm.com/developerworks/java/library/j-jtp05273/index.html

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: T5: Select wont find selected value in edit?

Posted by robnangle <ro...@gmail.com>.
Thiago H. de Paula Figueiredo wrote:
> 
> On Wed, 13 Apr 2011 09:33:04 -0300, robnangle &lt;robnangle@gmail.com&gt;
> wrote:
> 
>> There is no goalkeepers class, goalkeepers is just a list of players  
>> taken from the database:
>> public List getGoalkeepers() {
>> 		gsp = new GenerateSelectPlayers(); // class that generates the players
>> from the db
>> 		return gsp.getGoalkeepers();
>> 	}
> 
> Again: to make Select (and any operation in Java collections) work, the  
> object type you're putting in the collection needs to have appropriate  
> equals() and hashCode() methods.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

Ok and this method should be in the getKeepers()?

What do i check if its equal to? 

Apologies for what probably are stupid questions, I just hevnt yet
encountered them..


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300494.html
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: Select wont find selected value in edit?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 13 Apr 2011 09:33:04 -0300, robnangle <ro...@gmail.com> wrote:

> There is no goalkeepers class, goalkeepers is just a list of players  
> taken from the database:
> public List getGoalkeepers() {
> 		gsp = new GenerateSelectPlayers(); // class that generates the players
> from the db
> 		return gsp.getGoalkeepers();
> 	}

Again: to make Select (and any operation in Java collections) work, the  
object type you're putting in the collection needs to have appropriate  
equals() and hashCode() methods.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: T5: Select wont find selected value in edit?

Posted by robnangle <ro...@gmail.com>.
Thiago H. de Paula Figueiredo wrote:
> 
> On Wed, 13 Apr 2011 08:30:42 -0300, robnangle &lt;robnangle@gmail.com&gt;
> wrote:
> 
>> t:select t:id="goalkeeper" model="goalkeepers" value="team.keeper"
>> blankOption="never"/
> 
> Make sure you overrode the equals() and hashCode() methods in the  
> Goalkeeper class with a correct implementation.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

There is no goalkeepers class, goalkeepers is just a list of players taken
from the database:

public List getGoalkeepers() {
		gsp = new GenerateSelectPlayers(); // class that generates the players
from the db
		return gsp.getGoalkeepers();
	}


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300475.html
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: Select wont find selected value in edit?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 13 Apr 2011 08:30:42 -0300, robnangle <ro...@gmail.com> wrote:

> t:select t:id="goalkeeper" model="goalkeepers" value="team.keeper"
> blankOption="never"/

Make sure you overrode the equals() and hashCode() methods in the  
Goalkeeper class with a correct implementation.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: T5: Select wont find selected value in edit?

Posted by robnangle <ro...@gmail.com>.
t:select t:id="goalkeeper" model="goalkeepers" value="team.keeper"
blankOption="never"/

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300356.html
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: Select wont find selected value in edit?

Posted by Richard Hill <ri...@su3analytics.com>.
no .tml here....



On Wed, 2011-04-13 at 03:41 -0700, robnangle wrote:
> Hi I have a problem when I am trying to edit values that the selected value
> does not appear? My code is below and I thought you just put into
> value="team.keeper" which would return the keeper. The two classes both have
> @Property+@Persist annotations.
> 
> tml for edit class:
> 
> 
> 
> insert for creating the values Work method is a regex which replaces part of
> the string value:
> 
> String statement = "INSERT INTO teams(goalkeeper) VALUES(?)";
> 		prep = conn.prepareStatement(statement);
> 		team = new Team();
> 		prep.setString(1, work(keeper));
> 		team.setKeeper(keeper);
>                  prep.executeUpdate();
> 		return index;
> 
> Any help is greatly appreciated as always..
> Cheers
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Select-wont-find-selected-value-in-edit-tp4300292p4300292.html
> 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
> 



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