• 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: How do I initialize an Entity attribute upon creation in D2W?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I initialize an Entity attribute upon creation in D2W?


  • Subject: Re: How do I initialize an Entity attribute upon creation in D2W?
  • From: Philippe Rabier <email@hidden>
  • Date: Sat, 05 Nov 2011 22:34:16 +0100

James, if you use Modern Look, you know there is a navigation controller (and not a navigation manager) set by the session.

In the NavigationController class, we have this methods:

public WOComponent newObjectForEntityName(final String entityName)
{
    WOComponent nextPage = null;
    try {
        EditPageInterface epi = D2W.factory().editPageForNewObjectWithEntityNamed(entityName, session());
        epi.setNextPage(session().context().page());
        nextPage = (WOComponent) epi;
    } catch (IllegalArgumentException e) {
        ErrorPageInterface epf = D2W.factory().errorPage(session());
        epf.setMessage(e.toString());
        epf.setNextPage(session().context().page());
        nextPage = (WOComponent) epf;
    }
    return nextPage;
}


public WOComponent createProjectAction()
{
WOComponent nextPage = newObjectForEntityName(NOProject.Keys.ENTITY_NAME);
if(session().getClient() != null)
{
if(nextPage instanceof ERD2WPage)
{
NOProject obj = (NOProject) ((ERD2WPage)nextPage).object();
if(obj != null)
{
obj.setClientRelationship((NOClient) EOUtilities.localInstanceOfObject(obj.editingContext(), session().getClient()));
}
}
}
return nextPage;
}

As you can see in the createProjectAction method, you get your object, here a Project object, so you can initialize your attributes here.

Just to be sure we are on the same page, in the navigationmenu.plist, I have that:
{
name = CreateClient;
displayName = New;
action = "";
},

Let me know if you need more help.

Philippe


On 5 nov. 2011, at 17:49, James Cicenia wrote:

I do use ModernLook

I am not quite certain how to get the attributes of the newly created entity.

Thanks
James



On Nov 5, 2011, at 11:39 AM, Philippe Rabier wrote:

Do you use Modern Look ?

Because we use the navigation manager to set relationship. 

I'm away from home right now but can take a closer look later. 

Philippe

Sent from my iPhone

On 5 nov. 2011, at 17:23, James Cicenia <email@hidden> wrote:

The subject line is the question.

I use the standard factory:

    public WOComponent newObjectForEntityName(String entityName) {
        WOComponent nextPage = null;
        try {
            EditPageInterface epi = D2W.factory().editPageForNewObjectWithEntityNamed(entityName, session());
            epi.setNextPage(session().context().page());
            nextPage = (WOComponent) epi;
        } catch (IllegalArgumentException e) {
            ErrorPageInterface epf = D2W.factory().errorPage(session());
            epf.setMessage(e.toString());
            epf.setNextPage(session().context().page());
            nextPage = (WOComponent) epf;
            
        }
        return nextPage;
    }

Thanks
James


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: How do I initialize an Entity attribute upon creation in D2W?
      • From: James Cicenia <email@hidden>
References: 
 >How do I initialize an Entity attribute upon creation in D2W? (From: James Cicenia <email@hidden>)

  • Prev by Date: Re: How do I initialize an Entity attribute upon creation in D2W?
  • Next by Date: Re: How do I initialize an Entity attribute upon creation in D2W?
  • Previous by thread: Re: How do I initialize an Entity attribute upon creation in D2W?
  • Next by thread: Re: How do I initialize an Entity attribute upon creation in D2W?
  • Index(es):
    • Date
    • Thread