Ahh ok. Thanks. Read it too quickly.

Regards,
-Andre Mermegas


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
Erik Beeson
Sent: Friday, January 31, 2003 10:34 PM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] how to access bean property?

Read Jason's email again carefully. For that to work, you need to have
the
<ww:property value="name" /> tag inside the body of the first tag. Like
I
said, check Jason's example again carefully.

To the developers who don't want to break up PropertyTag, here we see
the
problem with a single tag that tries to do too much.

--Erik


On Fri, 31 Jan 2003, Andre Mermegas wrote:

> Oh, one thing, I tried pushing the testBean to the top of the value
> stack by doing
>
> <ww:property value="testBean"/>
>
> and then accessing it
>
> <ww:property value="name"/>
>
>
>
> But the first ww:property is actually outputting, not pushing the bean
> to the top of the value stack I think.
>
> com.versionary.beans.TestBean@a33d00
>
>
>
>
>
>
>
> Regards,
>
> -Andre Mermegas
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]] On Behalf Of
> Jason Carreira
> Sent: Friday, January 31, 2003 9:51 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [OS-webwork] how to access bean property?
>
>
>
> Andre,
>
> You'll want to do ActionContext.getContext() instead of new
> ActionContext().
>
> ActionContext.getContext() gets the ThreadLocal instance which is
> populated by the ServletDispatcher.
>
> You'll probably also want to maintain a reference to your TestBean :-)
>
> Here's an example:
>
> public class TestAction extends ActionSupport {
>     private TestBean myBean;
>
>     public TestBean getMyBean() {
>         return myBean;
>     }
>
>     public void setMyBean(TestBean myBean) {
>         this.myBean = myBean;
>     }
>
>     protected String doExecute() throws Exception {
>         myBean = new TestBean();
>
> BeanUtil.setProperties(ActionContext.getContext().getParameters(),
> myBean);
>         return SUCCESS;
>     }
> }
>
> Then, in your success.jsp, which is mapped as the success result of
> TestAction in the views.properties or actions.xml (see the docs for
how
> to configure actions and view mappings), you can do this:
>
> <webwork:property value="myBean"> <!-- This will call getMyBean() on
> your action and put it on the top of the value stack -->
>
> The name is: <webwork:property value="name"/> <!-- This will call
> getName() on your TestBean and print it to the page
> </webwork:property>
>
> This is a good way to do it if you have several parameters from the
> TestBean that you want to display, but, if you have just one, like in
> this case, it's probably better to do this:
>
> <webwork:property value="myBean/name"/>
>
> Which will call getMyBean.getName() and print that out to the page.
>
> Hope that helps.
>
> I've also put this up on the Wiki:
>
>
>
<http://www.opensymphony.com:8668/space/How+do+I+populate+a+form+bean+an
> d+get+the+value+using+the+taglib%3F>
>
http://www.opensymphony.com:8668/space/How+do+I+populate+a+form+bean+and
> +get+the+value+using+the+taglib%3F
>
>  -----Original Message-----
> From:   [EMAIL PROTECTED] [
> <mailto:[EMAIL PROTECTED]>
> mailto:[EMAIL PROTECTED]]  On Behalf Of
> Andre Mermegas
>
> Sent:   Friday, January 31, 2003 9:00 PM
> To:     [EMAIL PROTECTED]
> Subject:        [OS-webwork] how to access bean property?
>
> Hey all,
> If I'm doing something like:
>
> In my Action.doExecute()
> ActionContext ac = new ActionContext();
> BeanUtil.setProperties(ac.getParameters(),new TestBean());
>
> TestBean has one property "name".
>
> How do I access the "name" property using the ww taglibs?
>
> <ww:property value="name"/> doesn't seem to be hitting the bean.
> <ww:property value="$name"/> does work, picking up the request
parameter
> directly.
>
> I thought maybe I had to name the object bean and then pass it in,
like
> TestBean tb = new TestBean(); and then pass in the tb object and do
> <ww:property value="tb/name"/> but that doesn't work either.
>
> I've been looking through the docs, but I cant find it. I know I'm not
> hitting the Bean on the view.
>
> Regards,
> -Andre Mermegas
>
>
>
>
>
>
> Regards,
> -Andre Mermegas
>
>
>
>



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to