You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Ido M. Tamir" <ta...@imp.univie.ac.at> on 2006/06/09 14:58:11 UTC

[3.0]: custom component in contrib:table sorting

Hi,

I revived an old tapestry app (3.0). Now I realized that my custom component
does not get updated correctly within an contrib:table.
This means: when I sort the table, the values of the @PropertySelection
which are contained within the component do not get updated, but still
get their values from the parameter that was at this row before sorting.
The @PropertySelection would also like to write its content into the the row 
that is now at this place, when submitting the form after sorting. When 
really reloading the page, everything is in place again.

Example: (where the second column is a drop down - my custom component -
and the third some other property that gets sorted correctly).
before sort (correct):
Name     Bet   Points
Name3   3       4
Name2   2       5
Name1   1       6

after sort (wrong):
Name     Bet   Points
Name1   3       6
Name2   2       5
Name3   1       4


The component is embedded within a contrib:table which is embedded
in a form. The source for the table is a List of Bets. All of this works: 
updating values and submitting, paging etc. but when I sort by some column
of the table, the parameters of the component (the Bet) seem not to have
been updated. Other columns defined as Blocks seem to have been sorted 
correctly. 

So I guess its not the Block that is causing this, but some problem with
updating the parameter and the associated PropertySelection of my
component.

So now I started to simply disallow all sorting, but that's not really a 
good option.

thanks for your suggestions,
I hope somebody has still interest in answering questions for
old stuff.

ido

.html:
<form jwcid="@Form" listener="ognl:listeners.formSubmit">
<table jwcid="table"/>
<span jwcid="betColumnValue@Block">
 		<span jwcid="@BetRenderer" bet="ognl:components.table.tableRow"/>
</span>
<span jwcid="@Submit" tag="Save Changes" selected="ognl:buttonClicked" 
value="Save Changes"/>
....

.page
<property-specification name="bets" type="java.util.List" persistent="yes"/>
<component id="table" type="contrib:Table">
<binding name="source" expression="bets"/>
	<binding name="columns">
		'*user:Name:user.userName,' +
		'bet:Bet:result,' +
		'points:Points:points '
  	</binding>
</component>

component:
<span jwcid="$content$">
	<span jwcid="@contrib:FormConditional" condition="ognl:changeable">
			<span jwcid="@PropertySelection" 	
model="ognl:@org.jockeysoft.betjockey.web.components.BetRenderer@GOAL_MODEL" 
value="ognl:bet.converter.firstGoals" disabled="false"/>
	</span>	
	<span jwcid="@contrib:FormConditional" condition="ognl:!changeable">
			<span jwcid="@Insert" value="ognl:bet.firstGoals"/>	
	</span>
        .....
</span>

jwc:
<component-specification 
class="org.jockeysoft.betjockey.web.components.BetRenderer" allow-body="no" 
allow-informal-parameters="no">
	<parameter name="bet" type="org.jockeysoft.betjockey.model.Bet" 
required="yes" direction="auto"/>
</component-specification>

.java:
public abstract class BetRenderer extends BaseComponent {
	public static final IPropertySelectionModel GOAL_MODEL = new 
GoalPropertySelectionModel();
	public abstract Bet getBet();
    public abstract void setBet(Bet bet);
    
	public boolean getChangeable(){
		//some logic dependent on the Bet & current user 
	}
	public IPropertySelectionModel getModel(){
		return GOAL_MODEL;
	}
	
}

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