[jboss-user] [JBoss Seam] - Entity Injection question
smithbstl
do-not-reply at jboss.com
Mon Oct 1 11:34:46 EDT 2007
Lets say I have an input field in a page
| <h:inputText value="#{someEntity.someProperty}"/>
| <h:commandButton actionListener="#{foo.submit}"/>
|
| @Stateful
| @Name("foo")
| public class foo {
|
| @In(required=false)
| SomeEntity someEntity;
|
| @Logger
| Log log;
|
| public void submit() {
| if (someEntity != null) {
| log.debug("Entity IS NOT NULL");
| else {
| log.debug("Entity IS NULL");
| }
| }
|
Since I am referencing a property of someEntity in my page, the entity is automatically instantiated using its no arg constructor, even though I have not specified @In(create=true), correct? There is never a case where someEntity will be null.
I have a page where I have a number of these types of inputs that are optional. Even if I do not enter anything in the input component and its the only component that refers to a particular entity, I still get non null values when the entity is submitted. All of the properties of the entity are null but the object itself has been created by Seam.
I end up having to do this instead
public void submit() {
| if (someEntity.someProperty != null) {
| log.debug("Entity's Property IS NOT NULL");
| else {
| log.debug("Entity's Property IS NULL");
| }
| }
I understand this behavior but it just seems a little counter intuitive to someone trying to learn the basics of bijection.
I am just making sure I understand it. So am I going to have to check properties like this to clarify if an object is "functionally null" (all properties are null)?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4090313#4090313
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4090313
More information about the jboss-user
mailing list