(BI am looking at Struts + Cewolf combination as well.  I have successfully
(Bbuild a sample app.
(B
(BIn my sample, I have both of Struts' ActionServlet and the Cewolf Servlet
(Btogether. See my following web.xml fragment:
(B-----------------
(B<web-app>
(B    <!-- Action Servlet Configuration -->
(B    <servlet>
(B        <servlet-name>action</servlet-name>
(B
(B<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
(B        <init-param>
(B            <param-name>application</param-name>
(B            <param-value>resources.application</param-value>
(B        </init-param>
(B        <init-param>
(B            <param-name>config</param-name>
(B            <param-value>/WEB-INF/struts-config.xml</param-value>
(B        </init-param>
(B            [...]
(B    </servlet>
(B    <servlet>
(B        <servlet-name>CewolfServlet</servlet-name>
(B        <servlet-class>de.laures.cewolf.CewolfRenderer</servlet-class>
(B    </servlet>
(B    <!-- Action Servlet Mapping -->
(B    <servlet-mapping>
(B        <servlet-name>action</servlet-name>
(B        <url-pattern>*.do</url-pattern>
(B    </servlet-mapping>
(B    <servlet-mapping>
(B        <servlet-name>CewolfServlet</servlet-name>
(B        <url-pattern>/cewolf/*</url-pattern>
(B    </servlet-mapping>
(B    [...]
(B</web-app>
(B---------------------
(B
(BThe initial request from a web browser to a URL (.../anychart.do) will be
(Bcathed by the Struts' servlet, processed by your Action class, then the
(Bcontrol will be forwarded to a JSP where you code view design using
(BCewolf's custom tags (<cewolf:chart>. etc).
(B
(BThe internal processing behind the JSP will have two parts.
(B
(B(1) it will produce PNG graphics object, which will be temporarily cached
(Binto a application-scoped collection with 'jsessionid'. The PNG object will
(BNOT be immediatedly responded back to the browser.
(B
(B(2)it will produce a text/html stream, which will be immediately responded
(Bto the requesting browser. For example it will look somthing like:
(B----
(B<HTML>
(B<BODY>
(B    [....]
(B    <IMG BORDER="0" HEIGHT="300" WIDTH="300" ALT="" src
(B="cewolf;jsessionid=04D17456FD5B435B8D47E2384D0EDDEA?img
(B=-956198779&amp;width=300&amp;height=300&amp;iehack=.png">
(B </td>
(B</BODY>
(B</HTML>
(B----
(B
(BThe HTML contains a <img src="..."> tag. The URL of the img tag points to
(Bthe Cewolf Servlet (NOT to the Struts' ActionServlet). As soon as the
(Bbrowser receives the HTML and find the img tag, the browser fires the
(Bsecond HTTP GET request to Cewolf Servlet. The second HTTP GET will go to
(BCewolf Servlet.
(B The Cewolf Servlet will check the cache to find out a PNG graphics object
(Bto respond. The magic is that the src attribute of img tag will contain the
(BIdentification information which JSP has assigned and passed in order to
(Blet the Cewolf Servlet identify witch of the cached PNG object instance to
(Bbe sent back.
(B
(BSo, you do not have to mind having both of Struts' ActionServlet ant Cewolf
(BServlet together in you app. You really need them both.
(B
(B=============================================================================
(B
(BLet me add one point. I have experimentally developed a custom tag named
(B<cewolfxml:producer>.
(B
(BUsing this cutom tag, my example JSP looks like:
(B------------
(B<%@ page language="java" %>
(B<%@ page contentType="text/html; charset=UTF-8" %>
(B<cewolfxml:producer var="myBalance1"
(B    doc="${distribution_dom}" scope="page" type="pie"/>
(B<cewolfxml:producer var="myBalance2" type="pie">
(B    <PieDataset>
(B        <Item>
(B            <Key>Asset Class A</Key>
(B            <Value>63.2</Value>
(B        </Item>
(B        <Item>
(B            <Key>Asset Class B</Key>
(B            <Value>30.8</Value>
(B        </Item>
(B        <Item>
(B            <Key>Asset Class C</Key>
(B            <Value>6.0</Value>
(B        </Item>
(B    </PieDataset>
(B</cewolfxml:producer>
(B<html:html>
(B    <head>
(B        <title><bean:message key="title.welcome"/></title>
(B     </head>
(B     <body bgcolor="white">
(B<cewolf:chart id="myBalancePieChart" title="by scriptlet" type="pie">
(B    <cewolf:gradientpaint>
(B        <cewolf:point x="0" y="0" color="#FFFFFF" />
(B        <cewolf:point x="300" y="0" color="#DDDDFF" />
(B    </cewolf:gradientpaint>
(B    <cewolf:data>
(B        <cewolf:producer id="myBalance1" />
(B    </cewolf:data>
(B</cewolf:chart>
(B<cewolf:img chartid="myBalancePieChart" renderer="cewolf" width="200"
(Bheight="200"/>
(B
(B<cewolf:chart id="myBalancePieChart" title="by custom-tag" type="pie">
(B    <cewolf:gradientpaint>
(B        <cewolf:point x="0" y="0" color="#FFFFFF" />
(B        <cewolf:point x="300" y="0" color="#DDDDFF" />
(B    </cewolf:gradientpaint>
(B    <cewolf:data>
(B        <cewolf:producer id="myBalance2" />
(B    </cewolf:data>
(B </cewolf:chart>
(B<cewolf:img chartid="myBalancePieChart" renderer="cewolf" width="200"
(Bheight="200"/>
(B    </body>
(B</html:html>
(B-----------
(B
(BMy <cewolfxml:producer> tag understands EL to find out a XML data. Also it
(Bcan parse XML coded inline in the JSP (like JSTL's <x:parse> tag). Then
(B<cewolfxml:producer> will convert the given XML into a DatasetProducer
(Bobject which is expeced by the <cewolf:producer id="..."/> tag.
(B
(BThis  <cewolfxml:producer> tag much simplifies JSP codes. All you have to
(Bdo is to let your Struts' Action class to generate XML instance (containg
(Bdata as Model) and save it into the page scope, forward to a JSP where you
(Bconvert the XML into Cewolf-acceptable format, then you easily get the PNG
(Bgraphics by Cewolf's build in JSP custom tags.
(B
(B
(B
(B
(B                                                                                       
(B                            
(B                    Andrew                                                             
(B                            
(B                    Stepanenko              [EMAIL PROTECTED](B:   Struts Users 
(BMailing List <[EMAIL PROTECTED]>             
(B                    <[EMAIL PROTECTED]        cc:                                      
(B                              
(B                    ne.edu.ua>              $B7oL>(B:   Struts and Cewolf 
(Bintegration                                  
(B                                                                                       
(B                            
(B                    2004/11/04 18:15                                                   
(B                            
(B                    "Struts Users                                                      
(B                            
(B                    Mailing List" $B$X(B                                             
(B                                  
(B                    $BJV?.$7$F$/[EMAIL PROTECTED](B                                   
(B                                            
(B                                                                                       
(B                            
(B                                                                                       
(B                            
(B
(B
(B
(B
(BHello all!
(B
(BI have a webapp done with struts and I want to add some charts to it
(Bvia Cewolf and JFreeChart.
(B
(BBut to render images with cewolf you need to define a cewolf servlet in
(Bweb.xml. How
(Bcan this be done with struts if there is already the only servlet
(B(ActionServlet) defined in web.xml for struts to work and all requests
(Bshould go to that servlet?
(B
(BThanks in advance,
(BAndrew.
(B
(B
(B
(B
(B
(B---------------------------------------------------------------------
(BTo unsubscribe, e-mail: [EMAIL PROTECTED]
(BFor additional commands, e-mail: [EMAIL PROTECTED]
(B
(B
(B
(B
(B
(B
(B---------------------------------------------------------------------
(BTo unsubscribe, e-mail: [EMAIL PROTECTED]
(BFor additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to