You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Clément Maignien <c....@edic-syliance.com> on 2005/09/02 10:01:05 UTC

Which class to prepare database data to be displayed in JSF components

Hi everyone,
Here is the situation : 
I have to display in JSF components data (what ever it is) that come from a database (what ever it is).
 
Which class is supposed to format data so it can be displayed in JSF component ? For example in some SelectItem objects.
 
According to me, the DAO souldn't do that as it is done in the MyFaces Wiki page http://wiki.apache.org/myfaces/HibernateAndMyFaces in the last example, because it links data model to UI.
The services (Spring for example) classes shouldn't do that either as the service could be called by WebService or RMI for a Swing application for example.
It could be done ManagedBean class (Form Bean), but this time it links UI data to model Data.
So in my opinion this should be done BeanAction class, am I wrong ?
 
Thx for your support.
Clément.
 


Re: Which class to prepare database data to be displayed in JSF components

Posted by Martin Marinschek <ma...@gmail.com>.
Hold on - classic MVC allows UI Data to access the model...

why should that be disallowed?

regards,

Martin

On 9/2/05, Clément Maignien <c....@edic-syliance.com> wrote:
>  
> Hi everyone, 
> Here is the situation : 
> I have to display in JSF components data (what ever it is) that come from a
> database (what ever it is). 
>   
> Which class is supposed to format data so it can be displayed in JSF
> component ? For example in some SelectItem objects. 
>   
> According to me, the DAO souldn't do that as it is done in the MyFaces Wiki
> page http://wiki.apache.org/myfaces/HibernateAndMyFaces in
> the last example, because it links data model to UI. 
> The services (Spring for example) classes shouldn't do that either as the
> service could be called by WebService or RMI for a Swing application for
> example. 
> It could be done ManagedBean class (Form Bean), but this time it links UI
> data to model Data. 
> So in my opinion this should be done BeanAction class, am I wrong ? 
>   
> Thx for your support. 
> Clément. 
>   
>  
>  
>  
> 
>  


-- 

http://www.irian.at
Your JSF powerhouse - 
JSF Trainings in English and German

Re: Which class to prepare database data to be displayed in JSF components

Posted by Mike Kienenberger <mk...@gmail.com>.
I have *SelectionItemProvider backing bean classes for each set of
database objects which convert a list of database objects into arrays
of SelectItems.   Two methods for each, one of which adds a "<no
selection>" null-capable line if the attribute is not mandatory.   I
automatically generate these backing beans and converters from my
database model.

On 9/3/05, Werner Punz <we...@gmx.at> wrote:
> Mhh interesting...
> 
> I am missing something here (I must admit I have not written too many
> custom converters yet)
> 
> how do you handle the problem that a selectone menu wants a Collection
> of SelectItem
> for the menu entries...?
> 
> Werner
> 
> 
> Werner Punz wrote:
> > Mike Kienenberger wrote:
> >
> >> I find custom converters registered by class to be ideal for this
> >> purpose.
> >> It converts data between business object format and String (required
> >> on the presentation side).
> >>
> > Not really totally feasable if you use a drop down box or another
> > control which needs a key,value pair ;-)
> >
> >
> 
>

Re: Which class to prepare database data to be displayed in JSF components

Posted by Werner Punz <we...@gmx.at>.
Mhh interesting...

I am missing something here (I must admit I have not written too many 
custom converters yet)

how do you handle the problem that a selectone menu wants a Collection 
of SelectItem
for the menu entries...?

Werner


Werner Punz wrote:
> Mike Kienenberger wrote:
> 
>> I find custom converters registered by class to be ideal for this 
>> purpose.
>> It converts data between business object format and String (required
>> on the presentation side).
>>
> Not really totally feasable if you use a drop down box or another 
> control which needs a key,value pair ;-)
> 
> 


Re: Which class to prepare database data to be displayed in JSF components

Posted by Mike Kienenberger <mk...@gmail.com>.
Really? because that's precisely how I'm using it -- populating
pulldowns.   My object is my value and my key/label is whatever
object.getName() returns.

On 9/2/05, Werner Punz <we...@gmx.at> wrote:
> Mike Kienenberger wrote:
> > I find custom converters registered by class to be ideal for this purpose.
> > It converts data between business object format and String (required
> > on the presentation side).
> >
> Not really totally feasable if you use a drop down box or another
> control which needs a key,value pair ;-)
> 
>

Re: Which class to prepare database data to be displayed in JSF components

Posted by Werner Punz <we...@gmx.at>.
Mike Kienenberger wrote:
> I find custom converters registered by class to be ideal for this purpose.
> It converts data between business object format and String (required
> on the presentation side).
> 
Not really totally feasable if you use a drop down box or another 
control which needs a key,value pair ;-)


Re: Which class to prepare database data to be displayed in JSF components

Posted by Mike Kienenberger <mk...@gmail.com>.
I find custom converters registered by class to be ideal for this purpose.
It converts data between business object format and String (required
on the presentation side).

On 9/2/05, Clément Maignien <c....@edic-syliance.com> wrote:
>  
> Hi everyone, 
> Here is the situation : 
> I have to display in JSF components data (what ever it is) that come from a
> database (what ever it is). 
>   
> Which class is supposed to format data so it can be displayed in JSF
> component ? For example in some SelectItem objects. 
>   
> According to me, the DAO souldn't do that as it is done in the MyFaces Wiki
> page http://wiki.apache.org/myfaces/HibernateAndMyFaces in
> the last example, because it links data model to UI. 
> The services (Spring for example) classes shouldn't do that either as the
> service could be called by WebService or RMI for a Swing application for
> example. 
> It could be done ManagedBean class (Form Bean), but this time it links UI
> data to model Data. 
> So in my opinion this should be done BeanAction class, am I wrong ? 
>   
> Thx for your support. 
> Clément. 
>   
>  
>  
>  
> 
>