Re: WOGenericContainer convert elementName to lowercase automatically
Re: WOGenericContainer convert elementName to lowercase automatically
- Subject: Re: WOGenericContainer convert elementName to lowercase automatically
- From: "Yung-Luen Lan" <email@hidden>
- Date: Sat, 26 Apr 2008 00:48:59 +0800
Hi,
Without Wonder, it still produce lowercase only tag.
I wrote my (simplified) version of WOGenericContainer to get the
output respect to the type case of elementName.
I guess it's basic stuff but I'll post here. However, that's a good
practice anyway. (I followed Chuck's book to finish this element.
Thanks, Chuck.)
================================
package your.app;
import com.webobjects.appserver.*;
import com.webobjects.appserver._private.WODynamicElementCreationException;
import com.webobjects.foundation.*;
public class MyGenericContainer extends WODynamicElement {
protected NSDictionary<String, WOAssociation> extraBindings = null;
protected WOAssociation elementName;
protected WOElement children;
public MyGenericContainer(String n, NSDictionary<String,
WOAssociation> m, WOElement t) {
super(n, m, t);
elementName = m.objectForKey("elementName");
if (elementName == null) {
throw new WODynamicElementCreationException("Need elementName.");
}
if (m.count() > 1) {
NSMutableDictionary<String, WOAssociation> tempBindings =
m.mutableClone();
tempBindings.removeObjectForKey("elementName");
extraBindings = tempBindings.immutableClone();
}
children = t;
}
public void appendToResponse(WOResponse r, WOContext c) {
r.appendContentString("<" + elementName.valueInComponent(c.component()));
if (extraBindings != null) {
NSArray<String> allKeys = extraBindings.allKeys();
for (String k : allKeys) {
WOAssociation binding = extraBindings.objectForKey(k);
r.appendContentString(" " + k + "=\"" +
binding.valueInComponent(c.component()).toString() + "\"");
}
}
r.appendContentString(">");
children.appendToResponse(r, c);
r.appendContentString("</" +
elementName.valueInComponent(c.component()) + ">");
}
}
================================
Regards,
yllan
On Fri, Apr 25, 2008 at 6:23 AM, Lachlan Deck <email@hidden> wrote:
> Hi there,
>
>
> On 25/04/2008, at 7:01 AM, Yung-Luen Lan wrote:
>
>
> > Is it just me?
> > I think it's a bug so I filed a bug report to Apple.
> >
>
> You'd have to take Wonder out of the mix to determine whether it's in WO or
> Wonder.
>
> Old versions of WO used to have (terrible) upper-case tags. I suspect
> someone's put in a blanket lowercasing.
>
> Perhaps you could adapt your code to look for the lowercased version of the
> keys?
>
>
> >
> >
> >
> > On Thu, Apr 24, 2008 at 12:06 AM, Yung-Luen Lan <email@hidden>
> wrote:
> >
> > > Hi,
> > >
> > > I use WO to generate XML file in my project. After updating my
> > > outdated deploy environment to WO 5.4 / Project Wonder 4.x, I found
> > > the xml generated is different: all the tags rendered by
> > > WOGenericContainer become lowercase.
> > >
> > > I use CamelCase before, and match these XML tree with their CamelCase
> > > node name in other client app. Since they all become lowercase now,
> > > the client program no longer match them correctly.
> > >
> > > My wod looks like this:
> > >
> > > Client: WOGenericContainer {
> > > elementName = "Client";
> > > name=client.name;
> > > }
> > >
> > > but the XML code generated looks like:
> > > <client name="Bill"></client>
> > >
> > > Is there any way that I can set these tag to CamelCase or just tell
> > > the WO don't convert them for me?
> > >
> > > Regards,
> > > yllan
> > >
> > >
> > _______________________________________________
> > 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
> >
>
> with regards,
> --
>
> Lachlan Deck
>
>
>
>
_______________________________________________
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