Re: Problem with webobject attributes in WOBuilder
Re: Problem with webobject attributes in WOBuilder
- Subject: Re: Problem with webobject attributes in WOBuilder
- From: Paul Lynch <email@hidden>
- Date: Wed, 14 Jun 2006 14:19:55 +0100
On 14 Jun 2006, at 12:54, John Stewart wrote:
I'd like to keep this as MVC as possible, so the Java code should not
deal directly with the alternative styles, though It will provide the
logic to select the styles.
There's a mismatch here between what you seem to think MVC is, and
what you are doing. Let me explain: MVC just says
(oversimplification, but never mind) that you should apply a degree
of encapsulation around groupings of objects (model, view and
controller, obviously). In WebObjects, "Java" encompasses controller
objects as well as your model objects. So there's nothing wrong with
including pure html strings in your java code, so long as it is
within controllers.
I fully accept that it feels so much more elegant if you can avoid
having javascript, class names, and so on, in java; but sometimes you
just have to.
The simplest version of this is a straight boolean describing "open"
or "closed" styles. The java code can, say, provide a boolean
"isOpen".
If I create a ul wrapper "styleContainer" as below, I'd like to
include the "open" or "closed" styles, as well as a common "clear"
style.
The output would be of the form:
<!-- isOpen = true: -->
<ul class="clear open">
<li>...</li>
</ul>
<!-- isOpen = false: -->
<ul class="clear closed">
<li>...</li>
</ul>
Any ideas how I might do this without providing explicit class strings
in Java? Can a WOConditional be nested inside a WOGenericContainer
definition?
It certainly can. So long as it all sits inside the html portion of
your wo.
I could wrap the two versions inside two WOConditionals, but then it
would mean duplicating the whole list.
To further complicate things, what if I want more than 2 alternative
styles, e.g. fed by an integer instead of a boolean?
You could use conditionals and repetitions as you describe above. Or
you could create a new dynamic element that responded as you desire,
and all within the view layer. I get the impression that you may be
trying to force WO into some sort of "code within html" model, rather
like PHP or RoR.
Or is this one of WO's limitations where I have to include style names
in the Java code?
I wouldn't call it a limitation. As far as I am concerned, good
style is whatever works best.
Paul
_______________________________________________
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