• 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: Passing parameters on a binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing parameters on a binding


  • Subject: Re: Passing parameters on a binding
  • From: Jean-François Veillette <email@hidden>
  • Date: Thu, 21 Oct 2004 21:17:43 -0400

the last couple of days and have been
trying to extend his validation solution a bit. What I have done is
added a method to my super component:

	public boolean hasFailedValidationNamed(String key) {
		return validationData.objectForKey(key) != null;
	}

What I want to do is have a WOConditional in the page that can be bound
to hasFailedValidationNamed and pass it in the key. Is this at all
possible?
Yes and no. It is not possible with plain old key-value coding. It is
possible using OGNL (ask Google), there is a framework in Project Wonder
(WOOGNL) that wraps the OGNL library up for WO. I like it and it is
powerful, but it does add the potential for the binding version of
spaghetti code. You have been warned.

You can also use KVC to do what you want, without going fully with OGNL, you can easily implement a working solution.


1-
in your binding, you could have
aCondition: WOConditional { condition = validationData.aKey; }

That would work if 'validationData' is a NSDictionary. without any further work on your part. That's because NSDictionary does kvc by giving value for a given key.

2-
If validationData is not a dictionary, you can overload kvc in your component :


Object valueForKeyPath(String kp) {
if(kp.startWith("validationData.") {
String key = kp.substring(/* logic to get the key part after the "validationData." part*/);
return validationData.objectForKey(key) != null;
}
else
return super.valueForKeyPath(kp);
}


Last time I looked at OGNL it was really big, kvc on serious steroid.
I didn't like how we needed to integrate our code with it, and didn't need that much, so I decided to extend kvc in a different simpler manner.


- jfv

_______________________________________________
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: Passing parameters on a binding
      • From: Chuck Hill <email@hidden>
References: 
 >Re: Passing parameters on a binding (From: Chuck Hill <email@hidden>)

  • Prev by Date: Best option for static file access?
  • Next by Date: Reusable components
  • Previous by thread: Re: Passing parameters on a binding
  • Next by thread: Re: Passing parameters on a binding
  • Index(es):
    • Date
    • Thread