• 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: Conditionals for username/password?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conditionals for username/password?


  • Subject: Re: Conditionals for username/password?
  • From: David LeBer <email@hidden>
  • Date: Mon, 8 Nov 2004 13:10:28 -0500

On Nov 8, 2004, at 12:06 PM, Jeremy Matthews wrote:

I'm still working on my login page, but I've got a question:

If a user does not enter values into the login fields (username and password) and clicks on the submit button, I want a WOConditional to display "...enter your id/pass, yadda yadda yadda...".

After binding this conditional to the submit button, the submit button no longer works. What gives? Is there a better way, short of using JavaScript?

The conditional should be based on the result of the login action, not bound directly to the submit button. You could do something like this:


Add these to your component:

	public boolean errorFlag = false;
	public boolean errorString = "";

Bind the "error conditional" to the error flag, and wrap the conditional around a WOString bound to the errorString.

Bind the submit button to a checkUserLogin action that returns a WOComponent

String username; // assume exists and bound to the username WOTextField
String password; // assume exists and bound to the password WOTextField

public WOComponent checkUserLogin() {
errorFlag = false;
errorString = "";
// You could check to make sure the fields have valid values
// ie:
if (username == null || username.length() == 0) {
errorFlag = true;
errorString = "A user is required. Doofus!";
return this.context().page();
}
EOEditingContext ec = session().defaultEditingContext();
NSDictionary args = new NSDictionary(new NSArray(new String[] {username, password}),
new NSArray(new String[] {"username", "password"}));
try {
MemberData user = (MemberData)EOUtilities.objectMatchingValues(ec, "MemberData", args);
NextPage page = (NextPage)pageWIthName("NextPage");
//setup page there
return page;
} catch (EOObjectNotAvailableException e) {
errorFlag = true;
errorString = "What are you trying to pull, that's no user I know about. Idiot!";
return this.context().page();
}
}


Obviously your error messages should be a little more diplomatic :-)

;david

--
David LeBer
Codebase Software Systems
site:   http://www.codebase.ca
blog: http://david.codebase.ca

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Conditionals for username/password?
      • From: Nathan Dumar <email@hidden>
References: 
 >Conditionals for username/password? (From: Jeremy Matthews <email@hidden>)

  • Prev by Date: Re: EOF inserts PK automatically
  • Next by Date: Re: Conditionals for username/password?
  • Previous by thread: Conditionals for username/password?
  • Next by thread: Re: Conditionals for username/password?
  • Index(es):
    • Date
    • Thread