Sorry if this is dirt simply but I seem to be missing something that every google search, as well as page 170 in Joshua Marker's book suggest should work.
I have a small app where there is an WOHyperlink called "Submit new idea" that calls a method that creates a new "Idea" object and the returns a new "EditIdea" page.
public EditIdea submitIdeaAction() {
EditIdea nextPage = (EditIdea) pageWithName("EditIdea");
// Initialize your component here
EOEditingContext ec = session().defaultEditingContext();
ec.revert();
Idea aNewIdea = (Idea) EOUtilities.createAndInsertInstance(ec, "Idea");
nextPage.editIdea = aNewIdea;
return nextPage;
}
In the Idea class (which is an EOGenerator class) has a constructor method that by sets the status of the class to "PROPOSED".
private static final String PROPOSED = "P";
public Idea() {
super();
setProposedStatus();
}
public void setProposedStatus() {
setStatus(PROPOSED);
}
However, by the time I get to the EditIdea page, the Idea's status is null. Huh? I know the constructor above is getting called, but I don't know why it gets reset on the EditIdea page.
I can only think that the creation and insertion of the EO into the editing context does this. However I would not use the constructor to init any default value but implement the dedicated method awakeFromInsertion() for this purpose. The constructor is also executed when you read the object data from the database and the framework re-constructs your EO. This is probably not what you want.