Re: WOPopUpButton returns null
Re: WOPopUpButton returns null
- Subject: Re: WOPopUpButton returns null
- From: Drew Thoeni <email@hidden>
- Date: Tue, 20 Jan 2004 06:39:34 -0500
Karl,
As you and others suggested, I created a relationship in my EOModel
which appears to solve the WOPopUpButton problem. However, one thing
leads to another and...
I have the code tables/objects (the list of states in this case)
loading into a shared editing context at the Application level. When I
attempt to relate the stateCode object to the newAddress.state I get
"Cannot obtain a global ID in another editing context".
newAddress.state is in an editing context, "registerEc", and the
stateList is in the editing context "sharedEc".
I am doing this to separate the read-only objects (like the list of
states) from the user updatable objects (like Name, Address,
PaymentMethod).
What is the best design method to handle this?
Drew
On Jan 19, 2004, at 8:02 PM, Karl Gretton wrote:
Hi Drew,
Your bindings appear to be wrong. Currently, you have:
displayString: application.aStateCode.stateName
item: application.aStateCode
list: application.stateCodeList
selection: newAddress.state
Unless the newAddress.state is represently a toState relationship and
expecting a StateCode object, your code won't work. For example, if
newAddress.state is simply a 2-character string.
You should create another StateCode object in your class containing
the PopUpButton and use that. Then you can take the state code string
from there.
For example:-
displayString: application.aStateCode.stateName
item: application.aStateCode
list: application.stateCodeList
selection: theStateCode
and in your WOComponent you would have:-
protected StateCode theStateCode = new StateCode();
<snip>
public WOActionResults SomeActionInvokedWhenYouSubmitTheForm() {
if (theStateCode.stateCode != null and theStateCode.stateCode != "") {
newAddress.state = theStateCode.stateCode;
}
<the rest of your submit processing>
}
You should really just create a relationship in your model and then
set the toState relationship using the popup. This should work as an
alternative though. I hope that this helps.
Karl
On Jan 19, 2004, at 10:12 AM, Drew Thoeni wrote:
I hate to post such a basic question, but as a newbie I have not been
able to get a WOPopUpButton to work. I've spent several hours reading
and trying apparently every combination but the one that works. Help
if
you can and thanks in advance.
The scene;
Address.java contains a field "state"
State.java is a class that contains fields: stateAbbreviation and
stateName. State.java is initialized at the application level (since
it
does not change and may be accessed by all users). Here's the code:
public class Application extends WOApplication {
protected NSArray stateCodeList = new NSArray();
protected StateCode aStateCode = new StateCode();
<snip>
public static void main(String argv[]) {
WOApplication.main(argv, Application.class);
}
public Application() {
super();
setPageRefreshOnBacktrackEnabled(true);
// fetch State Code table
fetchSpec =
EOFetchSpecification.fetchSpecificationNamed("FetchIsLegalStateCodeLis
t"
, "StateCode");
stateCodeList =
sharedEc.objectsWithFetchSpecification(fetchSpec);
}
public WOResponse
handleSessionRestorationErrorInContext(WOContext
context) {
SessionTimeOut errorPage = (SessionTimeOut)
pageWithName("SessionTimeOut", context);
return errorPage.generateResponse();
}
}
In WOBuilder I have these set:
displayString: application.aStateCode.stateName
item: application.aStateCode
list: application.stateCodeList
selection: newAddress.state
If I replace the WOPopUpButton with a WOTextField and type a value
into
the WOTextField bound to newAddress.state (say "FL"), it works fine.
Using the WOPopUpButton, however, I get "The state property of Address
is not allowed to be null."
I'm sure I'm missing something obvious... just not to me.
Regards,
Drew
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.