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

Re: Simple Stuff Help


  • Subject: Re: Simple Stuff Help
  • From: Gustavo Pizano <email@hidden>
  • Date: Fri, 14 Mar 2008 22:30:22 -0500

WOW Hold On!!

this is what i made form what I learned from teh tutrial, I created a EOModel called UsersModel and there I create an entity called Users which contains the follwoing atributes

lastName varchar(20)
name varchar(20)
userid int PK
admin_privilege_key int
password varchar(20)

so what im planing its to give the last atribute a valor of 1 or 0 depending if its admin or client respectlyvzly 
 I generated the EO 
which has the accessors.

I was thinkin in make a WO called login with a form with username(which it will be the id) and the password
so form there to the session.
Im assuming that I have some data already in the db.(at least an admin and a client, for tests purposes  )

so if its an admin it will open a new page (wo) which will have (for now) an insert user, and all its attributes. and display all the users or an specified user.
and if its a client then... well i dunno what to display so far for the client.

What im having problem in understandin its about the EOEditingContex, like WTH is that, i have something in my mind i just need to assimilate it.
and well I wanna get the user who is loggin from the database to see if its a admin or client. so i think i must use this valueForKey(Stringkey) 
and this should be in the Session.java no? just that something is telling me I must use the EOEditingcontexts no?

Gus



On Mar 14, 2008, at 9:58 PM, Chuck Hill wrote:


On Mar 14, 2008, at 6:46 PM, Gustavo Pizano wrote:

Hello, well after doing the tutorial I will try to do simple things, like log into a system, and depending if the user is Client or Admin it will show diferents webpages, Im planing this to start having a better understanding of the "how does it work".
SO lets say I have a DB with users and privileges, so at the login page  will log on as client or admin,
I was reading how to schive this simple thing, but hadn't been able to figure it out. As far as I understadn I must delegate this to the EOF with some especial class and special operation, just I can't find it.

or.. if there is other easier way to do it with WO/EO, then can I get some help, even don;t telling me the "how" otherwise it will take the "magic" away, but the "where" can i find info.

Here is something to get you thinking:

String userID;  // From  your login page
String password;   // From  your login page
Session session = (Session)session();

// You need to write session.setUser() and User.authenticatedUserFromCredentials()
session.setUser(User.authenticatedUserFromCredentials(session.defaultEditingContext(), userID, password);
if (person == null) {
   // Handle failure to log in, then
   return context().page();
}

// You need to define ADMIN_PRIVILEGE_KEY and write Privilege.privilegeWithKey()
Privilege adminPrivilege = Privilege.privilegeWithKey(session.defaultEditingContext(, Privilege.ADMIN_PRIVILEGE_KEY);

if (session.user().privileges().containsObject(adminPrivilege)) {
   return pageWithName(AdminHomePage.class.getName());
}

return pageWithName(HomePage.class.getName());


Chuck



--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






 _______________________________________________
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: Simple Stuff Help
      • From: David LeBer <email@hidden>
References: 
 >Simple Stuff Help (From: Gustavo Pizano <email@hidden>)
 >Re: Simple Stuff Help (From: Chuck Hill <email@hidden>)

  • Prev by Date: WOLips Community Installer
  • Next by Date: Re: Simple Stuff Help
  • Previous by thread: Re: Simple Stuff Help
  • Next by thread: Re: Simple Stuff Help
  • Index(es):
    • Date
    • Thread