Re: Basic WO question
Re: Basic WO question
- Subject: Re: Basic WO question
- From: Daniel Mejia <email@hidden>
- Date: Tue, 15 Mar 2005 10:09:37 -0600
Doug,
I did what you said and even in that case I got the initializing message from Main. When I click in the Hyperlink to go back and also I got the message when I clck in the submit button in the form in the componenteTres (!). Here are the functions that I added to both components.
Here are the pices of code that I added to the java and teh wod files.
In componenteTres:
public WOComponent submit()
{
System.out.println("Field value:" + nombre + "\n");
return null;
}
public WOComponent callMain()
{
return this.lastPage;
}
public void setPrevPage(WOComponent lastPage){
this.lastPage = lastPage;
}
In Main
public Main(WOContext context) {
super(context);
System.out.println("Initializing Main: \n");
}
public ComponenteTres callTress()
{
ComponenteTres nextPage = (ComponenteTres)pageWithName("ComponenteTres");
nextPage.setPrevPage((WOComponent) this);
// Initialize your component here
return nextPage;
}
Here are the wod file from Main
Hyperlink3: WOHyperlink {
action = callTress;
}
And from ComponenteTres
Form1: WOForm {
}
Hyperlink1: WOHyperlink {
action = callMain;
}
SubmitButton1: WOSubmitButton {
action = submit;
}
TextField1: WOTextField {
value = nombre;
}
On Mar 15, 2005, at 6:43 AM, Doug Andrews wrote:
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:
This email sent to email@hidden
J. Daniel Mejia S.
Evolution Technologies, S.A. de C.V.
Teléfono: (81) 8349.5780
_______________________________________________
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