Re: [Solved] Dynamic panelGrid within dataTable

2007-02-14 Thread fastbob

Hmmm. I think you're spot on with your comment about putting the
functionality into the row object itself. That's what I was trying to do
when I erroneously attempted to bind to the dataTable var. Each row object
would be responsible for generating the appropriate components. But it
sounds like the row object can only be accessed through its parent
dataTable, which I suppose makes some sense.

It finally dawned on me that I need to deal with the dynamic generation at
two points - the rendering of the HTML and when the values are posted back
to the server. The latter I think I can deal with, but the former has me
scratching my head. It seems like I'll need to generate the dynamic
components at the same time I initialize the dataTable list (perhaps in a
map), and then refer to those components in the column definitions.

fastbob


Simon Kitching-3 wrote:
 
 fastbob wrote:
 Is there a preferred JSF pattern for communicating user selection of a
 dataTable row back to the server? I've found a number of somewhat crufty
 methods (such as on BalusC), but unless I've missed something, none seem
 particularly attractive other than f:attribute. But perhaps that's just
 the
 nature of the beast. Any suggestions?
 
 Generally when processing a row the nicest solution is to build any 
 functionality needed onto the row object itself. Suppose the model is 
 normally a list of Person objects but some logic is needed to manipulate 
 a particular person then the model can be changed to a list of 
 PersonHandler objects each of which has a person property. In this 
 case, there is no communication of the user selection required; the 
 method is invoked *on* the selected object.
 
 An alternative is to set the binding attribute on the t:dataTable 
 object, then the callback method that is invoked can call the getRowData 
   method on the datatable to find the row currently being operated on. 
 It's not so elegant but does work fine.
 
 I think that if you write the commandLink to invoke an ActionListener 
 rather than an action method then the event might also have the 
 appropriate row info but am not sure of the details here.
 
 Regards,
 
 
 Simon
 
 

-- 
View this message in context: 
http://www.nabble.com/Dynamic-panelGrid-within-dataTable-tf3218128.html#a8970885
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Re: [Solved] Dynamic panelGrid within dataTable

2007-02-14 Thread Simon Kitching

Hi,

When you say dynamic generation, do you mean CGLIB or similar? This 
approach *does* work (and is used in the project I'm currently working 
on) but I didn't mean to imply that with my comment.


To expand on my example below, if a table of Person objects has a column 
containing:

t:dataTable var=currPerson 
  t:outputText value=#{currPerson.name}/

then this can be converted to be a table of PersonHandler objects, and 
the jsp can be updated to:


t:dataTable var=currPersonHandler 
  t:outputText value=#{currPersonHandler.person.name}/
  ...
  h:commandLink action=#{currPersonHandler.doSomething}/

All that is needed is for the PersonHandler objects to have a 
getPerson() method. No dynamic generation required. And the 
doSomething method obviously knows which Person to modify - the Person 
it wraps.


Regards,

Simon


fastbob wrote:

Hmmm. I think you're spot on with your comment about putting the
functionality into the row object itself. That's what I was trying to do
when I erroneously attempted to bind to the dataTable var. Each row object
would be responsible for generating the appropriate components. But it
sounds like the row object can only be accessed through its parent
dataTable, which I suppose makes some sense.

It finally dawned on me that I need to deal with the dynamic generation at
two points - the rendering of the HTML and when the values are posted back
to the server. The latter I think I can deal with, but the former has me
scratching my head. It seems like I'll need to generate the dynamic
components at the same time I initialize the dataTable list (perhaps in a
map), and then refer to those components in the column definitions.

fastbob


Simon Kitching-3 wrote:

fastbob wrote:

Is there a preferred JSF pattern for communicating user selection of a
dataTable row back to the server? I've found a number of somewhat crufty
methods (such as on BalusC), but unless I've missed something, none seem
particularly attractive other than f:attribute. But perhaps that's just
the
nature of the beast. Any suggestions?
Generally when processing a row the nicest solution is to build any 
functionality needed onto the row object itself. Suppose the model is 
normally a list of Person objects but some logic is needed to manipulate 
a particular person then the model can be changed to a list of 
PersonHandler objects each of which has a person property. In this 
case, there is no communication of the user selection required; the 
method is invoked *on* the selected object.


An alternative is to set the binding attribute on the t:dataTable 
object, then the callback method that is invoked can call the getRowData 
  method on the datatable to find the row currently being operated on. 
It's not so elegant but does work fine.


I think that if you write the commandLink to invoke an ActionListener 
rather than an action method then the event might also have the 
appropriate row info but am not sure of the details here.


Regards,


Simon








Re: [Solved] Dynamic panelGrid within dataTable

2007-02-14 Thread fastbob

Simon,
Sorry for creating confusion. When I'm saying dynamic generation,
specifically I'm generating a panelGrid. 

To expand on your latest example, imagine that for different types of people
(teacher, CEO, banker) you have to display different details for searching,
e.g., grade level drop-down for teachers, a check box if the CEO manages a
multi-national company, etc. You also don't know in advance the exact number
and format of the parameters, since these are retrieved from an external XML
description. And to be complete, these generated fields are displayed via
detailToggler when the user clicks on a person.

So your example becomes something like:

t:dataTable var=currPersonHandler 
   t:panelGrid binding=#{something_other_than_currPersonHandler}/
   ...

It would be great if panelGrid accepted a value attribute, but apparently it
doesn't.

I'm open to suggestions, up to suggesting I'm crazy to even consider this
(that's already an established fact).

fastbob

Simon Kitching-3 wrote:
 
 Hi,
 
 When you say dynamic generation, do you mean CGLIB or similar? This 
 approach *does* work (and is used in the project I'm currently working 
 on) but I didn't mean to imply that with my comment.
 
 To expand on my example below, if a table of Person objects has a column 
 containing:
 t:dataTable var=currPerson 
t:outputText value=#{currPerson.name}/
 
 then this can be converted to be a table of PersonHandler objects, and 
 the jsp can be updated to:
 
 t:dataTable var=currPersonHandler 
t:outputText value=#{currPersonHandler.person.name}/
...
h:commandLink action=#{currPersonHandler.doSomething}/
 
 All that is needed is for the PersonHandler objects to have a 
 getPerson() method. No dynamic generation required. And the 
 doSomething method obviously knows which Person to modify - the Person 
 it wraps.
 
 Regards,
 
 Simon
 
 
 fastbob wrote:
 Hmmm. I think you're spot on with your comment about putting the
 functionality into the row object itself. That's what I was trying to do
 when I erroneously attempted to bind to the dataTable var. Each row
 object
 would be responsible for generating the appropriate components. But it
 sounds like the row object can only be accessed through its parent
 dataTable, which I suppose makes some sense.
 
 It finally dawned on me that I need to deal with the dynamic generation
 at
 two points - the rendering of the HTML and when the values are posted
 back
 to the server. The latter I think I can deal with, but the former has me
 scratching my head. It seems like I'll need to generate the dynamic
 components at the same time I initialize the dataTable list (perhaps in a
 map), and then refer to those components in the column definitions.
 
 fastbob
 
 
 Simon Kitching-3 wrote:
 fastbob wrote:
 Is there a preferred JSF pattern for communicating user selection of a
 dataTable row back to the server? I've found a number of somewhat
 crufty
 methods (such as on BalusC), but unless I've missed something, none
 seem
 particularly attractive other than f:attribute. But perhaps that's just
 the
 nature of the beast. Any suggestions?
 Generally when processing a row the nicest solution is to build any 
 functionality needed onto the row object itself. Suppose the model is 
 normally a list of Person objects but some logic is needed to manipulate 
 a particular person then the model can be changed to a list of 
 PersonHandler objects each of which has a person property. In this 
 case, there is no communication of the user selection required; the 
 method is invoked *on* the selected object.

 An alternative is to set the binding attribute on the t:dataTable 
 object, then the callback method that is invoked can call the getRowData 
   method on the datatable to find the row currently being operated on. 
 It's not so elegant but does work fine.

 I think that if you write the commandLink to invoke an ActionListener 
 rather than an action method then the event might also have the 
 appropriate row info but am not sure of the details here.

 Regards,


 Simon


 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Dynamic-panelGrid-within-dataTable-tf3218128.html#a8975342
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Re: [Solved] Dynamic panelGrid within dataTable

2007-02-12 Thread fastbob

Simon,
Thanks for your quick response. Obviously I don't understand the rendering
model sufficiently. This helps.

Yes, what I'm attempting does imply a tight coupling between the
presentation and backing bean, but in this case the backing bean is actually
used just for presentation and delegates to a more general backing bean. So
I can live with this instance.

Is there a preferred JSF pattern for communicating user selection of a
dataTable row back to the server? I've found a number of somewhat crufty
methods (such as on BalusC), but unless I've missed something, none seem
particularly attractive other than f:attribute. But perhaps that's just the
nature of the beast. Any suggestions?

Thanks.

fastbob
-- 
View this message in context: 
http://www.nabble.com/Dynamic-panelGrid-within-dataTable-tf3218128.html#a8937628
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Re: [Solved] Dynamic panelGrid within dataTable

2007-02-12 Thread Simon Kitching

fastbob wrote:

Simon,
Thanks for your quick response. Obviously I don't understand the rendering
model sufficiently. This helps.

Yes, what I'm attempting does imply a tight coupling between the
presentation and backing bean, but in this case the backing bean is actually
used just for presentation and delegates to a more general backing bean. So
I can live with this instance.

Is there a preferred JSF pattern for communicating user selection of a
dataTable row back to the server? I've found a number of somewhat crufty
methods (such as on BalusC), but unless I've missed something, none seem
particularly attractive other than f:attribute. But perhaps that's just the
nature of the beast. Any suggestions?


Generally when processing a row the nicest solution is to build any 
functionality needed onto the row object itself. Suppose the model is 
normally a list of Person objects but some logic is needed to manipulate 
a particular person then the model can be changed to a list of 
PersonHandler objects each of which has a person property. In this 
case, there is no communication of the user selection required; the 
method is invoked *on* the selected object.


An alternative is to set the binding attribute on the t:dataTable 
object, then the callback method that is invoked can call the getRowData 
 method on the datatable to find the row currently being operated on. 
It's not so elegant but does work fine.


I think that if you write the commandLink to invoke an ActionListener 
rather than an action method then the event might also have the 
appropriate row info but am not sure of the details here.


Regards,


Simon