Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #4981
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Stanimir Stamenkov <s7an10@netscape.net> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JSF feeds a Set<String> into a Set<Foo> |
| Date | Sat, 04 Jun 2011 17:42:15 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 50 |
| Message-ID | <isdg7s$npv$1@dont-email.me> (permalink) |
| References | <4de7e53a$0$21180$426a34cc@news.free.fr> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Sat, 4 Jun 2011 14:42:04 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="VdcnnljfizG2LUdZ5iOA6g"; logging-data="24383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/p9oGiWq1jbJf3rcxSQHpw" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20110520 SeaMonkey/2.1 |
| In-Reply-To | <4de7e53a$0$21180$426a34cc@news.free.fr> |
| X-Face | )>>ChyF_H<b)u~Zjgo/=wa~;=qyW%.F\L.d^fKL[;y\=tY\]M}2t(a^;PKS}9g|k@\vkA<P Q|4?kcJ52334f:CaCrQZ=]D~txPPh6[y{xHkZ+4/KPKZ~|*K#?EqeP0W]iU*Ldy-hyjh0)N4c.I<m) K}GsUUe0)~24Xp`Jt |
| Cancel-Lock | sha1:PGUifJOdzkj89XYclqyAyUoerDY= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4981 |
Show key headers only | View raw
Thu, 02 Jun 2011 21:32:09 +0200, /Elegie/:
> I am currently learning JSF2.0, and have just encountered a behavior
> I do not understand. Basically, I have a test case (see below) where
> I have a typed set (Set<Foo>) whose content, automatically populated
> by JSF, is made of strings (Set<String>). This should not even
> compile, yet this runs. What am I missing?
> (...)
You're missing the generics type erasure [1]. JSF doesn't have the
generics type information at run time. A related (but not the same)
issue [2] has been brought to the JSF Dev mailing list.
To resolve the issue you could attach converter to your input
component explicitly, e.g.:
<h:selectManyCheckbox
value="#{testCase.foos}"
converter="#{...}">
...
</h:selectManyCheckbox>
where you bind the converter instance directly, or:
<h:selectManyCheckbox
value="#{testCase.foos}">
<f:converter converterId="..." />
...
</h:selectManyCheckbox>
where you provide a registered converter ID. With JSF 1.2 one
register a custom converter by adding such an element in the
"faces-config.xml" file:
<converter>
<converter-id>test.FooConverter</converter-id>
<converter-class>test.faces.FooConverter</converter-class>
</converter>
JSF 2.0 may provide more convenient annotation placed on the
converter class directly (don't know, I have really no JSF 2
experience, yet).
[1]
http://download.oracle.com/javase/tutorial/java/generics/erasure.html
[2] "JSF & Support for Generic Types... Again..."
<http://java.net/projects/javaserverfaces/lists/dev/archive/2011-04/message/15>
--
Stanimir
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
JSF feeds a Set<String> into a Set<Foo> Elegie <elegie@invalid> - 2011-06-02 21:32 +0200
Re: JSF feeds a Set<String> into a Set<Foo> Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-04 17:42 +0300
Re: JSF feeds a Set<String> into a Set<Foo> Elegie <elegie@invalid> - 2011-06-04 18:49 +0200
csiph-web