Well, true to my inexperience, my implementation of this idea leaves alot to
be desired.(but it works!) The code for the page is below. The
TurbineTypeResolver service (I don't know if it really needs to be a
service) parses an xml file at init and caches user-agent strings keys to
type values (html, wml, hdml, etc.). The DeckLoader is modeled after the
other standard loaders in Turbine. I have a WebMacroDeckLoader so I can
build wml decks like the following:
<wml>
<card>
#if(haveData)
$stuff
}
#else
{
<p>no stuff!</p>
}
</card>
</wml>
And a WML parser that processes everything to put the proper extra stuff
that WML needs. The deck has to write to data.getOut() to avoid the (ECS?)
html tags and such... Ideally we would want a DigestLoader that loads a
DeckLoader that loads multiple CardLoaders. As you can see, TurbineResources
need entries for each default."type"
It would be useful if the AssemblerBrokerService were more configurable,
too. Right now it seems to register only "actions", "screens", "navigations"
etc. Making this more general would be good for other things in Turbine such
as ScheduledJobs which doesn't use the AssemblerBroker but explicitly finds
jobs in a directory off the modules path...
Ultimately, RunData should be more general too, maybe be an interface,
because you would want to ask it things like getDeck() in the WML case...
(RunDataHTML implements RunData, RunDataWML implements RunData...)Just some
ideas I've been thinking about - don't know if all this is necessary.
Let me know what you think may be worth pursuing, if any of it. I'm busy
working on some other technology currently, but this stuff really interests
me...
public class PageTypeResolver extends Page
{
// this is a hack to direct traffic by requester type
protected void build(RunData data)
{
String type = TurbineTypeResolver.getUserType(data);
try
{
// HTML
if(type.compareToIgnoreCase(XMLResources.HTML_MEDIA_TYPE) == 0)
PageLoader.getInstance().exec(data,
TurbineResources.getString("page.HTMLDefault"));
// WML
else if(type.compareToIgnoreCase(XMLResources.WML_MEDIA_TYPE) ==
0)
DeckLoader.getInstance().exec(data,
TurbineResources.getString("deck.WMLDefault"));
// default
else
PageLoader.getInstance().exec(data,
TurbineResources.getString("page.HTMLDefault"));
}
catch(Exception e)
{
org.apache.turbine.util.Log.error("Type Resolver Error: " +
e.toString());
}
}
public void doBuild(RunData data)
{
build(data);
}
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Magnus ?or Torfason
Sent: Monday, December 18, 2000 10:34 AM
To: Turbine
Subject: RE: [Proposal] keywords
> For that matter, it would also be
> useful to have some kind of user-agent resolver so that Turbine
> could load a
> "digest" which subsequently loads decks and cards (instead of a page that
> loads layouts, screens, and navigations) based on the user-agent string. I
> built my own deck loader, but scince Turbine.java always loads a
> page, I had
> to hack-up a page that does this user-type-resolution for me...
>
> Chris
>
That's very cool, I have done multi-ML (HTML/WML/..) in the same
app, but it required different url's for each user agent.
Would you care to let me see this code of yours, and perhaps
we could find a way do make it general enough so that it would
make sense as a standard page that would be part of the Turbine
distro (one of the standard pages, not the default page of course)
Magnus
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]