Thanks Volker,

Do you think that my solution: adapting the Set to a List in the backing
bean by simply doing:

      *public* List<PhoneNumber> getPhones() {

            *return* *new* ArrayList<PhoneNumber>(
getEditingPerson().getPhones() );

      }

will have side effects when deleting a row or sorting and then editing?

Announcements told that we won't need DTOs when using EJB3 thanks to JPA and
JSF, in the other side: hibernate considers a java.util.List as a bag, which
is a very special case that surely doesn't apply in 90% (and has a lot of
disadvantages). To have a good behavior we need to use java.util.Set, but
here we find ourselves catched by the view side because we need to index our
tables in order to be able to sort/edit them :-).

 I know this question is more about JSF in general than myfaes or Tobago,
but do you have best practice hints to share with us?

Regards,
Zied

2007/9/11, Volker Weber <[EMAIL PROTECTED]>:
>
> Hi Zied,
>
> tc:sheet is a extension of h:datatable and supports the same values.
>
> AFAIK Set is not supported as Collection because there is no defined
> order to work on.
> But Set is supported as Object:
>
> http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/api/javax/faces/model/ScalarDataModel.html
>
>
> Regards,
>    Volker
>
> 2007/9/11, Zied Hamdi <[EMAIL PROTECTED]>:
> > Hi,
> >
> > Sorry I was absent for a moment, today I'm back at work.
> >
> > So the problem is that <tc:sheet doesn't support java.util.Setcollections.
> > Why don't you just throw an IllegalArgumentException rather than passing
> the
> > Set to the page scope under the varibale specified in var ?
> >
> > This is very confusing, it seems there's a problem with the page tags,
> and
> > since there's no way to compile JSF syntax, it'd be better to give a
> runtime
> > compilation...
> >
> > Is there a reason why Sets are not supported? is it because of the fact
> > there's no id to maintain?
> >
> > Regards,
> > Zied
> >
> > 2007/9/8, Zied Hamdi <[EMAIL PROTECTED]>:
> > >
> > > Hi again,
> > >
> > > I woke up remembering this problem happens when I don't surround my
> > element by tc:column tags. So I decided to take a look so I don't feel
> > stupid, and I found extra tc:column tags. After correcting the problem:
> > >
> > >
> > >             < tc:sheet id= "adressesSheet" var ="adress" showHeader=
> > "false"
> > >
> > >                   value ="#{personCtrl.adresses}" columns = "1*"
> > >
> > >                   binding ="#{personCtrl.adressTable}" >
> > >
> > >                   < tc:column>
> > >
> > >                         < tc:panel>
> > >
> > >                              < f:facet name ="layout" >
> > >
> > >                                    < tc:gridLayout
> > columns ="10px;1*;10px" />
> > >
> > >                              </ f:facet>
> > >
> > >
> > >
> > >                              < ui:include src ="/person/adress.xhtml"
> />
> > >
> > >
> > >
> > >                         </ tc:panel >
> > >
> > >                   </tc:column >
> > >
> > >             </tc:sheet >
> > >
> > >
> > > Nothing has changed : I still have the problem with ui:include, and it
> > still disappears when I use jsp:include instead...
> > >
> > > Anyway, the 'adress' variable should never be equal to
> > #{personCtrl.adresses}, which is my case...
> > >
> > > Regards,
> > > Zied
> > >
> > > 2007/9/7, Zied Hamdi <[EMAIL PROTECTED]>:
> > >
> > > >
> > > > Hi,
> > > >
> > > > I hezitated for a while before sending this post, it seems
> impossible to
> > me.
> > > >
> > > > Again under facelets (maybe it's due to the nightbuild of 05.09 but
> I
> > don't think the junit didn't try this) I have a problem I didn't have
> with
> > "plain" jsp:
> > > >
> > > > /person/adressListBox.xhtml
> > > > ...
> > > >             < tc:sheet id= "adressesSheet" var ="adress1"
> showHeader=
> > "false"
> > > >
> > > >                   value ="#{personCtrl.adresses}" columns = "1*"
> > > >
> > > >                   binding ="#{personCtrl.adressTable}" >
> > > >
> > > >                   < tc:column>
> > > >
> > > >                         < tc:panel>
> > > >
> > > >                              < f:facet name ="layout" >
> > > >
> > > >                                    < tc:gridLayout
> > columns ="10px;1*;10px" />
> > > >
> > > >                              </ f:facet>
> > > >
> > > >
> > > >
> > > >                              < tc:column />
> > > >
> > > >
> > > >
> > > >                              < f:subview id = "personAdressList" >
> > > >
> > > >                                    < ui:include src =
> > "/person/adress.xhtml" >
> > > >
> > > >                                          < c:set value
> > = "#{adress1[0]}" var= "adress"></ c:set >
> > > >
> > > >                                    </ ui:include>
> > > >
> > > >                              </ f:subview>
> > > >
> > > >
> > > >
> > > >                              < tc:column />
> > > >
> > > >
> > > >
> > > >                         </ tc:panel >
> > > >
> > > >                   </tc:column >
> > > >
> > > >             </tc:sheet >
> > > > ...
> > > >
> > > > The error I receive here is :
> > > >
> > > >
> > > > Caused by: javax.el.PropertyNotFoundException :
> > /person/adress.xhtml @18,52 value="#{adress.specifier }":
> > /person/adressListBox.xhtml @64,50 value="#{adress1[0]}": Property '0'
> not
> > found on type org.hibernate.collection.PersistentSet
> > > >
> > > >       at
> > com.sun.facelets.el.TagValueExpression.getValue(
> > TagValueExpression.java:73 )
> > > >
> > > >       at
> > javax.faces.component.UIOutput.getValue(UIOutput.java :173
> > )
> > > >
> > > >       ... 99 more
> > > >
> > > >
> > > > So it's really true: adress1 contains the value of
> > #{personCtrl.adresses} instead of one of its elements: it should not be
> a
> > Set but an Adress instance. (the exception is intentional to put in
> evidence
> > the problem in one code snippet). Originally var ="adress1"  was var=
> > "adress" . And there were no < c:set.
> > > >
> > > >
> > > > The error in that case is equivalent when I attempt to use the
> variable
> > adress in the included page:
> > > >
> > > >
> > > > Caused by: javax.el.PropertyNotFoundException :
> > /person/adress.xhtml @18,52 value="#{adress.specifier }": Property
> > 'specifier' not found on type
> > org.hibernate.collection.PersistentSet
> > > >
> > > >       at
> > com.sun.facelets.el.TagValueExpression.getValue(
> > TagValueExpression.java:73 )
> > > >
> > > >       at
> > javax.faces.component.UIOutput.getValue(UIOutput.java :173
> > )
> > > >
> > > >       ... 99 more
> > > >
> > > >
> > > >
> > > > Here's the component tree (I didn't find the input el, I suppose
> it's in
> > the markup variable):
> > > >
> > > > <UIData columns="1*" directLinkCount="9" first="0"
> id="adressesSheet"
> > rendered="true" rowIndex="0" rows="100" selectable="multi"
> > showDirectLinks="none" showHeader="false" showPageRange="none"
> > showRowRange="none" sortActionListener=" transient="false" var="adress"
> > binding="#{ personCtrl.adressTable}"> <UIColumn id="j_id80"
> > markup="[Ljava.lang.String;@76cfab" rendered="true" sortable="false"
> > transient="false"> <UIPanel id="j_id81" markup="[Ljava.lang.String
> ;@3c1a28"
> > rendered="true" transient="false"> layout <UIGridLayout
> > columns="10px;1*;10px" id="j_id363" ignoreFree="false" rendered="true"
> > rows="1*" transient="false"/> <UIColumn id="j_id83"
> > markup="[Ljava.lang.String;@1d94799" rendered="true" sortable="false"
> > transient="false"/> <UINamingContainer id="personAdressList"
> rendered="true"
> > transient="false"/> <UIColumn id="j_id85"
> > markup="[Ljava.lang.String;@1ebcd54" rendered="true" sortable="false"
> > transient="false"/> </UIPanel> </UIColumn> <UIColumn id="j_id414"
> > markup="[Ljava.lang.String;@1f58247" rendered="true" sortable="false"
> > transient="false"> <UIPanel id="j_id415"
> > markup="[Ljava.lang.String;@13c2a46" rendered="true" transient="false">
> > layout <UIGridLayout columns="10px;1*;10px" id="j_id416"
> ignoreFree="false"
> > rendered="true" rows="1*" transient="false"/> <UIColumn id="j_id417"
> > markup="[Ljava.lang.String;@fb8c90" rendered="true" sortable="false"
> > transient="false"/> <UINamingContainer id="personAdressList"
> rendered="true"
> > transient="false"> <UIPanel id="j_id418" markup="[Ljava.lang.String
> ;@c94377"
> > rendered="true" transient="false"> layout <UIGridLayout
> columns="1*;1*;1*"
> > id="j_id419" ignoreFree="false" margin="3px" marginBottom="3px"
> > marginLeft="3px" marginRight="3px" marginTop="3px" rendered="true"
> rows="1*"
> > transient="false"/> <UICell id="j_id420" rendered="true"
> scrollbars="false"
> > spanX="1" spanY="1" transient="false"> <UILinkCommand
> > action="#{personCtrl.removeAdressCmd}"
> > actionExpression="#{personCtrl.removeAdressCmd}" defaultCommand="false"
> > disabled="false" id="j_id421" immediate="false" markup="[
> > Ljava.lang.String;@16c6310" rendered="true"
> > renderedPartially="[Ljava.lang.String;@dbd726" transient="false"
> > transition="true"/> </UICell> <UIPanel id="specifier"
> > markup="[Ljava.lang.String;@10a034e" rendered="true" transient="false">
> > layout <UIGridLayout columns="150px;*" id="j_id422" ignoreFree="false"
> > rendered="true" rows="1*" transient="false"/> <UILabel id="j_id423"
> > markup="[Ljava.lang.String;@5f1c5e" rendered="true" transient="false"
> > value="Complément d'adresse"/> <UIInput disabled="false" id="j_id424"
> > immediate="false" localValueSet="false" markup="[Ljava.lang.String
> ;@3fa023"
> > password="false" readonly="false" rendered="true" required="false"
> > transient="false" valid="true"/> </UIPanel>
> > > > ...
> > > >
> > > > By the way, it's painful to see what's inside varibales with JSF, do
> you
> > have a best practice approch? sth like in old jsps
> <%System.out.print();%>.
> > I've tried the <ui:debug hotkey="x"/> in my root page but it doesn't
> react
> > on any shortcut and doesn't throw js exceptions, so it's a subject
> apart.
> > > >
> > > > Regads,
> > > > Zied
> > >
> > >
> > >
> > > --
> > > Zied Hamdi
> > > zatreex.sourceforge.net
> >
> >
> >
> > --
> > Zied Hamdi
> > zatreex.sourceforge.net
>



-- 
Zied Hamdi
zatreex.sourceforge.net

Reply via email to