• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EO/Java class default Values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EO/Java class default Values


  • Subject: Re: EO/Java class default Values
  • From: Markus Ruggiero <email@hidden>
  • Date: Wed, 27 Sep 2006 09:07:21 +0200


On 27.09.2006, at 06:40, Tarun Reddy wrote:

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.


Don't miss my latest project at http://blindpromo.com


Markus Ruggiero

rucotec consulting and technologies    email     mailto:email@hidden

rucotec GmbH                           web       http://www.rucotec.ch

Steinentorstrasse 8             

4051 Basel                             Mobile    +41 (0)79 508 4701

Switzerland                            Phone/Fax +41 (0)61 271 4990



 _______________________________________________
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

  • Follow-Ups:
    • Re: EO/Java class default Values
      • From: Ken Anderson <email@hidden>
References: 
 >EO/Java class default Values (From: Tarun Reddy <email@hidden>)

  • Prev by Date: EO/Java class default Values
  • Next by Date: Re: Log output using Wonder 3.0
  • Previous by thread: EO/Java class default Values
  • Next by thread: Re: EO/Java class default Values
  • Index(es):
    • Date
    • Thread