-
1. Re: How are @In(create = true) and @Name connected?
limousyf Aug 23, 2007 4:39 AM (in response to wise_guybg)Mmm, first @Out complains about nullity because you didn't specify that it wasn't required (required=false).
This means the outjected value must not be null
About the @Name, if I understand your question, the link is done on the var name.
If you inject ExamData examData; Seam will look for "examData" in the contexts.
If you specify that you want to look for myExamData for example, it's done like this:
@In(value="myExamData") -
2. Re: How are @In(create = true) and @Name connected?
wise_guybg Aug 23, 2007 4:44 AM (in response to wise_guybg)Yes, @Out needs a not-null value and this is why I added create=true.
My question is why does the creation depend on whether I have @Name or not.
BTW Is there a case in which problems arise from having @Name("examData") and a field @In @Out ExamData examData? -
3. Re: How are @In(create = true) and @Name connected?
pmuir Aug 23, 2007 5:36 AM (in response to wise_guybg)@Name registers your class as a Seam component. If you don't put @Name on it and @In it, then you need to provide another way of instantiating e.g. a factory.
-
4. Re: How are @In(create = true) and @Name connected?
wise_guybg Aug 23, 2007 6:40 AM (in response to wise_guybg)Thanks for the explanation. It has helped me turn my attention on the In annotation. Here is what the javadoc states:
/** * Specifies that a component should be instantiated * if the context variable is null. */ boolean create() default false;
and have a look at Component.javaprivate static Object getInstance(String name, boolean create, Object result)
where it is said that:if (result==null && create) { result = getInstanceFromFactory(name); if (result==null) { if (component==null) { //needed when this method is called by JSF if ( log.isDebugEnabled() ) log.debug("seam component not found: " + name); }
And here it is:2007-08-23 13:26:51,459 DEBUG [org.jboss.seam.Component] seam component not found: examData
I understand it better now.