Re: T5: disabling column sorting programmatically in Grid

2009-01-19 Thread Thiago H. de Paula Figueiredo
Em Mon, 19 Jan 2009 13:33:42 -0300, immutability devli...@bielik.org  
escreveu:



So I thought of the standard way of doing this - in the
onSuccessFromFormFilter handler I do the following:


As Tapestry uses redirect-after-post by default, it does not renders the  
page in the same request it processes form submissions. You're setting  
that column as unsortable in the form submission request, when it must be  
set in the render request. One way to do it is to  
nameColumn.sortable(false) the the method that returns the BeanModel.


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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



Re: T5: disabling column sorting programmatically in Grid

2009-01-19 Thread immutability

Thiago, thank you for a quick response, I still have a lot to learn!

 One way to do it is to nameColumn.sortable(false) the 
 the method that returns the BeanModel.
I'm confused at this point. I'm currently not returning the BeanModel
anywhere. When I was using BeanModel to add custom columns, it was a
property that was then bound to the grid component in the .tml file (i.e.
model=model) but since the recent versions of Tapestry5 do not require me
to add custom columns using the BeanModel code, I'm not doing this anymore.
Hence, my first use of the BeanModel was this - to try and make an existing
column sortable (or not-sortable). 

Could you please elaborate (at least in short) on returning the BeanModel in
my scenario (where I first get it from an existing grid rather than create
BeanModel from scratch). I'm sorry for sounding so dumb! :) And thanks
again!


-- 
View this message in context: 
http://www.nabble.com/T5%3A-disabling-column-sorting-programmatically-in-Grid-tp21546541p21547589.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5: disabling column sorting programmatically in Grid

2009-01-19 Thread Thiago H. de Paula Figueiredo
Em Mon, 19 Jan 2009 14:27:35 -0300, immutability devli...@bielik.org  
escreveu:



Thiago, thank you for a quick response, I still have a lot to learn!


You're welcome! We all stilee need a lot to learn . . .


One way to do it is to nameColumn.sortable(false) the
the method that returns the BeanModel.

I'm confused at this point. I'm currently not returning the BeanModel
anywhere. When I was using BeanModel to add custom columns, it was a
property that was then bound to the grid component in the .tml file (i.e.
model=model) but since the recent versions of Tapestry5 do not require  
me to add custom columns using the BeanModel code, I'm not doing this  
anymore. Hence, my first use of the BeanModel was this - to try and make  
an existing column sortable (or not-sortable).


Let me put that in other way: regardless of the origin of the BeanModel  
(created by you or obtained from the Grid instance directly), you should  
change it in the render request, not in the form submission processing  
request. You have to understand this distinction to understand Tapestry  
*and* what is happening to your code. In your case, I think it will be  
easier to create a BeanModel yourself.


I would try this:

@Inject
private BeanModelSource beanModelSource;

@Inject
private Messages messages;

@Property(flash)
private boolean disableSorting; // this property is set by your form or by  
any other logic


/* This method will be called during the Grid rendering, and that's  
exactly what we need here */

public BeanModel getBeanModel() {
	BeanModel model = beanModelSource.createDisplayModel(YourClass.class,  
messages);

if (disableSorting) {
PropertyModel nameColumn = 
gridResources.getDataModel().getById(name);
nameColumn.sortable(false);
}
return model;
}

table t:type=Grid t:model=beanModel ...

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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



Re: T5: disabling column sorting programmatically in Grid

2009-01-19 Thread immutability

Thanks again, now you got me started (finally)! It really seems to be a
better idea to just create the bean model for each request in this case. A
note for others who may be trying the code above - don't ever try to call
grid.getBeanModel within a getter for the model for the same grid - that
will cause an endless recursion and a stack overflow. :-)

Thanks again Thiago!
-- 
View this message in context: 
http://www.nabble.com/T5%3A-disabling-column-sorting-programmatically-in-Grid-tp21546541p21549517.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5: disabling column sorting programmatically in Grid

2009-01-19 Thread Thiago H. de Paula Figueiredo

The code above should be, as found by Immutability:

public BeanModel getBeanModel() {
BeanModel model = beanModelSource.createDisplayModel(YourClass.class,
messages);
if (disableSorting) {
PropertyModel nameColumn =  model.getById(name);
nameColumn.sortable(false);
}
return model;
}

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

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