Hi,
Out of curiosity, I have been trying to understand the request-response loop. I have a fairly simple WO Component that has a WOTextField in it.
<webobject name = "myForm">
Please enter your name: <webobject name = "userName"></webobject>
<webobject name = "submitMe"></webobject>
</webobject>
In the .java file I just print the stack trace as follows to understand the flow:
public String getUserName() {
Exception e = new Exception();
e.printStackTrace();
System.out.println("user name is " + userName );
return userName;
}
public void setUserName(String userName) {
Exception e = new Exception();
e.printStackTrace();
this.userName = userName;
}
When I hit submitMe, I would have thought that only the setUserName would have got called in takeValuesFromRequest.
However I find that instead the getUserName() gets called first and then the setUserName() gets called.
Why is there a necessity for the WOTextField to actually get() values from the enclosing component in a takeValuesFromRequest() stage of the request-response cycle?
Stack traces in chronological order:
java.lang.Exception
at your.app.components.Main.getUserName(Main.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor$1.methodValue(NSKeyValueCoding.java:636)
at com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(NSKeyValueCoding.java:1134)
at com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueForKey(NSKeyValueCoding.java:1324)
at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1736)
at com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValueCoding.java:447)
at com.webobjects.foundation.NSValidation$DefaultImplementation.validateTakeValueForKeyPath(NSValidation.java:676)
at com.webobjects.appserver.WOComponent.validateTakeValueForKeyPath(WOComponent.java:1424)
at com.webobjects.appserver._private.WOKeyValueAssociation.setValue(WOKeyValueAssociation.java:76)
at com.webobjects.appserver._private.WOTextField.takeValuesFromRequest(WOTextField.java:102)
at com.webobjects.appserver._private.WODynamicGroup.takeChildrenValuesFromRequest(WODynamicGroup.java:84)
at com.webobjects.appserver._private.WODynamicGroup.takeValuesFromRequest(WODynamicGroup.java:93)
at com.webobjects.appserver._private.WOForm.takeValuesFromRequest(WOForm.java:122)
at com.webobjects.appserver._private.WODynamicGroup.takeChildrenValuesFromRequest(WODynamicGroup.java:84)
at com.webobjects.appserver._private.WODynamicGroup.takeValuesFromRequest(WODynamicGroup.java:93)
at com.webobjects.appserver.WOComponent.takeValuesFromRequest(WOComponent.java:1051)
at com.webobjects.appserver.WOSession.takeValuesFromRequest(WOSession.java:1331)
at com.webobjects.appserver.WOApplication.takeValuesFromRequest(WOApplication.java:1724)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedPage(WOComponentRequestHandler.java:199)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:298)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332)
at com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:369)
at com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:442)
at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1687)
at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
at java.lang.Thread.run(Thread.java:613)
---------------
java.lang.Exception
at your.app.components.Main.setUserName(Main.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor$1.setMethodValue(NSKeyValueCoding.java:643)
at com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.setValueInObject(NSKeyValueCoding.java:1150)
at com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.takeValueForKey(NSKeyValueCoding.java:1354)
at com.webobjects.appserver.WOComponent.takeValueForKey(WOComponent.java:1748)
at com.webobjects.foundation.NSKeyValueCoding$Utility.takeValueForKey(NSKeyValueCoding.java:469)
at com.webobjects.foundation.NSValidation$DefaultImplementation.validateTakeValueForKeyPath(NSValidation.java:679)
at com.webobjects.appserver.WOComponent.validateTakeValueForKeyPath(WOComponent.java:1424)
at com.webobjects.appserver._private.WOKeyValueAssociation.setValue(WOKeyValueAssociation.java:76)
at com.webobjects.appserver._private.WOTextField.takeValuesFromRequest(WOTextField.java:102)
at com.webobjects.appserver._private.WODynamicGroup.takeChildrenValuesFromRequest(WODynamicGroup.java:84)
at com.webobjects.appserver._private.WODynamicGroup.takeValuesFromRequest(WODynamicGroup.java:93)
at com.webobjects.appserver._private.WOForm.takeValuesFromRequest(WOForm.java:122)
at com.webobjects.appserver._private.WODynamicGroup.takeChildrenValuesFromRequest(WODynamicGroup.java:84)
at com.webobjects.appserver._private.WODynamicGroup.takeValuesFromRequest(WODynamicGroup.java:93)
at com.webobjects.appserver.WOComponent.takeValuesFromRequest(WOComponent.java:1051)
at com.webobjects.appserver.WOSession.takeValuesFromRequest(WOSession.java:1331)
at com.webobjects.appserver.WOApplication.takeValuesFromRequest(WOApplication.java:1724)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedPage(WOComponentRequestHandler.java:199)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:298)
at com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332)
at com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:369)
at com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:442)
at com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1687)
at com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
at com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
at java.lang.Thread.run(Thread.java:613)
Thanks, Karthik