From: Keats <ke...@ea...> - 2003-08-15 17:14:54
|
Mostly out of curiosity, I implemented a TagLib for WM Script. It turned out to be quite simple. It's just a proof-of-concept at this point but I'll polish it up a bit. You just put the WM Script inside a wm:template tag. I expose the JSP PageContext as $Jsp. This is probably dangerous but it was a easy way to get access to all the JSP stuff. Ultimately I'd like to try and use other taglibs from within the WM Script. Here's a sample JSP: ======================================================= <%@ page session="true" buffer="none" %> <%@ taglib uri="/WEB-INF/wmtaglib.tld" prefix="wm" %> <html> <head> <title>wm:template test</title> </head> <body> <center>wm:template test</center> <br> <center>Time now: <%= new java.util.Date() %></center> <wm:template> <h3>Testing the WebMacro Template TagLib!</h3> #set $User="Keats" <p>Hello, $User</p> <p>JSP page Servlet class is $Jsp.Page.Class.Name<br> <p>JSP page ServletContext is $Jsp.Page.ServletContext<br> <p><b>JSP Page attributes</b></p> <ul> #foreach $attrib in $Jsp.getAttributeNamesInScope($Jsp.PAGE_SCOPE) <li>$attrib</li> #end </ul> <p><b>JSP Request attributes</b></p> <ul> #foreach $attrib in $Jsp.getAttributeNamesInScope($Jsp.REQUEST_SCOPE) <li>$attrib</li> #end </ul> <p><b>JSP Session attributes</b></p> <ul> #foreach $attrib in $Jsp.getAttributeNamesInScope($Jsp.SESSION_SCOPE) <li>$attrib</li> #end </ul> <p><b>JSP Application attributes</b></p> <ul> #foreach $attrib in $Jsp.getAttributeNamesInScope($Jsp.APPLICATION_SCOPE) <li>$attrib</li> #end </ul> </wm:template> </body> </html> ======================================================= Keats ----- Original Message ----- From: "Harmeet Bedi" <ha...@ko...> To: <ma...@an...>; <web...@li...> Sent: Monday, August 11, 2003 9:54 PM Subject: Re: [Webmacro-devel] JSP + WM together - interesting! > > ----- Original Message ----- > From: "Marc Palmer" <ma...@an...> > > > > > http://www.webmacro.org/UsingWebMacroWithJsp > > > > The example you give... doesn't it require a WMServlet to make it work? > > Sure, it does require webmacro templates to be exposed as servlet with it's > own URI. > > > > > I was thinking of a "pure JSP" solution where a JSP page is used to create > > an instance of WM and render templates, and this JSP is "called" from > other > > JSPs. > > I was trying to keep it separate at page level, but combined at runtime. > Would be good to add to Wiki the JSP/WM hybrid page ideas too. > > Harmeet > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 > _______________________________________________ > Webmacro-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-devel |