Setting bindings in wizard-like page components
Setting bindings in wizard-like page components
- Subject: Setting bindings in wizard-like page components
- From: Mark Wardle <email@hidden>
- Date: Thu, 8 Oct 2009 22:16:22 +0100
Hello all.
Apologies for how specific this question is - I tried hard to make it
more generic but ended up thinking this was clearer:
I've got a page-level SNOMED CT component that allows a user to search
and browse medical terms. It is fairly heavyweight and probably not
the best way of doing things, but it works.
I'm currently calling it like this from a different component:
ChooseSnomedPage nextPage = pageWithName(ChooseSnomedPage.class);
nextPage.setTitle("Choose ethnic origin");
nextPage.setTarget(this.patient);
nextPage.setBinding(Patient.ETHNIC_ORIGIN_KEY);
nextPage.setRootConcept(Concept.fetchRequiredConcept(patient.editingContext(),
Concept.CONCEPT_ID_KEY, 372148003L));
nextPage.setNextPage(this.context().page());
return nextPage;
This example limits the choice to ethnicity options. The
"ChooseSnomedPage" component takes a target object (setTarget) and a
binding (setBinding) and once a choice is made, calls this:
NSKeyValueCoding.Utility.takeValueForKey(target(),
concept, binding());
to set the value. This works well. When a SNOMED CT concept is chosen,
the result is manually pushed into the target using KVC.
While it works, it seems very cumbersome, particularly if there are a
number of properties. I'd like to replace this call with a stateless
component that provides its own component action method.
For example:
<wo:SnomedTerm value = "$patient.occupation" title="Choose occupation"
rootConceptId="14679004"/>
SnomedTerm.html:
----------------------------
<webobject name="SnomedLink">
<webobject name="SnomedDescription"/>
</webobject>
SnomedTerm.wod:
----------------------------
SnomedLink: WOHyperlink {
action = editSnomedAction;
disabled = ^disabled;
id = ^id;
}
SnomedDescription: WOString {
value = value.fullySpecifiedName;
valueWhenEmpty = valueWhenEmpty;
}
SnomedTerm implements the editSnomedAction like this:
public WOActionResults editSnomedAction() {
ChooseSnomedPage nextPage = pageWithName(ChooseSnomedPage.class);
nextPage.setTitle(title());
nextPage.setTarget(this);
nextPage.setBinding("value");
nextPage.setRootConcept(rootConcept());
nextPage.setNextPage(this.context().page());
return nextPage;
}
It sets the target to itself, and the binding to value.
Unfortunately, while the correct property is read, it is not
subsequently set if a SNOMED concept is chosen. The log files show
that the binding is correctly set, and this does use
setValueForBinding() which I thought would push the value back to the
parent component, but I wonder whether this happening in the next
phase of the R-R loop and so, as this is stateless, it won't work.
Is there a more Webobjects-way of implementing a small stateless
component that edits a property by returning a page-level component,
much like a wizard, and then returning back to the original page? I
don't really want to use an AJAX-based approach.
I suppose the alternative is to use something like this:
<wo:SnomedTerm target = "$patient" property="occupation" title="Choose
occupation" rootConceptId="14679004"/>
And then manually do KVC on patient with the key "occupation", but
surely there's a better way?
Sorry if this isn't very clear. All help gratefully received!
Best wishes,
Mark
--
Dr. Mark Wardle MB MRCP MD
Specialist registrar, Neurology
Cardiff, UK
_______________________________________________
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