You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by phyopiyo <ph...@yahoo.com.sg> on 2006/06/03 15:28:59 UTC
[Shale - Clay] nested properties in @managed-bean-name can't work
Hi
I could not get/set property values of nested properties in my managed bean.
I am using normal HTML to reference to JSF components defined in my
clay-config.xml. Here is the code fragment.
<!-- ======== in HTML page =========== -->
<span jsfid="clay" allowBody="false" managedBeanName="testBean" />
...//supporing HTMLs code here
<tr>
<td>
<label jsfid="testObjLabel">Mock password</label>
</td>
<td>
<input jsfid="testObj" type="text" class="data_form">
</td>
<td>
<span jsfid="testObjMessage" class="error_form">Mock Error
Message</span>
</td>
</tr>
...//supporing HTMLs code here
<!-- ============ in clay-config.xml ============ -->
<component jsfid="testObjLabel" extends="outputLabel" allowBody="false">
<attributes>
<set name="value" value="#{messages['common.label.test']}" />
<set name="for" value="testObj" />
</attributes>
</component>
<component jsfid="testObj" extends="inputText" id="testObj">
<attributes>
<set name="value" value="#{@managed-bean-name.nestedProperty.testObj}" />
<set name="required" value="true" />
</attributes>
</component>
<component jsfid="testObjMessage" extends="message" allowBody="false">
<attributes>
<set name="for" value="testObj" />
</attributes>
</component>
<!-- ============ in respective backing bean ========= -->
public class TestBean extends AbstractViewController{
private NestedClass nestedProperty;
public NestedClass getNestedProperty(){
return nestedProperty;
}
public void setNestedProperty(NestedClass nested){
nestedProperty = nested;
}
// ... all other related methods like 'save', 'canel' etc.
}
<!-- ====== nested property class ========-->
public class NestedClass{
private String testObj;
public String getTestObj(){
return testObj;
}
public void setTestObj(String test){
testObj = test;
}
}
<!-- ========== in faces-config.xml ==========-->
<managed-bean>
<managed-bean-name>testBean</managed-bean-name>
<managed-bean-class>
com.test.TestBean
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<!-- ========== End ============== -->
I knew that we must use managed-beans in xxx$yyy format, if the URL is like
http://localhost:8080/myapplication/xxx/yyy.html. But my case here is using
http://localhost:8080/myapplication/testBean.html. Therefore, I gave my
managed-bean name 'testBean' without any $ character.
When i submit the form, I am getting ' "testObj": Error during model data
update. ' error message. When I try out other immediate properties (e.g.
@managed-bean-name.propertyOne ), i can set/gett it perfectly. The error
only happen when i used nested properties (e.g.
@managed-bean-name.propertyOne.littleNestedProperty).
Is there any thing that I need to do to solve this problem? I have already
read through and study the 'rolodex' example came along with Shale. But it
is too confusing and could not understand it because there are so many
components defined inside and i lost track. I also found that Rolodex
sample can successfully use nested bean properties from managed-bean. but i
just can't do it and can't find the reason why...
thank you for spending your precious time to read my mail....
Regards to all,
Phyo
--
View this message in context: http://www.nabble.com/-Shale---Clay--nested-properties-in-%40managed-bean-name-can%27t-work-t1727504.html#a4693586
Sent from the Struts - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Shale - Clay] nested properties in @managed-bean-name can't
work
Posted by phyopiyo <ph...@yahoo.com.sg>.
Hi
I just found out why this is happening. If you have nested objects under
your managed bean, and if it is a class defined by you, you must provide
the getter method of that object to return a new instance when the object is
null.
I got the solution from Rolodex example.... !
Thanks for providing a very good example in Rolodex, just a little bit hard
for new comer to know what's going on inside that Rolodex example.
Nonetheless, rolodex is the best example to explore.
Regards,
Phyo
--
View this message in context: http://www.nabble.com/-Shale---Clay--nested-properties-in-%40managed-bean-name-can%27t-work-t1727504.html#a4699691
Sent from the Struts - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org