Re: Basic WO question
Re: Basic WO question
- Subject: Re: Basic WO question
- From: Doug Andrews <email@hidden>
- Date: Tue, 15 Mar 2005 07:43:28 -0500
It sounds like your page name is bound to the 'pageName' attribute of
the hyperlinks.
This is the same as programmatically calling pageWithName(myPageName)
in your code, which will create an instance of the page each time.
You should bind your hyperlink to a method in your code instead. (The
'action' attribute of the hyperlink). You can then pass a reference of
page 1 to page 2, and use that to return.
For example, in Main.java, you could have the following method, that is
bound to the 'action' attribute of the hyperlink.
public WOComponent clickedLink()
{
ComponenteTres nextPage =
(ComponenteTres)pageWithName("ComponenteTres");
nextPage.setPrevPage(this);
return nextPage;
}
In your ComponenteTres.java, you will need two methods. The one above,
setPrevPage, and another 'clickedLink' method. You will also need the
class variable 'WOComponent lastPage';
public void setPrevPage(WOComponent lastPage)
{
this.lastPage = lastPage;
}
public WOComponent clickedLink()
{
return lastPage;
}
This way, when the user clicks on the hyperlink on the second page, he
will get the original instance of Main returned to them, instead of a
new instance.
-Doug Andrews
On Mar 15, 2005, at 12:35 AM, Daniel Mejia wrote:
Hi all,
I have a basic question that I know somebody can help me to answer in
this group.
The question is: how many times a component is created in WO (stateful
component). I have a small application with two components, Main and
ComponenteTres. The Main is a very basic page that has only a
WOHyperlink to the ComponenteTres component.
ComponenteTres component is a Form with one field and an action binded
to the sumit button that just print the value in the text field in the
form and a WOHyperlink to go back to the Main page.
Both Components Main and ComponeteTres has a System.out.println in the
constructor to display a message when the component is created.
What I expected was to have just one display from the constructor of
each component, but what I got is a message from the constructor every
time when I access the page and what is more extrange for me is that
when I click in the sumit button in the form of the secod component I
get a message from both, the Main component and the PageOne component.
Is this the expected behaviour?
When I click in the WOHyperlink to go back to the Main page I get a
message from the Main constructor method twice (?).
I'm developing with WO 5.2 and Mac OS 10.3.8.
Regards,
Daniel Mejia.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden