myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Quilleash " <mike.quille...@subexazure.com>
Subject RE: Nulls and hibernate objects
Date Tue, 17 Apr 2007 13:06:11 GMT
Thanks for the reply.
 
I'm not sure converters work here because they are only used when
actually converting an object to a string for HTML output or converting
a form submission back to an object.
 
The part I think I am falling down on is where it tries to equate the
current server value of the menu (null) to one of the select item values
(one of which is null).  However it seems that nulls are treated
specially or ignored somehow, the result being the "selected" attribute
never gets put on my "Please Select" item during the rendering of the
HTML <option>.  I have not got as far as form submission yet, this is
just a rendering problem.
 
Mike.

________________________________

From: Strittmatter, Stephan [mailto:Stephan.Strittmatter@sybit.de] 
Sent: 17 April 2007 13:04
To: MyFaces Discussion
Subject: RE: Nulls and hibernate objects


Hi Mike,
 
probably this will focus to the right direction:
http://jroller.com/page/stritti?entry=jsf_stringconverter_for_null_value
s
 
Regards,
 
Stephan

________________________________

From: Mike Quilleash [mailto:mike.quilleash@subexazure.com] 
Sent: Tuesday, April 17, 2007 2:00 PM
To: MyFaces Discussion
Subject: Nulls and hibernate objects


Hi all,
 
I have a selectOneMenu where the value is set to a many-to-one property
in a hibernate entity
 
<h:selectOneMenu value="#{hibObj.otherObj}" required="true">
 
and
 
class HibObj
{
   public OtherObj getOtherObj() { ... }
}
 
Initially otherObj is set to null.  I generate a select item list for
possible values of otherObj preceeded by a "Please Select" item that
should be the initial selection.  The SelectItem for the no selection
has it's value set to null, label of "Please Select", and disabled set
to true.
 
However when the menu renders it displays the first item after the
"Please Select".  Debugging in the code shows that the null, both in the
SelectItem and returned when value is evaluated, are special cases and
get converted to empty strings or cause the matching to be skipped
altogether.  (I then think the browser defaults to selecting the first
non-disabled item as the html selected is not against any of the
options).
 
Does anyone have any ideas how to get this to work?  I'm happy enough to
put a null placeholder in the Please Select Item but I don't want
to/can't do that in the hibernate model.
 
Any help or suggestions appreciated.
 
Cheers.
 
Mike.
 
 This e-mail is bound by the terms and conditions described at
http://www.subexazure.com/mail-disclaimer.html


 This e-mail is bound by the terms and conditions described at http://www.subexazure.com/mail-disclaimer.html

Mime
View raw message