Well, I'm not very well accuainted with WebMacro, and it might be easy to
accomplish with templates, but I've developed an application for WML using
screens, and found some limitations.
Problem: The biggest is that org.apache.ecs.Document, the container of all
the stuff in the page, is very HTML oriented ( method setHtml(Html
set_html) ). I did not see how the <html></html> tags that result from this
method can be avoided in a neat way. I subclassed org.apache.ecs.html.Html
with my very own WML element, and output the mandatory header in a subclass
of Layout. See source at bottom of page.
Solution: Not very easy, seems to me that this would require creating a
markup-language independent document class and modifying RunData to use that
class instead of Document
Problem: When a redirection is neccessary a text/html document (with a
redirection header, 302 i believe) straight from Turbine servlet. This
works with some wap devices, but not with others.
Solution: Modifying Turbine, one possibility is to put in a conditional
processing based on the request (redirect, or output legal wml to instruct
the browser to check the new page), or modularizing the redirection
handling, possibly with a Redirection class, with the function
processRedirect(HttpResponse res, String redirectionUrl). This contains
some overhead, and would need to be Screen dependent, because:
Problem: I would like to run the WML frontend in the same instance as the
regular Html frontend. This requires screen dependent redirection handling,
and, the ability to specify a Login Screen in the request, since the default
login screen obviously is legal for only one of the content types.
Solution: Add a mechanism in Turbine.java to allow screen variables to be
really used, instead of always pointing to the one specified in
TurbineResources.properties. This would of course create a security
loophole, but could be countered with a boolean isScreenLoginScreen()
function in Screen, returning false, but allowing login screens to subclass
the function to return true.
I would be prepared to contribute to the tree if people like these changes,
but if people do not, I will go on using hacks not requiring modifications
to the core Turbine code, since that will lessen the work maintaining my
app.
Any comments?
// ---------------------------------------
// WmlFakingHtml.java
import org.apache.ecs.*;
import org.apache.ecs.html.*;
/**
* Fake class, so that a document type can be set to wml
*/
public class WmlFakingHtml extends Html {
public WmlFakingHtml() {
setElementType("wml");
}
public WmlFakingHtml(String value) {
setElementType("wml");
addElement(value);
}
public WmlFakingHtml(Element value) {
setElementType("wml");
addElement(value);
}
}// WmlFakingHtml.java
// ---------------------------------------
// ---------------------------------------
// WapLayout.java
// Turbine Modules
import org.apache.turbine.modules.*;
import org.apache.turbine.util.*;
// ECS Classes
import org.apache.ecs.*;
import org.apache.ecs.wml.*;
import java.io.InputStream;
public class WapLayout extends Layout {
public void doBuild (RunData data) throws Exception {
// Create an instance of the WmlFakingHtml class,
// representing a <wml></wml> tag. This fakes a Html class for
unbeutiful
reasons
WmlFakingHtml wml = new WmlFakingHtml();
// If an Action has defined a message, attempt to display it here
if ( data.getMessage() != null ) {
System.out.println(data.getMessage());
/*
wml.addElement(new Card()
.addElement(new P()
.setAlignment(Alignment.CENTER)
.addElement(data.getMessage())
)
);
*/
}
// Now execute the Screen portion of the page
ConcreteElement screen = ScreenLoader.getInstance().eval ( data,
data.getScreen() );
wml.addElement(screen);
// Add the card to the rundata, and do all the unbeutiful fixes
doStupidWmlFix(data,wml);
}
/**
* A collection of unbeutiful code, needed to get the layout to output
legal wml.
*
* @param data The RunData object
* @param card This layout is a single card WML layout, and this is that
card
*/
private void doUnbeutifulWmlFix(RunData data, WmlFakingHtml wml) throws
Exception {
// Set the content type to the correct content type for wap:
data.setContentType("text/vnd.wap.wml");
// Output the required headers
data.getResponse().getWriter().println("<?xml version=\"1.0\"?>");
data.getResponse().getWriter().println("<!DOCTYPE wml PUBLIC
\"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">");
// This call is a big fake, possible ONLY because we extended the Html
class with the Wml class,
// thus making the Wml class an instance of the Html class.
Unbeutiful ,
but required,
// since the Document class assumes HTML syntax.
data.getPage().setHtml(wml);
}
}
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Rafal Krzewski
> Sent: 12. september 2000 17:20
> To: Turbine
> Subject: Re: WML?
>
>
> Chris Campbell wrote:
>
> > Turbine looks great guys - really impressed. Forgive me if I'm asking a
> > silly question, I'm new to this stuff and not finding an answer
> in the mail
> > archives. Is there a way to get Turbine and WebMacro to serve
> up wml instead
> > of html? There seems no obvious way to do this with the
> properties files. Is
> > there a preferred way to do this? Am I missing something in the
> > documentation?
>
> Theoreticly you should be able to do this with no problem: just
> define your
> wm templatest to output wml insted of html and you should be running.
> I know that there was an issue with WM that required some custom code for
> bypassing it: WebMacro always added a newline character before
> the contents
> of the parsed template. In WML, the very first line of the file must
> contain the <?xml version="1.0"?> processing instruction. My firend was
> trying to get this to the attention of Justin Wells for some time but
> to no avail. I don't know if this was fixed yet or not.
>
> Rafal
>
>
> ------------------------------------------------------------
> 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]