From: Marc P. <ma...@an...> - 2003-08-07 09:36:17
|
Hey, While supporting that guy with the #macro problem who mailed the team address, he's sent me a JSP file he is using to run WM! This is really quite simple but is quite amusing / useful as a migration tool or a way to get employers who want you to use JSP to let you use WM ;-) Here's his JSP - the way he is locating the template is unnecessarily obscure because he has put them into the app doc root: <%@ page import='org.webmacro.*,org.webmacro.servlet.WebContext,java.util.*' %><% WebMacro webMacro = null; Context context = null; Template template = null; try{ webMacro = new WM(); context = new Context(webMacro.getBroker()); String path = pageContext.getServletContext().getRealPath("") + java.io.File.separator + "MacroTestMain.html"; template = webMacro.getTemplate(path); } catch (Exception e){ e.printStackTrace(); } String htmlPath = pageContext.getServletContext().getRealPath(""); context.put("htmlPath",htmlPath); try{ out.print(template.evaluate(context)); } catch (Exception e) { e.printStackTrace(); } %> Anyway, this is quite interesting and may have some useful possibilities for WM, if shifted to an included JSP file so that you don't have to have this code in every JSP. Maybe someone who has real experience of JSP could write a page on this on the Wiki, and we could announce it in the next press release "A migration / co-existence path for JSP users". Marc -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Keats <ke...@ea...> - 2003-08-07 13:55:17
|
Even better would be a WebMacro TagLib: <wm:template> ## WebMacro script here ... </wm:template> We could even put the JspContext into the WM Context. Keats ----- Original Message ----- From: "Marc Palmer" <ma...@an...> To: <web...@li...> Sent: Thursday, August 07, 2003 5:34 AM Subject: [Webmacro-devel] JSP + WM together - interesting! > > Hey, > > While supporting that guy with the #macro problem who mailed the team > address, he's sent me a JSP file he is using to run WM! > > This is really quite simple but is quite amusing / useful as a migration > tool or a way to get employers who want you to use JSP to let you use WM ;-) > > Here's his JSP - the way he is locating the template is unnecessarily > obscure because he has put them into the app doc root: > > <%@ page > import='org.webmacro.*,org.webmacro.servlet.WebContext,java.util.*' %><% > > WebMacro webMacro = null; > Context context = null; > Template template = null; > try{ > webMacro = new WM(); > context = new Context(webMacro.getBroker()); > String path = pageContext.getServletContext().getRealPath("") + > java.io.File.separator + "MacroTestMain.html"; > template = webMacro.getTemplate(path); > } catch (Exception e){ > e.printStackTrace(); > } > String htmlPath = pageContext.getServletContext().getRealPath(""); > context.put("htmlPath",htmlPath); > > try{ > out.print(template.evaluate(context)); > } catch (Exception e) { > e.printStackTrace(); > } > %> > > Anyway, this is quite interesting and may have some useful possibilities > for WM, if shifted to an included JSP file so that you don't have to have > this code in every JSP. > > Maybe someone who has real experience of JSP could write a page on this on > the Wiki, and we could announce it in the next press release "A migration / > co-existence path for JSP users". > > Marc > > |
From: Harmeet B. <ha...@ko...> - 2003-08-08 03:09:17
|
I am pretty sure one could do this with jsp:include facility - Outer template asks servlet engine to process another template or servlet and include the result in calling template. One JSP file could include URL to a webmacro template. Would that not work ? It seems like an elegant way to integrate. Harmeet |
From: Lane S. <la...@op...> - 2003-08-08 03:45:37
|
If someone could write up and post a simple JSP page at http://www.webmacro.org/UsingWebMacroWithJsp that would be fantastic and I second the motion. Thankfully, I am completely ignorant of how to do this so I leave it to one of you JSP experts out there. Thanks! -Lane Harmeet Bedi wrote: >I am pretty sure one could do this with jsp:include facility - Outer >template >asks servlet engine to process another template or servlet and include >the result in calling template. >One JSP file could include URL to a webmacro template. > >Would that not work ? It seems like an elegant way to integrate. > >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 > > > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga |
From: Harmeet B. <ha...@ko...> - 2003-08-08 04:34:48
|
Did it. http://www.webmacro.org/UsingWebMacroWithJsp On first save attempt I got a number format exception. But the second try went through ok. Did not save the error message unfortunately. Also this page seems to have a deficiency. http://www.webmacro.org/AddNewContent It talks about edit, not adding new pages. Found that by guess work. It is http://www.webmacro.org/ControllerPage?edit=new_page_name. It would be cool, if there was a javascript page that prompted user to enter page name, validate it and generate appropriate URL. Harmeet ----- Original Message ----- From: "Lane Sharman" <la...@op...> > If someone could write up and post a simple JSP page at > http://www.webmacro.org/UsingWebMacroWithJsp |
From: Lane S. <la...@op...> - 2003-08-08 15:09:57
|
You are the man, Harmeet! Thanks for this invaluable web page addition. Feel free to go back and update it as new ideas come to mind. thanks again, Lane Harmeet Bedi wrote: >Did it. http://www.webmacro.org/UsingWebMacroWithJsp > >On first save attempt I got a number format exception. But the second try >went through ok. Did not save the error message unfortunately. > > >Also this page seems to have a deficiency. >http://www.webmacro.org/AddNewContent >It talks about edit, not adding new pages. Found that by guess work. It is >http://www.webmacro.org/ControllerPage?edit=new_page_name. It would be cool, >if there was a javascript page that prompted user to enter page name, >validate it and generate appropriate URL. > >Harmeet >----- Original Message ----- >From: "Lane Sharman" <la...@op...> > > > > >>If someone could write up and post a simple JSP page at >>http://www.webmacro.org/UsingWebMacroWithJsp >> >> > > > > >------------------------------------------------------- >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 > > > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga |
From: Marc P. <ma...@an...> - 2003-08-11 17:58:17
|
On Fri, 8 Aug 2003 00:35:14 -0400, Harmeet Bedi <ha...@ko...> wrote: > Did it. http://www.webmacro.org/UsingWebMacroWithJsp The example you give... doesn't it require a WMServlet to make it work? 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. Marc -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Harmeet B. <ha...@ko...> - 2003-08-12 02:12:37
|
----- 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 |
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 |
From: Lane S. <la...@op...> - 2003-08-15 18:13:20
|
cool. I suppose I should understand how JSP works one of these days :). Lane Keats wrote: >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 >> >> > > > >------------------------------------------------------- >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 > > > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga |
From: <web...@st...> - 2003-08-18 08:15:30
|
On Fri, 15 Aug 2003, Keats wrote: | 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. This looks extremely promising! Cool! Endre. |