"...especially if I can not think of a better wrong answer..."
maybe we should stick with the groovy thing :)
Actually my a) was not very good and should be more like:
"By calling the registerManagedBean method on the Faces-Application
instance."
(as the method signature i came up with, is missing the scope
anyway ;) )
Imre
On 18.12.2009, at 10:08, Martin Marinschek wrote:
Ah well, so this is what the community decides as a question:
How can you register a managed bean with JSF2?
a) By calling FacesContext.getApplication().registerManagedBean(String
name, Class<?> beanClass)
b) Using XML-code in the faces configuration file
c) Using annotations in the Java-Code of the managed-bean
(@ManagedBean or @Named)
d) Using other JSF2 compliant bean-containers like a CDI
implementation or Spring
I would be curious as to how many people find the correct answer ;)
regards,
Martin
On 12/18/09, Imre Osswald <ioss(a)mx.jevelopers.com> wrote:
> Hi Martin,
>
> it is terribly complicated and wrong to do it (I totally agree),
> but still possible. (As I said, I would never want to see anything
> like that)
> As such rendering a) to maybe not the best "wrong" answer.
>
> The problem with d) being true, is that there are plenty of horrible
> ways I could come up to register managed beans ;)
>
> Still there should be a question about managed beans, and b,c and d,
> should be in the answers.
> Maybe we can either tweak the question, or change a) a bit, but I am
> also O.K. with having the question as is.
> I don't want to be a "Haarspalter" (quibbler?), especially if I can
> not think of a better wrong answer :D
>
> Maybe:
> a) by putting the bean into the session-map?
>
> which would make the bean usable in EL, as if it were a managed-bean.
> But not registering it, nor does this make the bean managed.
>
> or:
> a) by calling
> FacesContext.getApplication().registerManagedBean(String
> name, Class<?> beanClass)
> ... no comment :)
>
> regards
> Imre
>
>
>
> On 18.12.2009, at 02:25, Martin Marinschek wrote:
>
>> Hi Imre,
>>
>> I don't know of a d) which is used like this (with some DI-
>> containers,
>> you can of course do it, although nobody I have seen does it). In
>> any
>> case, it really sounds terribly complicated and wrong to do it, and
>> not at all like a correct answer, while the other 3 all sound
>> right to
>> me.
>>
>> But - maybe it's just me, so help me out: please give me a better
>> suggestion for a) if you think it is not yet far enough from the
>> truth....
>>
>> regards,
>>
>> Martin
>>
>> On 12/18/09, Imre Osswald <ioss(a)mx.jevelopers.com> wrote:
>>> Hi Martin,
>>>
>>> how "hard you have to push" depends on what "register"
and "Managed
>>> Bean" really means.
>>> But let's say we have a d) which allows me to register Managed
>>> Beans
>>> dynamically, then you could have groovy code in your view
>>> definition,
>>> that gets executed and registers the MB.
>>> While I am pretty sure, this is something I don't want to see in
>>> any
>>> view definition I have to work with, it would still be possible.
>>> (About using groovy in the view-definition see:
>>>
http://blog.jevelopers.com/archives/4-Project-Frisco-started.html)
>>>
>>> regards,
>>> Imre
>>>
>>> On 18.12.2009, at 00:30, Martin Marinschek wrote:
>>>
>>>> Hi Imre,
>>>>
>>>> d) is certainly valid with more than one bean container right now.
>>>> In
>>>> which context is a) valid? Never heard of anything like this.
>>>>
>>>> I don't think potential exam-takers will read this list, if they
>>>> do, I
>>>> think it's ok if they pass the exam ;)
>>>>
>>>> regards,
>>>>
>>>> Martin
>>>>
>>>> On 12/17/09, Imre Osswald <ioss(a)mx.jevelopers.com> wrote:
>>>>> If d) is valid and you push hard enough you can make a) valid
>>>>> too.
>>>>>
>>>>> But my actual question is, if we publish the questions and
>>>>> answers
>>>>> here on an open list, will they still be usable in an exam? :)
>>>>>
>>>>> Imre
>>>>>
>>>>> On 17.12.2009, at 16:37, Martin Marinschek wrote:
>>>>>
>>>>>> I would have said that b, c and d are all three valid answers.
>>>>>> Can't
>>>>>> we have multiple valid answers?
>>>>>>
>>>>>> regards,
>>>>>>
>>>>>> Martin
>>>>>>
>>>>>> On 12/17/09, Dan Allen <dan.j.allen(a)gmail.com> wrote:
>>>>>>> On Thu, Dec 17, 2009 at 9:57 AM, David Geary
>>>>>>> <clarity.training(a)gmail.com>wrote:
>>>>>>>
>>>>>>>> 2009/12/17 Martin Marinschek
<mmarinschek(a)apache.org>
>>>>>>>>
>>>>>>>>> I won't chime in for the distractors, but here my
question:
>>>>>>>>>
>>>>>>>>> How can you register a managed bean with JSF2?
>>>>>>>>>
>>>>>>>>> a) Using groovy in the view definition
>>>>>>>>> b) Using XML-code in the faces configuration file
>>>>>>>>> c) Using annotations in the Java-Code of the
managed-bean
>>>>>>>>> d) Using other JSF2 compliant bean-containers
>>>>>>>>>
>>>>>>>>
>>>>>>> c) ... (@ManagedBean or @Named)
>>>>>>>
>>>>>>> -Dan
>>>>>>>
>>>>>>> --
>>>>>>> Dan Allen
>>>>>>> Senior Software Engineer, Red Hat | Author of Seam in Action
>>>>>>> Registered Linux User #231597
>>>>>>>
>>>>>>>
http://mojavelinux.com
>>>>>>>
http://mojavelinux.com/seaminaction
>>>>>>>
http://www.google.com/profiles/dan.j.allen
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>>
http://www.irian.at
>>>>>>
>>>>>> Your JSF powerhouse -
>>>>>> JSF Consulting, Development and
>>>>>> Courses in English and German
>>>>>>
>>>>>> Professional Support for Apache MyFaces
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>>
http://www.irian.at
>>>>
>>>> Your JSF powerhouse -
>>>> JSF Consulting, Development and
>>>> Courses in English and German
>>>>
>>>> Professional Support for Apache MyFaces
>>>
>>>
>>
>>
>> --
>>
>>
http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces