You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michał Małecki <mi...@poczta.onet.pl> on 2004/12/01 09:06:08 UTC

template panel

Hello,
while learning jsf Icame into the following problem - I had dataTable to
iterate over a list of books, and every book I wanted to display in nice
table. The simplest solution was of course put book into panelGrid.
Unfortunatelly it is very inflexible - what if you want different styles for
different cells etc And I created panel that put its children into template
(html with /**/ for every child) (it was my second custom renderer and took
about 1 hour for the very rough version). I wonder - how come jsf don't have
such useful tag, or at least - why myfaces doesn't have it as additional
tag.
Should such problem be solved in other way? Could someone please clarify
this?
thanks

Michał Małecki



Re: template panel

Posted by Michał Małecki <mi...@poczta.onet.pl>.
Hello Manfred,
thank for reply. Correct me if I'm wrong - in your solution there is a lot
of jsp attributes for styles and it's hard to change structure of tables (in
panel grid you can archive it only by adding next panel grid). On the other
hand you can programmatically change styles.
In my solution you have only <my:panel template="book.tmpl> with components
inside; and templates as pure html, possible to edit in some html editor.
I wonder what other people use, and if using other viewHandler in jsf (for
xul, or similar to tapestry) would solve all that problems
Michał

Michał,
I use the following "trick".
Within my cells I use dynamic EL expression styles for my outputText or
panelGroup tags.
Example:
<h:outputText value="#{rowBean.myValue}"
styleClass="#{rowBean.myValueStyle}"/>

Some people might insist that this breaks the separation of model and
view. Well, there is some truth in this statement.

You can decrease (or even break IMHO) dependency between model and view
by separating the style into a fixed prefix and a dynamic suffix.
Example:
<h:outputText value="#{rowBean.myValue}"
styleClass="myValueStylePrefix_#{rowBean.myValueStyleSemanticSuffix}"/>

This way you can make your model beans behave more abstract and more
independent from the concrete view. They return only semantic
information that applies to the associated value. e.g. The suffix bean
property returns values like "veryImportant", "important" and
"unimportant". These values have only semantic meaning and are then
"interpreted" by the view tier by combining them with a prefix:
"personNameStyle_veryImportant" --> e.g. bold
"personNameStyle_important" --> e.g. normal text
"personNameStyle_unimportant" --> e.g. white text, white background ;-)

HTH,
Manfred


Michał Małecki wrote:
> Hello,
> while learning jsf Icame into the following problem - I had dataTable to
> iterate over a list of books, and every book I wanted to display in nice
> table. The simplest solution was of course put book into panelGrid.
> Unfortunatelly it is very inflexible - what if you want different styles
for
> different cells etc And I created panel that put its children into
template
> (html with /**/ for every child) (it was my second custom renderer and
took
> about 1 hour for the very rough version). I wonder - how come jsf don't
have
> such useful tag, or at least - why myfaces doesn't have it as additional
> tag.
> Should such problem be solved in other way? Could someone please clarify
> this?
> thanks
>
> Michał Małecki





Re: template panel

Posted by Manfred Geiler <ma...@apache.org>.
Michał,
I use the following "trick".
Within my cells I use dynamic EL expression styles for my outputText or 
panelGroup tags.
Example:
<h:outputText value="#{rowBean.myValue}" 
styleClass="#{rowBean.myValueStyle}"/>

Some people might insist that this breaks the separation of model and 
view. Well, there is some truth in this statement.

You can decrease (or even break IMHO) dependency between model and view 
by separating the style into a fixed prefix and a dynamic suffix.
Example:
<h:outputText value="#{rowBean.myValue}" 
styleClass="myValueStylePrefix_#{rowBean.myValueStyleSemanticSuffix}"/>

This way you can make your model beans behave more abstract and more 
independent from the concrete view. They return only semantic 
information that applies to the associated value. e.g. The suffix bean 
property returns values like "veryImportant", "important" and 
"unimportant". These values have only semantic meaning and are then 
"interpreted" by the view tier by combining them with a prefix:
"personNameStyle_veryImportant" --> e.g. bold
"personNameStyle_important" --> e.g. normal text
"personNameStyle_unimportant" --> e.g. white text, white background ;-)

HTH,
Manfred


Michał Małecki wrote:
> Hello,
> while learning jsf Icame into the following problem - I had dataTable to
> iterate over a list of books, and every book I wanted to display in nice
> table. The simplest solution was of course put book into panelGrid.
> Unfortunatelly it is very inflexible - what if you want different styles for
> different cells etc And I created panel that put its children into template
> (html with /**/ for every child) (it was my second custom renderer and took
> about 1 hour for the very rough version). I wonder - how come jsf don't have
> such useful tag, or at least - why myfaces doesn't have it as additional
> tag.
> Should such problem be solved in other way? Could someone please clarify
> this?
> thanks
> 
> Michał Małecki