• 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: WOPopUpButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOPopUpButton


  • Subject: Re: WOPopUpButton
  • From: "Jerry W. Walker" <email@hidden>
  • Date: Sat, 23 Jun 2007 07:12:07 -0400

Hi, Sigurður,

Apple provides a WO project template that includes the Session, Application and DirectAction classes for your customization. These are subclasses, respectively, of WOSession, WOApplication and WODirectAction which are classes defined in the com.webobjects.appserver package in the JavaWebObjects.framework.

Apple also provides the following methods in WOComponent:

session() - Returns the current WOSession object (that is, your current Session object), but if you check the JavaDocs, you'll note that the type of the object returned is com.webobjects.appserver.WOSession.

application() - Returns the WOApplication object for the current application (that is, your current Application object), but, again, the type returned is com.webobjects.appserverWOApplication.

If you define a method in your custom Session class, then the way to reference that method from, say, one of your components, is to write:

  ((Session)session()).myMethod()

The reason for (Session) is to cast your returned session object from the superclass WOSession type more narrowly to your custom Session subclass type so that the Java compiler recognizes the methods of your subclass.

However, defaultEditingContext() is a method defined in WOSession, not in your Session subclass, so it can be reached either directly from WOSession as follows:

    session().defaultEditingContext()

or, since it is inherited by your subclass, through a reference to your Session subclass by:

    ((Session)session()).defaultEditingContext()

Note that in this latter reference, the compiler must have access to two definitions: the class definition for Session and the method definition for session(). The session() method definition is easy, it will always be available to any subclass of WOComponent. However, the Session definition will not be recognized by the compiler unless you've added an import statement at the beginning of your WOComponent subclass indicating the package in which your Session is defined, or you fully qualify your Session's name, e.g. my.package.Session.

Typically, your WOComponents are defined in the same application bundle in which your Session is defined and both are in the unnamed class, so you won't have any problems referencing Session. However, if you are defining a WOComponent subclass in a framework outside of your application, or if you've put your Session in a package, then you have to let the compiler know where it can find the definition for Session.

Note, also, that if you use the method, session(), from within a DirectAction subclass, you will be referencing a different session() method than that provided in WOComponent. It will typically still return a Session of type com.webobjects.appserver.WOSession, but it goes about the process differently since there's no guarantee from with your DirectAction class that a Session even exists.

Hope this helps.

Regards,
Jerry

On Jun 23, 2007, at 6:23 AM, Sigurður E. Vilhelmsson wrote:

OK, a quick Java lesson required :)

What is the difference between the two, i.e. what is the top line
trying to do, that the bottom one skips?

ec = ((Session)session()).defaultEditingContext()
and
ec = session().defaultEditingContext()

Just trying not to be a code monkey, I want to understand what I am doing :)

Sigurdur

2007/6/22, Miguel Arroz <email@hidden>:
Hi!

   Are you sure you are including the right include for Session?

   Anyway, you may write only ec = session().defaultEditingContext(),
without the type conversion, because the WOSession superclass has the
defaultEditingContext method.

   Yours

Miguel Arroz

On 2007/06/22, at 18:15, Sigurður E. Vilhelmsson wrote:

> Sorry to stray back to the original topic :P but I'm getting an error
> in my java file. I used the code from David:
>
> public NSArray allCourseDescription() {
> EOEditingContext ec = ((Session)session
> ()).defaultEditingContext();
> return EOUtilities.objectsForEntityNamed(ec,
> "CourseDescription");
> }
>
> (I figured the extra space and s in allCourseDescription s() were a
> typo)
>
> However, now I get an error complaining that "Session cannot be
> resolved to a type".
>
> Best regards,
> Sigurdur
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40guiamac.com
>
> This email sent to email@hidden


Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems


    email@hidden
    203 278-4085        office



_______________________________________________
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


References: 
 >WOPopUpButton (From: "Sigurður E. Vilhelmsson" <email@hidden>)
 >Re: WOPopUpButton (From: David LeBer <email@hidden>)
 >Re: WOPopUpButton (From: Ian Joyner <email@hidden>)
 >Re: WOPopUpButton (From: Eric Robinson <email@hidden>)
 >Re: WOPopUpButton (From: Ian Joyner <email@hidden>)
 >Re: WOPopUpButton (From: Mike Schrag <email@hidden>)
 >Re: WOPopUpButton (From: Ken Anderson <email@hidden>)
 >Re: WOPopUpButton (From: Miguel Arroz <email@hidden>)
 >Re: WOPopUpButton (From: "Sigurður E. Vilhelmsson" <email@hidden>)
 >Re: WOPopUpButton (From: Miguel Arroz <email@hidden>)
 >Re: WOPopUpButton (From: "Sigurður E. Vilhelmsson" <email@hidden>)

  • Prev by Date: Re: WOPopUpButton
  • Next by Date: Java Client : who is using it ?
  • Previous by thread: Re: WOPopUpButton
  • Next by thread: Re: WOPopUpButton
  • Index(es):
    • Date
    • Thread