You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leena Borle <ls...@gmail.com> on 2008/08/05 19:36:35 UTC

Re: Struts 2 And JFreeChart

Hello,
 See if this helps you.
 I have a form with remote DIV which displays chart after user clicks on
submit.
Trick here is to generate chart object, store it in session and display it
in separate JSP.   Remove the form part if you want to display just the
dynamic-DIV using Chart image.

Form.jsp [
        <s:form>
            <s:url id="display_chart" value="DrawChart_draw.action"
namespace="/user" />

            <s:submit value="Draw chart" href="%{display_chart}"
theme="ajax" targets="*chart_div*"  />
            <br />
         </s:form>

    <h4>Your Running Chart</h4>
        <div id="*chart_div*">
        </div>    <!-- End display chart -->
    </div>

]


display_chart.jsp [
<body>

     <img  src="/MyApp/user/DrawChart_display.action" alt="No Chart Image"
/>
</body>

]


struts.xml[
           <package name="user"  extends
="struts-default,jfreechart-default">
            <!--  Separate method to draw and  display due to Remote
DIV/Button tag contsraints.
             -->
            <action name="DrawChart_input" method="input"
class=".xxx.DrawChart">
                    <result name="input">form.jsp </result>
            </action>

            <action name="DrawChart_draw" method="draw"
class="xxx..DrawChart">
                    <result name="success">/jsp/display_chart.jsp </result>
            </action>
            <action name="DrawChart_display" method="display"
class="xxx.DrawChart">
                    <result name="success" type="chart">
                        <param name="width">400</param>
                        <param name="height">300</param>
                     </result>
            </action>

           </package>
]


DrawChart.java [
     JFreeChart chart;
    public String draw() throws Exception {
                 //chart creation logic.
              //generate chart object
              chart = ....
             session = ....
             session.put("CHART", chart);
            return success;
    }

    /**
     * returns chart obejct from the session.
       This methos is used by display_chart.jsp
    */
    public String display() throws Exception {
        session = ...get session ...
        this.chart = (JFreeChart) session.get("CHART");
        if(chart == null) {
            addActionError(getText("error.nochart"));
            return ERROR;
        }
        return SUCCESS;
    }

    // this method will get called if we specify <param
name="value">chart</param>
    public JFreeChart getChart() {
            return chart;
    }

    /**
     * <p> input action
     */
    public String input() throws Exception {
        return INPUT;
    }

]



Leena

RE: [OT] Re: Struts 2 And JFreeChart

Posted by Martin Gainty <mg...@hotmail.com>.
which version Jfreechart are you implementing?

Thanks,
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 


> Date: Thu, 21 Aug 2008 08:24:41 -0700
> From: newton.dave@yahoo.com
> Subject: [OT] Re: Struts 2 And JFreeChart
> To: user@struts.apache.org
> 
> --- On Thu, 8/21/08, Milan Milanovic wrote:
> > I don't understand this solution, what is "p" parameter, and 
> > whait is "RANDOM"?
> 
> This is a common technique to throw off caching mechanisms.
> 
> The "p" parameter is a dummy parameter that gets a random value so that when the submission is made, since the URL is changing due to the random parameter, it won't be cached.
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Talk to your Yahoo! Friends via Windows Live Messenger.  Find out how.
http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yahoo_082008

Re: [OT] Re: Struts 2 And JFreeChart

Posted by Dave Newton <ne...@yahoo.com>.
--- On Fri, 8/22/08, Milan Milanovic <mi...@yahoo.com> wrote:
> But if I don't have "p" property in my action
> class, I got warning in log ParamsPrepareParams setting String... 
> interceptor and so on?

...

So put a "p" parameter in your action.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: Struts 2 And JFreeChart

Posted by Milan Milanovic <mi...@yahoo.com>.
But if I don't have "p" property in my action class, I got warning in log
ParamsPrepareParams setting String... interceptor and so on ?

--
Milan

newton.dave wrote:
> 
>> do I need to have this "p" (String type)
>> parameter in my action class ?
> 
> No, it's there to create a unique URL, so it won't be cached.
> 
> Dave
> 
>> dynamicd wrote:
>> > 
>> > 
>> > its some parameter name (the name does not matter) and
>> RANDOM is set in
>> > the controller (Action)
>> > or to make it easy
>> > 
>> > img
>> src="/Dashboard/DisplayChart.action?p=<%=request.hashCode()%>"
>> /
>> > 
>> > instead of passing DisplayChart.action each time.
>> > it is passed in as a different url everytime and so it
>> will display the
>> > new image other wise if the url is the same then you
>> will get displayed
>> > the cached image. 
>> > 
>> > 
>> > 
>> > Milan Milanovic wrote:
>> >> 
>> >> I don't understand this solution, what is
>> "p" parameter, and whait is
>> >> "RANDOM" ?
>> >> 
>> >> 
>> >> --
>> >> Regards, Milan
>> >> 
>> >> 
>> >> dynamicd wrote:
>> >>> 
>> >>> 
>> >>> got it to work.. could not stop the caching so
>> added a param to the src
>> >>> 
>> >>> img
>> >>>
>> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
>> >>> /
>> >>> 
>> >>> 
>> >>> 
>> >>> dynamicd wrote:
>> >>>> 
>> >>>> I have tried 
>> >>>> <%
>> >>>>   
>> response.setHeader("Cache-Control",
>> "no-cache"); //HTTP 1.1
>> >>>>    response.setHeader("Pragma",
>> "no-cache"); //HTTP 1.0
>> >>>>   
>> response.setDateHeader("Expires", 0); //prevents
>> caching at the
>> >>>> proxy server
>> >>>> 
>> >>>> %>
>> >>>> 
>> >>>> as well..
>> >>>> 
>> >>>> 
>> >>>> 
>> >>>> newton.dave wrote:
>> >>>>> 
>> >>>>> --- On Wed, 8/6/08, dynamicd
>> <dh...@gmail.com> wrote:
>> >>>>>> Also tried implementing the
>> SessionAware. However the same thing.
>> >>>>> 
>> >>>>> Why?
>> >>>>> 
>> >>>>> Did you try setting the headers for
>> not caching?
>> >>>>> 
>> >>>>> Dave
>> >>>>> 
>> >>>>>> dynamicd wrote:
>> >>>>>> > 
>> >>>>>> > This is cool.. I tried it
>> out. However once the 
>> >>>>>> > chart_display.jsp is called
>> the first time through the
>> >>>>>> image tag. it does
>> >>>>>> > not call the
>> DisplayChart.action again to refresh the
>> >>>>>> image with a new one
>> >>>>>> > when clicked on the
>> DrawChart.action. (I added the
>> >>>>>> println statement in
>> >>>>>> > the display method to find
>> out that the div is not
>> >>>>>> refreshing)  I have to
>> >>>>>> > log out and log in
>> (invalidate session) to get the new
>> >>>>>> chart. I am missing
>> >>>>>> > something
>> >>>>>> > 
>> >>>>>> > 
>> >>>>>> > 	  
>> >>>>>> > 	  public String display()
>> throws Exception {
>> >>>>>> > 	     
>> System.out.println("I AM IN THE DISPLAY
>> >>>>>> NOW "); 
>> >>>>>> > 		    Map attributes =
>> >>>>>>
>> ActionContext.getContext().getSession();
>> >>>>>> > 	        this.chart =
>> (JFreeChart)
>> >>>>>> attributes.get("CHART");
>> >>>>>> > 	        
>> >>>>>> > 	        if(chart == null) {
>> >>>>>> > 	            return
>> Constants.FORWARD_INVALIDACTION;
>> >>>>>> > 	        }
>> >>>>>> > 	        return
>> Constants.FORWARD_SUCCESS;
>> >>>>>> > 	    } 
>> >>>>>> > 	  
>> >>>>>> > 	 
>> >>>>>> > 	 private void
>> setChart(JFreeChart chart){
>> >>>>>> > 		 Map attributes =
>> >>>>>>
>> ActionContext.getContext().getSession();
>> >>>>>> > 		
>> attributes.put("CHART", null);
>> >>>>>> > 		 this.chart = chart;
>> >>>>>> > 		
>> attributes.put("CHART", this.chart);
>> >>>>>> > 	 }
>> >>>>>> > 
>> >>>>>> > public JFreeChart getChart()
>> {
>> >>>>>> > 		return chart;
>> >>>>>> > 	}
>> >>>>>> > 
>> >>>>>> > 
>> >>>>>> > 
>> >>>>>> > Leena Borle wrote:
>> >>>>>> >> 
>> >>>>>> >> Hello,
>> >>>>>> >>  See if this helps you.
>> >>>>>> >>  I have a form with
>> remote DIV which displays
>> >>>>>> chart after user clicks on
>> >>>>>> >> submit.
>> >>>>>> >> Trick here is to generate
>> chart object, store it
>> >>>>>> in session and display
>> >>>>>> >> it
>> >>>>>> >> in separate JSP.   Remove
>> the form part if you
>> >>>>>> want to display just the
>> >>>>>> >> dynamic-DIV using Chart
>> image.
>> >>>>>> >> 
>> >>>>>> >> Form.jsp [
>> >>>>>> >>         <s:form>
>> >>>>>> >>             <s:url
>> id="display_chart"
>> >>>>>>
>> value="DrawChart_draw.action"
>> >>>>>> >>
>> namespace="/user" />
>> >>>>>> >> 
>> >>>>>> >>             <s:submit
>> value="Draw
>> >>>>>> chart"
>> href="%{display_chart}"
>> >>>>>> >> theme="ajax"
>> >>>>>> targets="*chart_div*" 
>> />
>> >>>>>> >>             <br />
>> >>>>>> >>          </s:form>
>> >>>>>> >> 
>> >>>>>> >>     <h4>Your
>> Running Chart</h4>
>> >>>>>> >>         <div
>> id="*chart_div*">
>> >>>>>> >>         </div>   
>> <!-- End display chart
>> >>>>>> -->
>> >>>>>> >>     </div>
>> >>>>>> >> 
>> >>>>>> >> ]
>> >>>>>> >> 
>> >>>>>> >> 
>> >>>>>> >> display_chart.jsp [
>> >>>>>> >> <body>
>> >>>>>> >> 
>> >>>>>> >>      
>> /MyApp/user/DrawChart_display.action 
>> >>>>>> >> </body>
>> >>>>>> >> 
>> >>>>>> >> ]
>> >>>>>> >> 
>> >>>>>> >> 
>> >>>>>> >> struts.xml[
>> >>>>>> >>            <package
>> name="user" 
>> >>>>>> extends
>> >>>>>> >>
>> ="struts-default,jfreechart-default">
>> >>>>>> >>             <!-- 
>> Separate method to draw and 
>> >>>>>> display due to Remote
>> >>>>>> >> DIV/Button tag
>> contsraints.
>> >>>>>> >>              -->
>> >>>>>> >>             <action
>> >>>>>> name="DrawChart_input"
>> method="input"
>> >>>>>> >>
>> class=".xxx.DrawChart">
>> >>>>>> >>                    
>> <result
>> >>>>>> name="input">form.jsp
>> </result>
>> >>>>>> >>            
>> </action>
>> >>>>>> >> 
>> >>>>>> >>             <action
>> >>>>>> name="DrawChart_draw"
>> method="draw"
>> >>>>>> >>
>> class="xxx..DrawChart">
>> >>>>>> >>                    
>> <result
>> >>>>>>
>> name="success">/jsp/display_chart.jsp
>> >>>>>> >> </result>
>> >>>>>> >>            
>> </action>
>> >>>>>> >>             <action
>> >>>>>> name="DrawChart_display"
>> >>>>>> method="display"
>> >>>>>> >>
>> class="xxx.DrawChart">
>> >>>>>> >>                    
>> <result
>> >>>>>> name="success"
>> type="chart">
>> >>>>>> >>                        
>> 400
>> >>>>>> >>                        
>> 300
>> >>>>>> >>                     
>> </result>
>> >>>>>> >>            
>> </action>
>> >>>>>> >> 
>> >>>>>> >>           
>> </package>
>> >>>>>> >> ]
>> >>>>>> >> 
>> >>>>>> >> 
>> >>>>>> >> DrawChart.java [
>> >>>>>> >>      JFreeChart chart;
>> >>>>>> >>     public String draw()
>> throws Exception {
>> >>>>>> >>                  //chart
>> creation logic.
>> >>>>>> >>               //generate
>> chart object
>> >>>>>> >>               chart =
>> ....
>> >>>>>> >>              session =
>> ....
>> >>>>>> >>             
>> session.put("CHART",
>> >>>>>> chart);
>> >>>>>> >>             return
>> success;
>> >>>>>> >>     }
>> >>>>>> >> 
>> >>>>>> >>     /**
>> >>>>>> >>      * returns chart
>> obejct from the session.
>> >>>>>> >>        This methos is
>> used by display_chart.jsp
>> >>>>>> >>     */
>> >>>>>> >>     public String
>> display() throws Exception {
>> >>>>>> >>         session = ...get
>> session ...
>> >>>>>> >>         this.chart =
>> (JFreeChart)
>> >>>>>> session.get("CHART");
>> >>>>>> >>         if(chart == null)
>> {
>> >>>>>> >>            
>> >>>>>>
>> addActionError(getText("error.nochart"));
>> >>>>>> >>             return ERROR;
>> >>>>>> >>         }
>> >>>>>> >>         return SUCCESS;
>> >>>>>> >>     }
>> >>>>>> >> 
>> >>>>>> >>     // this method will
>> get called if we specify
>> >>>>>> chart
>> >>>>>> >>     public JFreeChart
>> getChart() {
>> >>>>>> >>             return chart;
>> >>>>>> >>     }
>> >>>>>> >> 
>> >>>>>> >>     /**
>> >>>>>> >>      * <p> input
>> action
>> >>>>>> >>      */
>> >>>>>> >>     public String input()
>> throws Exception {
>> >>>>>> >>         return INPUT;
>> >>>>>> >>     }
>> >>>>>> >> 
>> >>>>>> >> ]
>> >>>>> 
>> >>>>> 
>> >>>>>
>> ---------------------------------------------------------------------
>> >>>>> To unsubscribe, e-mail:
>> user-unsubscribe@struts.apache.org
>> >>>>> For additional commands, e-mail:
>> user-help@struts.apache.org
>> >>>>> 
>> >>>>> 
>> >>>>> 
>> >>>> 
>> >>>> 
>> >>> 
>> >>> 
>> >> 
>> >> 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19091326.html
>> Sent from the Struts - User mailing list archive at
>> Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail:
>> user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19115856.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: Struts 2 And JFreeChart

Posted by Dave Newton <ne...@yahoo.com>.
> do I need to have this "p" (String type)
> parameter in my action class ?

No, it's there to create a unique URL, so it won't be cached.

Dave

> dynamicd wrote:
> > 
> > 
> > its some parameter name (the name does not matter) and
> RANDOM is set in
> > the controller (Action)
> > or to make it easy
> > 
> > img
> src="/Dashboard/DisplayChart.action?p=<%=request.hashCode()%>"
> /
> > 
> > instead of passing DisplayChart.action each time.
> > it is passed in as a different url everytime and so it
> will display the
> > new image other wise if the url is the same then you
> will get displayed
> > the cached image. 
> > 
> > 
> > 
> > Milan Milanovic wrote:
> >> 
> >> I don't understand this solution, what is
> "p" parameter, and whait is
> >> "RANDOM" ?
> >> 
> >> 
> >> --
> >> Regards, Milan
> >> 
> >> 
> >> dynamicd wrote:
> >>> 
> >>> 
> >>> got it to work.. could not stop the caching so
> added a param to the src
> >>> 
> >>> img
> >>>
> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
> >>> /
> >>> 
> >>> 
> >>> 
> >>> dynamicd wrote:
> >>>> 
> >>>> I have tried 
> >>>> <%
> >>>>   
> response.setHeader("Cache-Control",
> "no-cache"); //HTTP 1.1
> >>>>    response.setHeader("Pragma",
> "no-cache"); //HTTP 1.0
> >>>>   
> response.setDateHeader("Expires", 0); //prevents
> caching at the
> >>>> proxy server
> >>>> 
> >>>> %>
> >>>> 
> >>>> as well..
> >>>> 
> >>>> 
> >>>> 
> >>>> newton.dave wrote:
> >>>>> 
> >>>>> --- On Wed, 8/6/08, dynamicd
> <dh...@gmail.com> wrote:
> >>>>>> Also tried implementing the
> SessionAware. However the same thing.
> >>>>> 
> >>>>> Why?
> >>>>> 
> >>>>> Did you try setting the headers for
> not caching?
> >>>>> 
> >>>>> Dave
> >>>>> 
> >>>>>> dynamicd wrote:
> >>>>>> > 
> >>>>>> > This is cool.. I tried it
> out. However once the 
> >>>>>> > chart_display.jsp is called
> the first time through the
> >>>>>> image tag. it does
> >>>>>> > not call the
> DisplayChart.action again to refresh the
> >>>>>> image with a new one
> >>>>>> > when clicked on the
> DrawChart.action. (I added the
> >>>>>> println statement in
> >>>>>> > the display method to find
> out that the div is not
> >>>>>> refreshing)  I have to
> >>>>>> > log out and log in
> (invalidate session) to get the new
> >>>>>> chart. I am missing
> >>>>>> > something
> >>>>>> > 
> >>>>>> > 
> >>>>>> > 	  
> >>>>>> > 	  public String display()
> throws Exception {
> >>>>>> > 	     
> System.out.println("I AM IN THE DISPLAY
> >>>>>> NOW "); 
> >>>>>> > 		    Map attributes =
> >>>>>>
> ActionContext.getContext().getSession();
> >>>>>> > 	        this.chart =
> (JFreeChart)
> >>>>>> attributes.get("CHART");
> >>>>>> > 	        
> >>>>>> > 	        if(chart == null) {
> >>>>>> > 	            return
> Constants.FORWARD_INVALIDACTION;
> >>>>>> > 	        }
> >>>>>> > 	        return
> Constants.FORWARD_SUCCESS;
> >>>>>> > 	    } 
> >>>>>> > 	  
> >>>>>> > 	 
> >>>>>> > 	 private void
> setChart(JFreeChart chart){
> >>>>>> > 		 Map attributes =
> >>>>>>
> ActionContext.getContext().getSession();
> >>>>>> > 		
> attributes.put("CHART", null);
> >>>>>> > 		 this.chart = chart;
> >>>>>> > 		
> attributes.put("CHART", this.chart);
> >>>>>> > 	 }
> >>>>>> > 
> >>>>>> > public JFreeChart getChart()
> {
> >>>>>> > 		return chart;
> >>>>>> > 	}
> >>>>>> > 
> >>>>>> > 
> >>>>>> > 
> >>>>>> > Leena Borle wrote:
> >>>>>> >> 
> >>>>>> >> Hello,
> >>>>>> >>  See if this helps you.
> >>>>>> >>  I have a form with
> remote DIV which displays
> >>>>>> chart after user clicks on
> >>>>>> >> submit.
> >>>>>> >> Trick here is to generate
> chart object, store it
> >>>>>> in session and display
> >>>>>> >> it
> >>>>>> >> in separate JSP.   Remove
> the form part if you
> >>>>>> want to display just the
> >>>>>> >> dynamic-DIV using Chart
> image.
> >>>>>> >> 
> >>>>>> >> Form.jsp [
> >>>>>> >>         <s:form>
> >>>>>> >>             <s:url
> id="display_chart"
> >>>>>>
> value="DrawChart_draw.action"
> >>>>>> >>
> namespace="/user" />
> >>>>>> >> 
> >>>>>> >>             <s:submit
> value="Draw
> >>>>>> chart"
> href="%{display_chart}"
> >>>>>> >> theme="ajax"
> >>>>>> targets="*chart_div*" 
> />
> >>>>>> >>             <br />
> >>>>>> >>          </s:form>
> >>>>>> >> 
> >>>>>> >>     <h4>Your
> Running Chart</h4>
> >>>>>> >>         <div
> id="*chart_div*">
> >>>>>> >>         </div>   
> <!-- End display chart
> >>>>>> -->
> >>>>>> >>     </div>
> >>>>>> >> 
> >>>>>> >> ]
> >>>>>> >> 
> >>>>>> >> 
> >>>>>> >> display_chart.jsp [
> >>>>>> >> <body>
> >>>>>> >> 
> >>>>>> >>      
> /MyApp/user/DrawChart_display.action 
> >>>>>> >> </body>
> >>>>>> >> 
> >>>>>> >> ]
> >>>>>> >> 
> >>>>>> >> 
> >>>>>> >> struts.xml[
> >>>>>> >>            <package
> name="user" 
> >>>>>> extends
> >>>>>> >>
> ="struts-default,jfreechart-default">
> >>>>>> >>             <!-- 
> Separate method to draw and 
> >>>>>> display due to Remote
> >>>>>> >> DIV/Button tag
> contsraints.
> >>>>>> >>              -->
> >>>>>> >>             <action
> >>>>>> name="DrawChart_input"
> method="input"
> >>>>>> >>
> class=".xxx.DrawChart">
> >>>>>> >>                    
> <result
> >>>>>> name="input">form.jsp
> </result>
> >>>>>> >>            
> </action>
> >>>>>> >> 
> >>>>>> >>             <action
> >>>>>> name="DrawChart_draw"
> method="draw"
> >>>>>> >>
> class="xxx..DrawChart">
> >>>>>> >>                    
> <result
> >>>>>>
> name="success">/jsp/display_chart.jsp
> >>>>>> >> </result>
> >>>>>> >>            
> </action>
> >>>>>> >>             <action
> >>>>>> name="DrawChart_display"
> >>>>>> method="display"
> >>>>>> >>
> class="xxx.DrawChart">
> >>>>>> >>                    
> <result
> >>>>>> name="success"
> type="chart">
> >>>>>> >>                        
> 400
> >>>>>> >>                        
> 300
> >>>>>> >>                     
> </result>
> >>>>>> >>            
> </action>
> >>>>>> >> 
> >>>>>> >>           
> </package>
> >>>>>> >> ]
> >>>>>> >> 
> >>>>>> >> 
> >>>>>> >> DrawChart.java [
> >>>>>> >>      JFreeChart chart;
> >>>>>> >>     public String draw()
> throws Exception {
> >>>>>> >>                  //chart
> creation logic.
> >>>>>> >>               //generate
> chart object
> >>>>>> >>               chart =
> ....
> >>>>>> >>              session =
> ....
> >>>>>> >>             
> session.put("CHART",
> >>>>>> chart);
> >>>>>> >>             return
> success;
> >>>>>> >>     }
> >>>>>> >> 
> >>>>>> >>     /**
> >>>>>> >>      * returns chart
> obejct from the session.
> >>>>>> >>        This methos is
> used by display_chart.jsp
> >>>>>> >>     */
> >>>>>> >>     public String
> display() throws Exception {
> >>>>>> >>         session = ...get
> session ...
> >>>>>> >>         this.chart =
> (JFreeChart)
> >>>>>> session.get("CHART");
> >>>>>> >>         if(chart == null)
> {
> >>>>>> >>            
> >>>>>>
> addActionError(getText("error.nochart"));
> >>>>>> >>             return ERROR;
> >>>>>> >>         }
> >>>>>> >>         return SUCCESS;
> >>>>>> >>     }
> >>>>>> >> 
> >>>>>> >>     // this method will
> get called if we specify
> >>>>>> chart
> >>>>>> >>     public JFreeChart
> getChart() {
> >>>>>> >>             return chart;
> >>>>>> >>     }
> >>>>>> >> 
> >>>>>> >>     /**
> >>>>>> >>      * <p> input
> action
> >>>>>> >>      */
> >>>>>> >>     public String input()
> throws Exception {
> >>>>>> >>         return INPUT;
> >>>>>> >>     }
> >>>>>> >> 
> >>>>>> >> ]
> >>>>> 
> >>>>> 
> >>>>>
> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> >>>>> For additional commands, e-mail:
> user-help@struts.apache.org
> >>>>> 
> >>>>> 
> >>>>> 
> >>>> 
> >>>> 
> >>> 
> >>> 
> >> 
> >> 
> > 
> > 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19091326.html
> Sent from the Struts - User mailing list archive at
> Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.

No




Milan Milanovic wrote:
> 
> Hi,
> 
> do I need to have this "p" (String type) parameter in my action class ?
> 
> --
> Thx, Milan
> 
> 
> dynamicd wrote:
>> 
>> 
>> its some parameter name (the name does not matter) and RANDOM is set in
>> the controller (Action)
>> or to make it easy
>> 
>> img src="/Dashboard/DisplayChart.action?p=<%=request.hashCode()%>" /
>> 
>> instead of passing DisplayChart.action each time.
>> it is passed in as a different url everytime and so it will display the
>> new image other wise if the url is the same then you will get displayed
>> the cached image. 
>> 
>> 
>> 
>> Milan Milanovic wrote:
>>> 
>>> I don't understand this solution, what is "p" parameter, and whait is
>>> "RANDOM" ?
>>> 
>>> 
>>> --
>>> Regards, Milan
>>> 
>>> 
>>> dynamicd wrote:
>>>> 
>>>> 
>>>> got it to work.. could not stop the caching so added a param to the src
>>>> 
>>>> img
>>>> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
>>>> /
>>>> 
>>>> 
>>>> 
>>>> dynamicd wrote:
>>>>> 
>>>>> I have tried 
>>>>> <%
>>>>>    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
>>>>>    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
>>>>>    response.setDateHeader("Expires", 0); //prevents caching at the
>>>>> proxy server
>>>>> 
>>>>> %>
>>>>> 
>>>>> as well..
>>>>> 
>>>>> 
>>>>> 
>>>>> newton.dave wrote:
>>>>>> 
>>>>>> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>>>>>>> Also tried implementing the SessionAware. However the same thing.
>>>>>> 
>>>>>> Why?
>>>>>> 
>>>>>> Did you try setting the headers for not caching?
>>>>>> 
>>>>>> Dave
>>>>>> 
>>>>>>> dynamicd wrote:
>>>>>>> > 
>>>>>>> > This is cool.. I tried it out. However once the 
>>>>>>> > chart_display.jsp is called the first time through the
>>>>>>> image tag. it does
>>>>>>> > not call the DisplayChart.action again to refresh the
>>>>>>> image with a new one
>>>>>>> > when clicked on the DrawChart.action. (I added the
>>>>>>> println statement in
>>>>>>> > the display method to find out that the div is not
>>>>>>> refreshing)  I have to
>>>>>>> > log out and log in (invalidate session) to get the new
>>>>>>> chart. I am missing
>>>>>>> > something
>>>>>>> > 
>>>>>>> > 
>>>>>>> > 	  
>>>>>>> > 	  public String display() throws Exception {
>>>>>>> > 	      System.out.println("I AM IN THE DISPLAY
>>>>>>> NOW "); 
>>>>>>> > 		    Map attributes =
>>>>>>> ActionContext.getContext().getSession();
>>>>>>> > 	        this.chart = (JFreeChart)
>>>>>>> attributes.get("CHART");
>>>>>>> > 	        
>>>>>>> > 	        if(chart == null) {
>>>>>>> > 	            return Constants.FORWARD_INVALIDACTION;
>>>>>>> > 	        }
>>>>>>> > 	        return Constants.FORWARD_SUCCESS;
>>>>>>> > 	    } 
>>>>>>> > 	  
>>>>>>> > 	 
>>>>>>> > 	 private void setChart(JFreeChart chart){
>>>>>>> > 		 Map attributes =
>>>>>>> ActionContext.getContext().getSession();
>>>>>>> > 		 attributes.put("CHART", null);
>>>>>>> > 		 this.chart = chart;
>>>>>>> > 		 attributes.put("CHART", this.chart);
>>>>>>> > 	 }
>>>>>>> > 
>>>>>>> > public JFreeChart getChart() {
>>>>>>> > 		return chart;
>>>>>>> > 	}
>>>>>>> > 
>>>>>>> > 
>>>>>>> > 
>>>>>>> > Leena Borle wrote:
>>>>>>> >> 
>>>>>>> >> Hello,
>>>>>>> >>  See if this helps you.
>>>>>>> >>  I have a form with remote DIV which displays
>>>>>>> chart after user clicks on
>>>>>>> >> submit.
>>>>>>> >> Trick here is to generate chart object, store it
>>>>>>> in session and display
>>>>>>> >> it
>>>>>>> >> in separate JSP.   Remove the form part if you
>>>>>>> want to display just the
>>>>>>> >> dynamic-DIV using Chart image.
>>>>>>> >> 
>>>>>>> >> Form.jsp [
>>>>>>> >>         <s:form>
>>>>>>> >>             <s:url id="display_chart"
>>>>>>> value="DrawChart_draw.action"
>>>>>>> >> namespace="/user" />
>>>>>>> >> 
>>>>>>> >>             <s:submit value="Draw
>>>>>>> chart" href="%{display_chart}"
>>>>>>> >> theme="ajax"
>>>>>>> targets="*chart_div*"  />
>>>>>>> >>             <br />
>>>>>>> >>          </s:form>
>>>>>>> >> 
>>>>>>> >>     <h4>Your Running Chart</h4>
>>>>>>> >>         <div id="*chart_div*">
>>>>>>> >>         </div>    <!-- End display chart
>>>>>>> -->
>>>>>>> >>     </div>
>>>>>>> >> 
>>>>>>> >> ]
>>>>>>> >> 
>>>>>>> >> 
>>>>>>> >> display_chart.jsp [
>>>>>>> >> <body>
>>>>>>> >> 
>>>>>>> >>       /MyApp/user/DrawChart_display.action 
>>>>>>> >> </body>
>>>>>>> >> 
>>>>>>> >> ]
>>>>>>> >> 
>>>>>>> >> 
>>>>>>> >> struts.xml[
>>>>>>> >>            <package name="user" 
>>>>>>> extends
>>>>>>> >> ="struts-default,jfreechart-default">
>>>>>>> >>             <!--  Separate method to draw and 
>>>>>>> display due to Remote
>>>>>>> >> DIV/Button tag contsraints.
>>>>>>> >>              -->
>>>>>>> >>             <action
>>>>>>> name="DrawChart_input" method="input"
>>>>>>> >> class=".xxx.DrawChart">
>>>>>>> >>                     <result
>>>>>>> name="input">form.jsp </result>
>>>>>>> >>             </action>
>>>>>>> >> 
>>>>>>> >>             <action
>>>>>>> name="DrawChart_draw" method="draw"
>>>>>> 
>>>>>>> >> class="xxx..DrawChart">
>>>>>>> >>                     <result
>>>>>>> name="success">/jsp/display_chart.jsp
>>>>>>> >> </result>
>>>>>>> >>             </action>
>>>>>>> >>             <action
>>>>>>> name="DrawChart_display"
>>>>>>> method="display"
>>>>>>> >> class="xxx.DrawChart">
>>>>>>> >>                     <result
>>>>>>> name="success" type="chart">
>>>>>>> >>                         400
>>>>>>> >>                         300
>>>>>>> >>                      </result>
>>>>>>> >>             </action>
>>>>>>> >> 
>>>>>>> >>            </package>
>>>>>>> >> ]
>>>>>>> >> 
>>>>>>> >> 
>>>>>>> >> DrawChart.java [
>>>>>>> >>      JFreeChart chart;
>>>>>>> >>     public String draw() throws Exception {
>>>>>>> >>                  //chart creation logic.
>>>>>>> >>               //generate chart object
>>>>>>> >>               chart = ....
>>>>>>> >>              session = ....
>>>>>>> >>              session.put("CHART",
>>>>>>> chart);
>>>>>>> >>             return success;
>>>>>>> >>     }
>>>>>>> >> 
>>>>>>> >>     /**
>>>>>>> >>      * returns chart obejct from the session.
>>>>>>> >>        This methos is used by display_chart.jsp
>>>>>>> >>     */
>>>>>>> >>     public String display() throws Exception {
>>>>>>> >>         session = ...get session ...
>>>>>>> >>         this.chart = (JFreeChart)
>>>>>>> session.get("CHART");
>>>>>>> >>         if(chart == null) {
>>>>>>> >>            
>>>>>>> addActionError(getText("error.nochart"));
>>>>>>> >>             return ERROR;
>>>>>>> >>         }
>>>>>>> >>         return SUCCESS;
>>>>>>> >>     }
>>>>>>> >> 
>>>>>>> >>     // this method will get called if we specify
>>>>>>> chart
>>>>>>> >>     public JFreeChart getChart() {
>>>>>>> >>             return chart;
>>>>>>> >>     }
>>>>>>> >> 
>>>>>>> >>     /**
>>>>>>> >>      * <p> input action
>>>>>>> >>      */
>>>>>>> >>     public String input() throws Exception {
>>>>>>> >>         return INPUT;
>>>>>>> >>     }
>>>>>>> >> 
>>>>>>> >> ]
>>>>>> 
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19108062.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi,

do I need to have this "p" (String type) parameter in my action class ?

--
Thx, Milan


dynamicd wrote:
> 
> 
> its some parameter name (the name does not matter) and RANDOM is set in
> the controller (Action)
> or to make it easy
> 
> img src="/Dashboard/DisplayChart.action?p=<%=request.hashCode()%>" /
> 
> instead of passing DisplayChart.action each time.
> it is passed in as a different url everytime and so it will display the
> new image other wise if the url is the same then you will get displayed
> the cached image. 
> 
> 
> 
> Milan Milanovic wrote:
>> 
>> I don't understand this solution, what is "p" parameter, and whait is
>> "RANDOM" ?
>> 
>> 
>> --
>> Regards, Milan
>> 
>> 
>> dynamicd wrote:
>>> 
>>> 
>>> got it to work.. could not stop the caching so added a param to the src
>>> 
>>> img
>>> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
>>> /
>>> 
>>> 
>>> 
>>> dynamicd wrote:
>>>> 
>>>> I have tried 
>>>> <%
>>>>    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
>>>>    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
>>>>    response.setDateHeader("Expires", 0); //prevents caching at the
>>>> proxy server
>>>> 
>>>> %>
>>>> 
>>>> as well..
>>>> 
>>>> 
>>>> 
>>>> newton.dave wrote:
>>>>> 
>>>>> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>>>>>> Also tried implementing the SessionAware. However the same thing.
>>>>> 
>>>>> Why?
>>>>> 
>>>>> Did you try setting the headers for not caching?
>>>>> 
>>>>> Dave
>>>>> 
>>>>>> dynamicd wrote:
>>>>>> > 
>>>>>> > This is cool.. I tried it out. However once the 
>>>>>> > chart_display.jsp is called the first time through the
>>>>>> image tag. it does
>>>>>> > not call the DisplayChart.action again to refresh the
>>>>>> image with a new one
>>>>>> > when clicked on the DrawChart.action. (I added the
>>>>>> println statement in
>>>>>> > the display method to find out that the div is not
>>>>>> refreshing)  I have to
>>>>>> > log out and log in (invalidate session) to get the new
>>>>>> chart. I am missing
>>>>>> > something
>>>>>> > 
>>>>>> > 
>>>>>> > 	  
>>>>>> > 	  public String display() throws Exception {
>>>>>> > 	      System.out.println("I AM IN THE DISPLAY
>>>>>> NOW "); 
>>>>>> > 		    Map attributes =
>>>>>> ActionContext.getContext().getSession();
>>>>>> > 	        this.chart = (JFreeChart)
>>>>>> attributes.get("CHART");
>>>>>> > 	        
>>>>>> > 	        if(chart == null) {
>>>>>> > 	            return Constants.FORWARD_INVALIDACTION;
>>>>>> > 	        }
>>>>>> > 	        return Constants.FORWARD_SUCCESS;
>>>>>> > 	    } 
>>>>>> > 	  
>>>>>> > 	 
>>>>>> > 	 private void setChart(JFreeChart chart){
>>>>>> > 		 Map attributes =
>>>>>> ActionContext.getContext().getSession();
>>>>>> > 		 attributes.put("CHART", null);
>>>>>> > 		 this.chart = chart;
>>>>>> > 		 attributes.put("CHART", this.chart);
>>>>>> > 	 }
>>>>>> > 
>>>>>> > public JFreeChart getChart() {
>>>>>> > 		return chart;
>>>>>> > 	}
>>>>>> > 
>>>>>> > 
>>>>>> > 
>>>>>> > Leena Borle wrote:
>>>>>> >> 
>>>>>> >> Hello,
>>>>>> >>  See if this helps you.
>>>>>> >>  I have a form with remote DIV which displays
>>>>>> chart after user clicks on
>>>>>> >> submit.
>>>>>> >> Trick here is to generate chart object, store it
>>>>>> in session and display
>>>>>> >> it
>>>>>> >> in separate JSP.   Remove the form part if you
>>>>>> want to display just the
>>>>>> >> dynamic-DIV using Chart image.
>>>>>> >> 
>>>>>> >> Form.jsp [
>>>>>> >>         <s:form>
>>>>>> >>             <s:url id="display_chart"
>>>>>> value="DrawChart_draw.action"
>>>>>> >> namespace="/user" />
>>>>>> >> 
>>>>>> >>             <s:submit value="Draw
>>>>>> chart" href="%{display_chart}"
>>>>>> >> theme="ajax"
>>>>>> targets="*chart_div*"  />
>>>>>> >>             <br />
>>>>>> >>          </s:form>
>>>>>> >> 
>>>>>> >>     <h4>Your Running Chart</h4>
>>>>>> >>         <div id="*chart_div*">
>>>>>> >>         </div>    <!-- End display chart
>>>>>> -->
>>>>>> >>     </div>
>>>>>> >> 
>>>>>> >> ]
>>>>>> >> 
>>>>>> >> 
>>>>>> >> display_chart.jsp [
>>>>>> >> <body>
>>>>>> >> 
>>>>>> >>       /MyApp/user/DrawChart_display.action 
>>>>>> >> </body>
>>>>>> >> 
>>>>>> >> ]
>>>>>> >> 
>>>>>> >> 
>>>>>> >> struts.xml[
>>>>>> >>            <package name="user" 
>>>>>> extends
>>>>>> >> ="struts-default,jfreechart-default">
>>>>>> >>             <!--  Separate method to draw and 
>>>>>> display due to Remote
>>>>>> >> DIV/Button tag contsraints.
>>>>>> >>              -->
>>>>>> >>             <action
>>>>>> name="DrawChart_input" method="input"
>>>>>> >> class=".xxx.DrawChart">
>>>>>> >>                     <result
>>>>>> name="input">form.jsp </result>
>>>>>> >>             </action>
>>>>>> >> 
>>>>>> >>             <action
>>>>>> name="DrawChart_draw" method="draw"
>>>>>> >> class="xxx..DrawChart">
>>>>>> >>                     <result
>>>>>> name="success">/jsp/display_chart.jsp
>>>>>> >> </result>
>>>>>> >>             </action>
>>>>>> >>             <action
>>>>>> name="DrawChart_display"
>>>>>> method="display"
>>>>>> >> class="xxx.DrawChart">
>>>>>> >>                     <result
>>>>>> name="success" type="chart">
>>>>>> >>                         400
>>>>>> >>                         300
>>>>>> >>                      </result>
>>>>>> >>             </action>
>>>>>> >> 
>>>>>> >>            </package>
>>>>>> >> ]
>>>>>> >> 
>>>>>> >> 
>>>>>> >> DrawChart.java [
>>>>>> >>      JFreeChart chart;
>>>>>> >>     public String draw() throws Exception {
>>>>>> >>                  //chart creation logic.
>>>>>> >>               //generate chart object
>>>>>> >>               chart = ....
>>>>>> >>              session = ....
>>>>>> >>              session.put("CHART",
>>>>>> chart);
>>>>>> >>             return success;
>>>>>> >>     }
>>>>>> >> 
>>>>>> >>     /**
>>>>>> >>      * returns chart obejct from the session.
>>>>>> >>        This methos is used by display_chart.jsp
>>>>>> >>     */
>>>>>> >>     public String display() throws Exception {
>>>>>> >>         session = ...get session ...
>>>>>> >>         this.chart = (JFreeChart)
>>>>>> session.get("CHART");
>>>>>> >>         if(chart == null) {
>>>>>> >>            
>>>>>> addActionError(getText("error.nochart"));
>>>>>> >>             return ERROR;
>>>>>> >>         }
>>>>>> >>         return SUCCESS;
>>>>>> >>     }
>>>>>> >> 
>>>>>> >>     // this method will get called if we specify
>>>>>> chart
>>>>>> >>     public JFreeChart getChart() {
>>>>>> >>             return chart;
>>>>>> >>     }
>>>>>> >> 
>>>>>> >>     /**
>>>>>> >>      * <p> input action
>>>>>> >>      */
>>>>>> >>     public String input() throws Exception {
>>>>>> >>         return INPUT;
>>>>>> >>     }
>>>>>> >> 
>>>>>> >> ]
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19091326.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.

its some parameter name (the name does not matter) and RANDOM is set in the
controller (Action)
or to make it easy

img src="/Dashboard/DisplayChart.action?p=<%=request.hashCode()%>" /

instead of passing DisplayChart.action each time.
it is passed in as a different url everytime and so it will display the new
image other wise if the url is the same then you will get displayed the
cached image. 



Milan Milanovic wrote:
> 
> I don't understand this solution, what is "p" parameter, and whait is
> "RANDOM" ?
> 
> 
> --
> Regards, Milan
> 
> 
> dynamicd wrote:
>> 
>> 
>> got it to work.. could not stop the caching so added a param to the src
>> 
>> img
>> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
>> /
>> 
>> 
>> 
>> dynamicd wrote:
>>> 
>>> I have tried 
>>> <%
>>>    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
>>>    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
>>>    response.setDateHeader("Expires", 0); //prevents caching at the proxy
>>> server
>>> 
>>> %>
>>> 
>>> as well..
>>> 
>>> 
>>> 
>>> newton.dave wrote:
>>>> 
>>>> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>>>>> Also tried implementing the SessionAware. However the same thing.
>>>> 
>>>> Why?
>>>> 
>>>> Did you try setting the headers for not caching?
>>>> 
>>>> Dave
>>>> 
>>>>> dynamicd wrote:
>>>>> > 
>>>>> > This is cool.. I tried it out. However once the 
>>>>> > chart_display.jsp is called the first time through the
>>>>> image tag. it does
>>>>> > not call the DisplayChart.action again to refresh the
>>>>> image with a new one
>>>>> > when clicked on the DrawChart.action. (I added the
>>>>> println statement in
>>>>> > the display method to find out that the div is not
>>>>> refreshing)  I have to
>>>>> > log out and log in (invalidate session) to get the new
>>>>> chart. I am missing
>>>>> > something
>>>>> > 
>>>>> > 
>>>>> > 	  
>>>>> > 	  public String display() throws Exception {
>>>>> > 	      System.out.println("I AM IN THE DISPLAY
>>>>> NOW "); 
>>>>> > 		    Map attributes =
>>>>> ActionContext.getContext().getSession();
>>>>> > 	        this.chart = (JFreeChart)
>>>>> attributes.get("CHART");
>>>>> > 	        
>>>>> > 	        if(chart == null) {
>>>>> > 	            return Constants.FORWARD_INVALIDACTION;
>>>>> > 	        }
>>>>> > 	        return Constants.FORWARD_SUCCESS;
>>>>> > 	    } 
>>>>> > 	  
>>>>> > 	 
>>>>> > 	 private void setChart(JFreeChart chart){
>>>>> > 		 Map attributes =
>>>>> ActionContext.getContext().getSession();
>>>>> > 		 attributes.put("CHART", null);
>>>>> > 		 this.chart = chart;
>>>>> > 		 attributes.put("CHART", this.chart);
>>>>> > 	 }
>>>>> > 
>>>>> > public JFreeChart getChart() {
>>>>> > 		return chart;
>>>>> > 	}
>>>>> > 
>>>>> > 
>>>>> > 
>>>>> > Leena Borle wrote:
>>>>> >> 
>>>>> >> Hello,
>>>>> >>  See if this helps you.
>>>>> >>  I have a form with remote DIV which displays
>>>>> chart after user clicks on
>>>>> >> submit.
>>>>> >> Trick here is to generate chart object, store it
>>>>> in session and display
>>>>> >> it
>>>>> >> in separate JSP.   Remove the form part if you
>>>>> want to display just the
>>>>> >> dynamic-DIV using Chart image.
>>>>> >> 
>>>>> >> Form.jsp [
>>>>> >>         <s:form>
>>>>> >>             <s:url id="display_chart"
>>>>> value="DrawChart_draw.action"
>>>>> >> namespace="/user" />
>>>>> >> 
>>>>> >>             <s:submit value="Draw
>>>>> chart" href="%{display_chart}"
>>>>> >> theme="ajax"
>>>>> targets="*chart_div*"  />
>>>>> >>             <br />
>>>>> >>          </s:form>
>>>>> >> 
>>>>> >>     <h4>Your Running Chart</h4>
>>>>> >>         <div id="*chart_div*">
>>>>> >>         </div>    <!-- End display chart
>>>>> -->
>>>>> >>     </div>
>>>>> >> 
>>>>> >> ]
>>>>> >> 
>>>>> >> 
>>>>> >> display_chart.jsp [
>>>>> >> <body>
>>>>> >> 
>>>>> >>       /MyApp/user/DrawChart_display.action 
>>>>> >> </body>
>>>>> >> 
>>>>> >> ]
>>>>> >> 
>>>>> >> 
>>>>> >> struts.xml[
>>>>> >>            <package name="user" 
>>>>> extends
>>>>> >> ="struts-default,jfreechart-default">
>>>>> >>             <!--  Separate method to draw and 
>>>>> display due to Remote
>>>>> >> DIV/Button tag contsraints.
>>>>> >>              -->
>>>>> >>             <action
>>>>> name="DrawChart_input" method="input"
>>>>> >> class=".xxx.DrawChart">
>>>>> >>                     <result
>>>>> name="input">form.jsp </result>
>>>>> >>             </action>
>>>>> >> 
>>>>> >>             <action
>>>>> name="DrawChart_draw" method="draw"
>>>>> >> class="xxx..DrawChart">
>>>>> >>                     <result
>>>>> name="success">/jsp/display_chart.jsp
>>>>> >> </result>
>>>>> >>             </action>
>>>>> >>             <action
>>>>> name="DrawChart_display"
>>>>> method="display"
>>>>> >> class="xxx.DrawChart">
>>>>> >>                     <result
>>>>> name="success" type="chart">
>>>>> >>                         400
>>>>> >>                         300
>>>>> >>                      </result>
>>>>> >>             </action>
>>>>> >> 
>>>>> >>            </package>
>>>>> >> ]
>>>>> >> 
>>>>> >> 
>>>>> >> DrawChart.java [
>>>>> >>      JFreeChart chart;
>>>>> >>     public String draw() throws Exception {
>>>>> >>                  //chart creation logic.
>>>>> >>               //generate chart object
>>>>> >>               chart = ....
>>>>> >>              session = ....
>>>>> >>              session.put("CHART",
>>>>> chart);
>>>>> >>             return success;
>>>>> >>     }
>>>>> >> 
>>>>> >>     /**
>>>>> >>      * returns chart obejct from the session.
>>>>> >>        This methos is used by display_chart.jsp
>>>>> >>     */
>>>>> >>     public String display() throws Exception {
>>>>> >>         session = ...get session ...
>>>>> >>         this.chart = (JFreeChart)
>>>>> session.get("CHART");
>>>>> >>         if(chart == null) {
>>>>> >>            
>>>>> addActionError(getText("error.nochart"));
>>>>> >>             return ERROR;
>>>>> >>         }
>>>>> >>         return SUCCESS;
>>>>> >>     }
>>>>> >> 
>>>>> >>     // this method will get called if we specify
>>>>> chart
>>>>> >>     public JFreeChart getChart() {
>>>>> >>             return chart;
>>>>> >>     }
>>>>> >> 
>>>>> >>     /**
>>>>> >>      * <p> input action
>>>>> >>      */
>>>>> >>     public String input() throws Exception {
>>>>> >>         return INPUT;
>>>>> >>     }
>>>>> >> 
>>>>> >> ]
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19091264.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: Struts 2 And JFreeChart

Posted by Dave Newton <ne...@yahoo.com>.
--- On Thu, 8/21/08, Milan Milanovic wrote:
> I don't understand this solution, what is "p" parameter, and 
> whait is "RANDOM"?

This is a common technique to throw off caching mechanisms.

The "p" parameter is a dummy parameter that gets a random value so that when the submission is made, since the URL is changing due to the random parameter, it won't be cached.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by Milan Milanovic <mi...@yahoo.com>.
I don't understand this solution, what is "p" parameter, and whait is
"RANDOM" ?

--
Regards, Milan


dynamicd wrote:
> 
> 
> got it to work.. could not stop the caching so added a param to the src
> 
> img
> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
> /
> 
> 
> 
> dynamicd wrote:
>> 
>> I have tried 
>> <%
>>    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
>>    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
>>    response.setDateHeader("Expires", 0); //prevents caching at the proxy
>> server
>> 
>> %>
>> 
>> as well..
>> 
>> 
>> 
>> newton.dave wrote:
>>> 
>>> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>>>> Also tried implementing the SessionAware. However the same thing.
>>> 
>>> Why?
>>> 
>>> Did you try setting the headers for not caching?
>>> 
>>> Dave
>>> 
>>>> dynamicd wrote:
>>>> > 
>>>> > This is cool.. I tried it out. However once the 
>>>> > chart_display.jsp is called the first time through the
>>>> image tag. it does
>>>> > not call the DisplayChart.action again to refresh the
>>>> image with a new one
>>>> > when clicked on the DrawChart.action. (I added the
>>>> println statement in
>>>> > the display method to find out that the div is not
>>>> refreshing)  I have to
>>>> > log out and log in (invalidate session) to get the new
>>>> chart. I am missing
>>>> > something
>>>> > 
>>>> > 
>>>> > 	  
>>>> > 	  public String display() throws Exception {
>>>> > 	      System.out.println("I AM IN THE DISPLAY
>>>> NOW "); 
>>>> > 		    Map attributes =
>>>> ActionContext.getContext().getSession();
>>>> > 	        this.chart = (JFreeChart)
>>>> attributes.get("CHART");
>>>> > 	        
>>>> > 	        if(chart == null) {
>>>> > 	            return Constants.FORWARD_INVALIDACTION;
>>>> > 	        }
>>>> > 	        return Constants.FORWARD_SUCCESS;
>>>> > 	    } 
>>>> > 	  
>>>> > 	 
>>>> > 	 private void setChart(JFreeChart chart){
>>>> > 		 Map attributes =
>>>> ActionContext.getContext().getSession();
>>>> > 		 attributes.put("CHART", null);
>>>> > 		 this.chart = chart;
>>>> > 		 attributes.put("CHART", this.chart);
>>>> > 	 }
>>>> > 
>>>> > public JFreeChart getChart() {
>>>> > 		return chart;
>>>> > 	}
>>>> > 
>>>> > 
>>>> > 
>>>> > Leena Borle wrote:
>>>> >> 
>>>> >> Hello,
>>>> >>  See if this helps you.
>>>> >>  I have a form with remote DIV which displays
>>>> chart after user clicks on
>>>> >> submit.
>>>> >> Trick here is to generate chart object, store it
>>>> in session and display
>>>> >> it
>>>> >> in separate JSP.   Remove the form part if you
>>>> want to display just the
>>>> >> dynamic-DIV using Chart image.
>>>> >> 
>>>> >> Form.jsp [
>>>> >>         <s:form>
>>>> >>             <s:url id="display_chart"
>>>> value="DrawChart_draw.action"
>>>> >> namespace="/user" />
>>>> >> 
>>>> >>             <s:submit value="Draw
>>>> chart" href="%{display_chart}"
>>>> >> theme="ajax"
>>>> targets="*chart_div*"  />
>>>> >>             <br />
>>>> >>          </s:form>
>>>> >> 
>>>> >>     <h4>Your Running Chart</h4>
>>>> >>         <div id="*chart_div*">
>>>> >>         </div>    <!-- End display chart
>>>> -->
>>>> >>     </div>
>>>> >> 
>>>> >> ]
>>>> >> 
>>>> >> 
>>>> >> display_chart.jsp [
>>>> >> <body>
>>>> >> 
>>>> >>       /MyApp/user/DrawChart_display.action 
>>>> >> </body>
>>>> >> 
>>>> >> ]
>>>> >> 
>>>> >> 
>>>> >> struts.xml[
>>>> >>            <package name="user" 
>>>> extends
>>>> >> ="struts-default,jfreechart-default">
>>>> >>             <!--  Separate method to draw and 
>>>> display due to Remote
>>>> >> DIV/Button tag contsraints.
>>>> >>              -->
>>>> >>             <action
>>>> name="DrawChart_input" method="input"
>>>> >> class=".xxx.DrawChart">
>>>> >>                     <result
>>>> name="input">form.jsp </result>
>>>> >>             </action>
>>>> >> 
>>>> >>             <action
>>>> name="DrawChart_draw" method="draw"
>>>> >> class="xxx..DrawChart">
>>>> >>                     <result
>>>> name="success">/jsp/display_chart.jsp
>>>> >> </result>
>>>> >>             </action>
>>>> >>             <action
>>>> name="DrawChart_display"
>>>> method="display"
>>>> >> class="xxx.DrawChart">
>>>> >>                     <result
>>>> name="success" type="chart">
>>>> >>                         400
>>>> >>                         300
>>>> >>                      </result>
>>>> >>             </action>
>>>> >> 
>>>> >>            </package>
>>>> >> ]
>>>> >> 
>>>> >> 
>>>> >> DrawChart.java [
>>>> >>      JFreeChart chart;
>>>> >>     public String draw() throws Exception {
>>>> >>                  //chart creation logic.
>>>> >>               //generate chart object
>>>> >>               chart = ....
>>>> >>              session = ....
>>>> >>              session.put("CHART",
>>>> chart);
>>>> >>             return success;
>>>> >>     }
>>>> >> 
>>>> >>     /**
>>>> >>      * returns chart obejct from the session.
>>>> >>        This methos is used by display_chart.jsp
>>>> >>     */
>>>> >>     public String display() throws Exception {
>>>> >>         session = ...get session ...
>>>> >>         this.chart = (JFreeChart)
>>>> session.get("CHART");
>>>> >>         if(chart == null) {
>>>> >>            
>>>> addActionError(getText("error.nochart"));
>>>> >>             return ERROR;
>>>> >>         }
>>>> >>         return SUCCESS;
>>>> >>     }
>>>> >> 
>>>> >>     // this method will get called if we specify
>>>> chart
>>>> >>     public JFreeChart getChart() {
>>>> >>             return chart;
>>>> >>     }
>>>> >> 
>>>> >>     /**
>>>> >>      * <p> input action
>>>> >>      */
>>>> >>     public String input() throws Exception {
>>>> >>         return INPUT;
>>>> >>     }
>>>> >> 
>>>> >> ]
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19090262.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by Milan Milanovic <mi...@yahoo.com>.
I have the same problem, my chart is created just first time and every time
div which contains img tag
refreshes I always got the first image (it doesn't update) ?!

--
Regards, Milan


dynamicd wrote:
> 
> 
> got it to work.. could not stop the caching so added a param to the src
> 
> img
> src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>"
> /
> 
> 
> 
> dynamicd wrote:
>> 
>> I have tried 
>> <%
>>    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
>>    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
>>    response.setDateHeader("Expires", 0); //prevents caching at the proxy
>> server
>> 
>> %>
>> 
>> as well..
>> 
>> 
>> 
>> newton.dave wrote:
>>> 
>>> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>>>> Also tried implementing the SessionAware. However the same thing.
>>> 
>>> Why?
>>> 
>>> Did you try setting the headers for not caching?
>>> 
>>> Dave
>>> 
>>>> dynamicd wrote:
>>>> > 
>>>> > This is cool.. I tried it out. However once the 
>>>> > chart_display.jsp is called the first time through the
>>>> image tag. it does
>>>> > not call the DisplayChart.action again to refresh the
>>>> image with a new one
>>>> > when clicked on the DrawChart.action. (I added the
>>>> println statement in
>>>> > the display method to find out that the div is not
>>>> refreshing)  I have to
>>>> > log out and log in (invalidate session) to get the new
>>>> chart. I am missing
>>>> > something
>>>> > 
>>>> > 
>>>> > 	  
>>>> > 	  public String display() throws Exception {
>>>> > 	      System.out.println("I AM IN THE DISPLAY
>>>> NOW "); 
>>>> > 		    Map attributes =
>>>> ActionContext.getContext().getSession();
>>>> > 	        this.chart = (JFreeChart)
>>>> attributes.get("CHART");
>>>> > 	        
>>>> > 	        if(chart == null) {
>>>> > 	            return Constants.FORWARD_INVALIDACTION;
>>>> > 	        }
>>>> > 	        return Constants.FORWARD_SUCCESS;
>>>> > 	    } 
>>>> > 	  
>>>> > 	 
>>>> > 	 private void setChart(JFreeChart chart){
>>>> > 		 Map attributes =
>>>> ActionContext.getContext().getSession();
>>>> > 		 attributes.put("CHART", null);
>>>> > 		 this.chart = chart;
>>>> > 		 attributes.put("CHART", this.chart);
>>>> > 	 }
>>>> > 
>>>> > public JFreeChart getChart() {
>>>> > 		return chart;
>>>> > 	}
>>>> > 
>>>> > 
>>>> > 
>>>> > Leena Borle wrote:
>>>> >> 
>>>> >> Hello,
>>>> >>  See if this helps you.
>>>> >>  I have a form with remote DIV which displays
>>>> chart after user clicks on
>>>> >> submit.
>>>> >> Trick here is to generate chart object, store it
>>>> in session and display
>>>> >> it
>>>> >> in separate JSP.   Remove the form part if you
>>>> want to display just the
>>>> >> dynamic-DIV using Chart image.
>>>> >> 
>>>> >> Form.jsp [
>>>> >>         <s:form>
>>>> >>             <s:url id="display_chart"
>>>> value="DrawChart_draw.action"
>>>> >> namespace="/user" />
>>>> >> 
>>>> >>             <s:submit value="Draw
>>>> chart" href="%{display_chart}"
>>>> >> theme="ajax"
>>>> targets="*chart_div*"  />
>>>> >>             <br />
>>>> >>          </s:form>
>>>> >> 
>>>> >>     <h4>Your Running Chart</h4>
>>>> >>         <div id="*chart_div*">
>>>> >>         </div>    <!-- End display chart
>>>> -->
>>>> >>     </div>
>>>> >> 
>>>> >> ]
>>>> >> 
>>>> >> 
>>>> >> display_chart.jsp [
>>>> >> <body>
>>>> >> 
>>>> >>       /MyApp/user/DrawChart_display.action 
>>>> >> </body>
>>>> >> 
>>>> >> ]
>>>> >> 
>>>> >> 
>>>> >> struts.xml[
>>>> >>            <package name="user" 
>>>> extends
>>>> >> ="struts-default,jfreechart-default">
>>>> >>             <!--  Separate method to draw and 
>>>> display due to Remote
>>>> >> DIV/Button tag contsraints.
>>>> >>              -->
>>>> >>             <action
>>>> name="DrawChart_input" method="input"
>>>> >> class=".xxx.DrawChart">
>>>> >>                     <result
>>>> name="input">form.jsp </result>
>>>> >>             </action>
>>>> >> 
>>>> >>             <action
>>>> name="DrawChart_draw" method="draw"
>>>> >> class="xxx..DrawChart">
>>>> >>                     <result
>>>> name="success">/jsp/display_chart.jsp
>>>> >> </result>
>>>> >>             </action>
>>>> >>             <action
>>>> name="DrawChart_display"
>>>> method="display"
>>>> >> class="xxx.DrawChart">
>>>> >>                     <result
>>>> name="success" type="chart">
>>>> >>                         400
>>>> >>                         300
>>>> >>                      </result>
>>>> >>             </action>
>>>> >> 
>>>> >>            </package>
>>>> >> ]
>>>> >> 
>>>> >> 
>>>> >> DrawChart.java [
>>>> >>      JFreeChart chart;
>>>> >>     public String draw() throws Exception {
>>>> >>                  //chart creation logic.
>>>> >>               //generate chart object
>>>> >>               chart = ....
>>>> >>              session = ....
>>>> >>              session.put("CHART",
>>>> chart);
>>>> >>             return success;
>>>> >>     }
>>>> >> 
>>>> >>     /**
>>>> >>      * returns chart obejct from the session.
>>>> >>        This methos is used by display_chart.jsp
>>>> >>     */
>>>> >>     public String display() throws Exception {
>>>> >>         session = ...get session ...
>>>> >>         this.chart = (JFreeChart)
>>>> session.get("CHART");
>>>> >>         if(chart == null) {
>>>> >>            
>>>> addActionError(getText("error.nochart"));
>>>> >>             return ERROR;
>>>> >>         }
>>>> >>         return SUCCESS;
>>>> >>     }
>>>> >> 
>>>> >>     // this method will get called if we specify
>>>> chart
>>>> >>     public JFreeChart getChart() {
>>>> >>             return chart;
>>>> >>     }
>>>> >> 
>>>> >>     /**
>>>> >>      * <p> input action
>>>> >>      */
>>>> >>     public String input() throws Exception {
>>>> >>         return INPUT;
>>>> >>     }
>>>> >> 
>>>> >> ]
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p19073921.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.

got it to work.. could not stop the caching so added a param to the src

img
src="/Dashboard/DisplayChart.action?p=<%=request.getParameter("RANDOM")%>" /



dynamicd wrote:
> 
> I have tried 
> <%
>    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
>    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
>    response.setDateHeader("Expires", 0); //prevents caching at the proxy
> server
> 
> %>
> 
> as well..
> 
> 
> 
> newton.dave wrote:
>> 
>> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>>> Also tried implementing the SessionAware. However the same thing.
>> 
>> Why?
>> 
>> Did you try setting the headers for not caching?
>> 
>> Dave
>> 
>>> dynamicd wrote:
>>> > 
>>> > This is cool.. I tried it out. However once the 
>>> > chart_display.jsp is called the first time through the
>>> image tag. it does
>>> > not call the DisplayChart.action again to refresh the
>>> image with a new one
>>> > when clicked on the DrawChart.action. (I added the
>>> println statement in
>>> > the display method to find out that the div is not
>>> refreshing)  I have to
>>> > log out and log in (invalidate session) to get the new
>>> chart. I am missing
>>> > something
>>> > 
>>> > 
>>> > 	  
>>> > 	  public String display() throws Exception {
>>> > 	      System.out.println("I AM IN THE DISPLAY
>>> NOW "); 
>>> > 		    Map attributes =
>>> ActionContext.getContext().getSession();
>>> > 	        this.chart = (JFreeChart)
>>> attributes.get("CHART");
>>> > 	        
>>> > 	        if(chart == null) {
>>> > 	            return Constants.FORWARD_INVALIDACTION;
>>> > 	        }
>>> > 	        return Constants.FORWARD_SUCCESS;
>>> > 	    } 
>>> > 	  
>>> > 	 
>>> > 	 private void setChart(JFreeChart chart){
>>> > 		 Map attributes =
>>> ActionContext.getContext().getSession();
>>> > 		 attributes.put("CHART", null);
>>> > 		 this.chart = chart;
>>> > 		 attributes.put("CHART", this.chart);
>>> > 	 }
>>> > 
>>> > public JFreeChart getChart() {
>>> > 		return chart;
>>> > 	}
>>> > 
>>> > 
>>> > 
>>> > Leena Borle wrote:
>>> >> 
>>> >> Hello,
>>> >>  See if this helps you.
>>> >>  I have a form with remote DIV which displays
>>> chart after user clicks on
>>> >> submit.
>>> >> Trick here is to generate chart object, store it
>>> in session and display
>>> >> it
>>> >> in separate JSP.   Remove the form part if you
>>> want to display just the
>>> >> dynamic-DIV using Chart image.
>>> >> 
>>> >> Form.jsp [
>>> >>         <s:form>
>>> >>             <s:url id="display_chart"
>>> value="DrawChart_draw.action"
>>> >> namespace="/user" />
>>> >> 
>>> >>             <s:submit value="Draw
>>> chart" href="%{display_chart}"
>>> >> theme="ajax"
>>> targets="*chart_div*"  />
>>> >>             <br />
>>> >>          </s:form>
>>> >> 
>>> >>     <h4>Your Running Chart</h4>
>>> >>         <div id="*chart_div*">
>>> >>         </div>    <!-- End display chart
>>> -->
>>> >>     </div>
>>> >> 
>>> >> ]
>>> >> 
>>> >> 
>>> >> display_chart.jsp [
>>> >> <body>
>>> >> 
>>> >>       /MyApp/user/DrawChart_display.action 
>>> >> </body>
>>> >> 
>>> >> ]
>>> >> 
>>> >> 
>>> >> struts.xml[
>>> >>            <package name="user" 
>>> extends
>>> >> ="struts-default,jfreechart-default">
>>> >>             <!--  Separate method to draw and 
>>> display due to Remote
>>> >> DIV/Button tag contsraints.
>>> >>              -->
>>> >>             <action
>>> name="DrawChart_input" method="input"
>>> >> class=".xxx.DrawChart">
>>> >>                     <result
>>> name="input">form.jsp </result>
>>> >>             </action>
>>> >> 
>>> >>             <action
>>> name="DrawChart_draw" method="draw"
>>> >> class="xxx..DrawChart">
>>> >>                     <result
>>> name="success">/jsp/display_chart.jsp
>>> >> </result>
>>> >>             </action>
>>> >>             <action
>>> name="DrawChart_display"
>>> method="display"
>>> >> class="xxx.DrawChart">
>>> >>                     <result
>>> name="success" type="chart">
>>> >>                         400
>>> >>                         300
>>> >>                      </result>
>>> >>             </action>
>>> >> 
>>> >>            </package>
>>> >> ]
>>> >> 
>>> >> 
>>> >> DrawChart.java [
>>> >>      JFreeChart chart;
>>> >>     public String draw() throws Exception {
>>> >>                  //chart creation logic.
>>> >>               //generate chart object
>>> >>               chart = ....
>>> >>              session = ....
>>> >>              session.put("CHART",
>>> chart);
>>> >>             return success;
>>> >>     }
>>> >> 
>>> >>     /**
>>> >>      * returns chart obejct from the session.
>>> >>        This methos is used by display_chart.jsp
>>> >>     */
>>> >>     public String display() throws Exception {
>>> >>         session = ...get session ...
>>> >>         this.chart = (JFreeChart)
>>> session.get("CHART");
>>> >>         if(chart == null) {
>>> >>            
>>> addActionError(getText("error.nochart"));
>>> >>             return ERROR;
>>> >>         }
>>> >>         return SUCCESS;
>>> >>     }
>>> >> 
>>> >>     // this method will get called if we specify
>>> chart
>>> >>     public JFreeChart getChart() {
>>> >>             return chart;
>>> >>     }
>>> >> 
>>> >>     /**
>>> >>      * <p> input action
>>> >>      */
>>> >>     public String input() throws Exception {
>>> >>         return INPUT;
>>> >>     }
>>> >> 
>>> >> ]
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18861176.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.
I have tried 
<%
   response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
   response.setHeader("Pragma", "no-cache"); //HTTP 1.0
   response.setDateHeader("Expires", 0); //prevents caching at the proxy
server

%>

as well..



newton.dave wrote:
> 
> --- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
>> Also tried implementing the SessionAware. However the same thing.
> 
> Why?
> 
> Did you try setting the headers for not caching?
> 
> Dave
> 
>> dynamicd wrote:
>> > 
>> > This is cool.. I tried it out. However once the 
>> > chart_display.jsp is called the first time through the
>> image tag. it does
>> > not call the DisplayChart.action again to refresh the
>> image with a new one
>> > when clicked on the DrawChart.action. (I added the
>> println statement in
>> > the display method to find out that the div is not
>> refreshing)  I have to
>> > log out and log in (invalidate session) to get the new
>> chart. I am missing
>> > something
>> > 
>> > 
>> > 	  
>> > 	  public String display() throws Exception {
>> > 	      System.out.println("I AM IN THE DISPLAY
>> NOW "); 
>> > 		    Map attributes =
>> ActionContext.getContext().getSession();
>> > 	        this.chart = (JFreeChart)
>> attributes.get("CHART");
>> > 	        
>> > 	        if(chart == null) {
>> > 	            return Constants.FORWARD_INVALIDACTION;
>> > 	        }
>> > 	        return Constants.FORWARD_SUCCESS;
>> > 	    } 
>> > 	  
>> > 	 
>> > 	 private void setChart(JFreeChart chart){
>> > 		 Map attributes =
>> ActionContext.getContext().getSession();
>> > 		 attributes.put("CHART", null);
>> > 		 this.chart = chart;
>> > 		 attributes.put("CHART", this.chart);
>> > 	 }
>> > 
>> > public JFreeChart getChart() {
>> > 		return chart;
>> > 	}
>> > 
>> > 
>> > 
>> > Leena Borle wrote:
>> >> 
>> >> Hello,
>> >>  See if this helps you.
>> >>  I have a form with remote DIV which displays
>> chart after user clicks on
>> >> submit.
>> >> Trick here is to generate chart object, store it
>> in session and display
>> >> it
>> >> in separate JSP.   Remove the form part if you
>> want to display just the
>> >> dynamic-DIV using Chart image.
>> >> 
>> >> Form.jsp [
>> >>         <s:form>
>> >>             <s:url id="display_chart"
>> value="DrawChart_draw.action"
>> >> namespace="/user" />
>> >> 
>> >>             <s:submit value="Draw
>> chart" href="%{display_chart}"
>> >> theme="ajax"
>> targets="*chart_div*"  />
>> >>             <br />
>> >>          </s:form>
>> >> 
>> >>     <h4>Your Running Chart</h4>
>> >>         <div id="*chart_div*">
>> >>         </div>    <!-- End display chart
>> -->
>> >>     </div>
>> >> 
>> >> ]
>> >> 
>> >> 
>> >> display_chart.jsp [
>> >> <body>
>> >> 
>> >>       /MyApp/user/DrawChart_display.action 
>> >> </body>
>> >> 
>> >> ]
>> >> 
>> >> 
>> >> struts.xml[
>> >>            <package name="user" 
>> extends
>> >> ="struts-default,jfreechart-default">
>> >>             <!--  Separate method to draw and 
>> display due to Remote
>> >> DIV/Button tag contsraints.
>> >>              -->
>> >>             <action
>> name="DrawChart_input" method="input"
>> >> class=".xxx.DrawChart">
>> >>                     <result
>> name="input">form.jsp </result>
>> >>             </action>
>> >> 
>> >>             <action
>> name="DrawChart_draw" method="draw"
>> >> class="xxx..DrawChart">
>> >>                     <result
>> name="success">/jsp/display_chart.jsp
>> >> </result>
>> >>             </action>
>> >>             <action
>> name="DrawChart_display"
>> method="display"
>> >> class="xxx.DrawChart">
>> >>                     <result
>> name="success" type="chart">
>> >>                         400
>> >>                         300
>> >>                      </result>
>> >>             </action>
>> >> 
>> >>            </package>
>> >> ]
>> >> 
>> >> 
>> >> DrawChart.java [
>> >>      JFreeChart chart;
>> >>     public String draw() throws Exception {
>> >>                  //chart creation logic.
>> >>               //generate chart object
>> >>               chart = ....
>> >>              session = ....
>> >>              session.put("CHART",
>> chart);
>> >>             return success;
>> >>     }
>> >> 
>> >>     /**
>> >>      * returns chart obejct from the session.
>> >>        This methos is used by display_chart.jsp
>> >>     */
>> >>     public String display() throws Exception {
>> >>         session = ...get session ...
>> >>         this.chart = (JFreeChart)
>> session.get("CHART");
>> >>         if(chart == null) {
>> >>            
>> addActionError(getText("error.nochart"));
>> >>             return ERROR;
>> >>         }
>> >>         return SUCCESS;
>> >>     }
>> >> 
>> >>     // this method will get called if we specify
>> chart
>> >>     public JFreeChart getChart() {
>> >>             return chart;
>> >>     }
>> >> 
>> >>     /**
>> >>      * <p> input action
>> >>      */
>> >>     public String input() throws Exception {
>> >>         return INPUT;
>> >>     }
>> >> 
>> >> ]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18858943.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 8/6/08, dynamicd <dh...@gmail.com> wrote:
> Also tried implementing the SessionAware. However the same thing.

Why?

Did you try setting the headers for not caching?

Dave

> dynamicd wrote:
> > 
> > This is cool.. I tried it out. However once the 
> > chart_display.jsp is called the first time through the
> image tag. it does
> > not call the DisplayChart.action again to refresh the
> image with a new one
> > when clicked on the DrawChart.action. (I added the
> println statement in
> > the display method to find out that the div is not
> refreshing)  I have to
> > log out and log in (invalidate session) to get the new
> chart. I am missing
> > something
> > 
> > 
> > 	  
> > 	  public String display() throws Exception {
> > 	      System.out.println("I AM IN THE DISPLAY
> NOW "); 
> > 		    Map attributes =
> ActionContext.getContext().getSession();
> > 	        this.chart = (JFreeChart)
> attributes.get("CHART");
> > 	        
> > 	        if(chart == null) {
> > 	            return Constants.FORWARD_INVALIDACTION;
> > 	        }
> > 	        return Constants.FORWARD_SUCCESS;
> > 	    } 
> > 	  
> > 	 
> > 	 private void setChart(JFreeChart chart){
> > 		 Map attributes =
> ActionContext.getContext().getSession();
> > 		 attributes.put("CHART", null);
> > 		 this.chart = chart;
> > 		 attributes.put("CHART", this.chart);
> > 	 }
> > 
> > public JFreeChart getChart() {
> > 		return chart;
> > 	}
> > 
> > 
> > 
> > Leena Borle wrote:
> >> 
> >> Hello,
> >>  See if this helps you.
> >>  I have a form with remote DIV which displays
> chart after user clicks on
> >> submit.
> >> Trick here is to generate chart object, store it
> in session and display
> >> it
> >> in separate JSP.   Remove the form part if you
> want to display just the
> >> dynamic-DIV using Chart image.
> >> 
> >> Form.jsp [
> >>         <s:form>
> >>             <s:url id="display_chart"
> value="DrawChart_draw.action"
> >> namespace="/user" />
> >> 
> >>             <s:submit value="Draw
> chart" href="%{display_chart}"
> >> theme="ajax"
> targets="*chart_div*"  />
> >>             <br />
> >>          </s:form>
> >> 
> >>     <h4>Your Running Chart</h4>
> >>         <div id="*chart_div*">
> >>         </div>    <!-- End display chart
> -->
> >>     </div>
> >> 
> >> ]
> >> 
> >> 
> >> display_chart.jsp [
> >> <body>
> >> 
> >>       /MyApp/user/DrawChart_display.action 
> >> </body>
> >> 
> >> ]
> >> 
> >> 
> >> struts.xml[
> >>            <package name="user" 
> extends
> >> ="struts-default,jfreechart-default">
> >>             <!--  Separate method to draw and 
> display due to Remote
> >> DIV/Button tag contsraints.
> >>              -->
> >>             <action
> name="DrawChart_input" method="input"
> >> class=".xxx.DrawChart">
> >>                     <result
> name="input">form.jsp </result>
> >>             </action>
> >> 
> >>             <action
> name="DrawChart_draw" method="draw"
> >> class="xxx..DrawChart">
> >>                     <result
> name="success">/jsp/display_chart.jsp
> >> </result>
> >>             </action>
> >>             <action
> name="DrawChart_display"
> method="display"
> >> class="xxx.DrawChart">
> >>                     <result
> name="success" type="chart">
> >>                         400
> >>                         300
> >>                      </result>
> >>             </action>
> >> 
> >>            </package>
> >> ]
> >> 
> >> 
> >> DrawChart.java [
> >>      JFreeChart chart;
> >>     public String draw() throws Exception {
> >>                  //chart creation logic.
> >>               //generate chart object
> >>               chart = ....
> >>              session = ....
> >>              session.put("CHART",
> chart);
> >>             return success;
> >>     }
> >> 
> >>     /**
> >>      * returns chart obejct from the session.
> >>        This methos is used by display_chart.jsp
> >>     */
> >>     public String display() throws Exception {
> >>         session = ...get session ...
> >>         this.chart = (JFreeChart)
> session.get("CHART");
> >>         if(chart == null) {
> >>            
> addActionError(getText("error.nochart"));
> >>             return ERROR;
> >>         }
> >>         return SUCCESS;
> >>     }
> >> 
> >>     // this method will get called if we specify
> chart
> >>     public JFreeChart getChart() {
> >>             return chart;
> >>     }
> >> 
> >>     /**
> >>      * <p> input action
> >>      */
> >>     public String input() throws Exception {
> >>         return INPUT;
> >>     }
> >> 
> >> ]


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.
Also tried implementing the SessionAware. However the same thing.



dynamicd wrote:
> 
> This is cool.. I tried it out. However once the 
> chart_display.jsp is called the first time through the image tag. it does
> not call the DisplayChart.action again to refresh the image with a new one
> when clicked on the DrawChart.action. (I added the println statement in
> the display method to find out that the div is not refreshing)  I have to
> log out and log in (invalidate session) to get the new chart. I am missing
> something
> 
> 
> 	  
> 	  public String display() throws Exception {
> 	      System.out.println("I AM IN THE DISPLAY NOW "); 
> 		    Map attributes = ActionContext.getContext().getSession();
> 	        this.chart = (JFreeChart) attributes.get("CHART");
> 	        
> 	        if(chart == null) {
> 	            return Constants.FORWARD_INVALIDACTION;
> 	        }
> 	        return Constants.FORWARD_SUCCESS;
> 	    } 
> 	  
> 	 
> 	 private void setChart(JFreeChart chart){
> 		 Map attributes = ActionContext.getContext().getSession();
> 		 attributes.put("CHART", null);
> 		 this.chart = chart;
> 		 attributes.put("CHART", this.chart);
> 	 }
> 
> public JFreeChart getChart() {
> 		return chart;
> 	}
> 
> 
> 
> Leena Borle wrote:
>> 
>> Hello,
>>  See if this helps you.
>>  I have a form with remote DIV which displays chart after user clicks on
>> submit.
>> Trick here is to generate chart object, store it in session and display
>> it
>> in separate JSP.   Remove the form part if you want to display just the
>> dynamic-DIV using Chart image.
>> 
>> Form.jsp [
>>         <s:form>
>>             <s:url id="display_chart" value="DrawChart_draw.action"
>> namespace="/user" />
>> 
>>             <s:submit value="Draw chart" href="%{display_chart}"
>> theme="ajax" targets="*chart_div*"  />
>>             <br />
>>          </s:form>
>> 
>>     <h4>Your Running Chart</h4>
>>         <div id="*chart_div*">
>>         </div>    <!-- End display chart -->
>>     </div>
>> 
>> ]
>> 
>> 
>> display_chart.jsp [
>> <body>
>> 
>>       /MyApp/user/DrawChart_display.action 
>> </body>
>> 
>> ]
>> 
>> 
>> struts.xml[
>>            <package name="user"  extends
>> ="struts-default,jfreechart-default">
>>             <!--  Separate method to draw and  display due to Remote
>> DIV/Button tag contsraints.
>>              -->
>>             <action name="DrawChart_input" method="input"
>> class=".xxx.DrawChart">
>>                     <result name="input">form.jsp </result>
>>             </action>
>> 
>>             <action name="DrawChart_draw" method="draw"
>> class="xxx..DrawChart">
>>                     <result name="success">/jsp/display_chart.jsp
>> </result>
>>             </action>
>>             <action name="DrawChart_display" method="display"
>> class="xxx.DrawChart">
>>                     <result name="success" type="chart">
>>                         400
>>                         300
>>                      </result>
>>             </action>
>> 
>>            </package>
>> ]
>> 
>> 
>> DrawChart.java [
>>      JFreeChart chart;
>>     public String draw() throws Exception {
>>                  //chart creation logic.
>>               //generate chart object
>>               chart = ....
>>              session = ....
>>              session.put("CHART", chart);
>>             return success;
>>     }
>> 
>>     /**
>>      * returns chart obejct from the session.
>>        This methos is used by display_chart.jsp
>>     */
>>     public String display() throws Exception {
>>         session = ...get session ...
>>         this.chart = (JFreeChart) session.get("CHART");
>>         if(chart == null) {
>>             addActionError(getText("error.nochart"));
>>             return ERROR;
>>         }
>>         return SUCCESS;
>>     }
>> 
>>     // this method will get called if we specify chart
>>     public JFreeChart getChart() {
>>             return chart;
>>     }
>> 
>>     /**
>>      * <p> input action
>>      */
>>     public String input() throws Exception {
>>         return INPUT;
>>     }
>> 
>> ]
>> 
>> 
>> 
>> Leena
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18858354.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.
I am creating a new chart using the ChartFactory

chart = ChartFactory.createBarChart
		  (reportname,xaxis, yaxis, dataset, 
		   PlotOrientation.VERTICAL, true,true, true);

return chart;
 
and I am storing it in the session. However the DisplayChart.action that is
in the image src is not called the second time on. It seems like a caching
issue. 



Leena Borle wrote:
> 
> Hi,
>   How are you creating new chart object ? For me every time user clicks on
> submit-DrawChart_draw,action  will create New chart object (e.g.
> chart=ChartFactory.createBarChart)  and store it in the session which
> afterwards is used by DIV(DrawChart_display.action). You need to refresh
> your chart object.
> Leena
> 
> On Wed, Aug 6, 2008 at 11:36 AM, dynamicd <dh...@gmail.com> wrote:
> 
>> This is cool.. I tried it out. However once the
>> chart_display.jsp is called the first time through the image tag. it does
>> not call the DisplayChart.action again to refresh the image with a new
>> one
>> when clicked on the DrawChart.action. (I added the println statement in
>> the
>> display method to find out that the div is not refreshing)  I have to log
>> out and log in (invalidate session) to get the new chart. I am missing
>> something
>>
>>
>>
>>          public String display() throws Exception {
>>               System.out.println("I AM IN THE DISPLAY NOW ");
>>                    Map attributes =
>> ActionContext.getContext().getSession();
>>                this.chart = (JFreeChart) attributes.get("CHART");
>>
>>                if(chart == null) {
>>                    return Constants.FORWARD_INVALIDACTION;
>>                }
>>                return Constants.FORWARD_SUCCESS;
>>            }
>>
>>
>>         private void setChart(JFreeChart chart){
>>                 Map attributes = ActionContext.getContext().getSession();
>>                 attributes.put("CHART", null);
>>                 this.chart = chart;
>>                 attributes.put("CHART", this.chart);
>>          }
>>
>> public JFreeChart getChart() {
>>                return chart;
>>        }
>>
>>
>>
>> Leena Borle wrote:
>> >
>> > Hello,
>> >  See if this helps you.
>> >  I have a form with remote DIV which displays chart after user clicks
>> on
>> > submit.
>> > Trick here is to generate chart object, store it in session and display
>> it
>> > in separate JSP.   Remove the form part if you want to display just the
>> > dynamic-DIV using Chart image.
>> >
>> > Form.jsp [
>> >         <s:form>
>> >             <s:url id="display_chart" value="DrawChart_draw.action"
>> > namespace="/user" />
>> >
>> >             <s:submit value="Draw chart" href="%{display_chart}"
>> > theme="ajax" targets="*chart_div*"  />
>> >             <br />
>> >          </s:form>
>> >
>> >     <h4>Your Running Chart</h4>
>> >         <div id="*chart_div*">
>> >         </div>    <!-- End display chart -->
>> >     </div>
>> >
>> > ]
>> >
>> >
>> > display_chart.jsp [
>> > <body>
>> >
>> >       /MyApp/user/DrawChart_display.action
>> > </body>
>> >
>> > ]
>> >
>> >
>> > struts.xml[
>> >            <package name="user"  extends
>> > ="struts-default,jfreechart-default">
>> >             <!--  Separate method to draw and  display due to Remote
>> > DIV/Button tag contsraints.
>> >              -->
>> >             <action name="DrawChart_input" method="input"
>> > class=".xxx.DrawChart">
>> >                     <result name="input">form.jsp </result>
>> >             </action>
>> >
>> >             <action name="DrawChart_draw" method="draw"
>> > class="xxx..DrawChart">
>> >                     <result name="success">/jsp/display_chart.jsp
>> > </result>
>> >             </action>
>> >             <action name="DrawChart_display" method="display"
>> > class="xxx.DrawChart">
>> >                     <result name="success" type="chart">
>> >                         400
>> >                         300
>> >                      </result>
>> >             </action>
>> >
>> >            </package>
>> > ]
>> >
>> >
>> > DrawChart.java [
>> >      JFreeChart chart;
>> >     public String draw() throws Exception {
>> >                  //chart creation logic.
>> >               //generate chart object
>> >               chart = ....
>> >              session = ....
>> >              session.put("CHART", chart);
>> >             return success;
>> >     }
>> >
>> >     /**
>> >      * returns chart obejct from the session.
>> >        This methos is used by display_chart.jsp
>> >     */
>> >     public String display() throws Exception {
>> >         session = ...get session ...
>> >         this.chart = (JFreeChart) session.get("CHART");
>> >         if(chart == null) {
>> >             addActionError(getText("error.nochart"));
>> >             return ERROR;
>> >         }
>> >         return SUCCESS;
>> >     }
>> >
>> >     // this method will get called if we specify chart
>> >     public JFreeChart getChart() {
>> >             return chart;
>> >     }
>> >
>> >     /**
>> >      * <p> input action
>> >      */
>> >     public String input() throws Exception {
>> >         return INPUT;
>> >     }
>> >
>> > ]
>> >
>> >
>> >
>> > Leena
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18857105.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18860659.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And JFreeChart

Posted by Leena Borle <ls...@gmail.com>.
Hi,
  How are you creating new chart object ? For me every time user clicks on
submit-DrawChart_draw,action  will create New chart object (e.g.
chart=ChartFactory.createBarChart)  and store it in the session which
afterwards is used by DIV(DrawChart_display.action). You need to refresh
your chart object.
Leena

On Wed, Aug 6, 2008 at 11:36 AM, dynamicd <dh...@gmail.com> wrote:

> This is cool.. I tried it out. However once the
> chart_display.jsp is called the first time through the image tag. it does
> not call the DisplayChart.action again to refresh the image with a new one
> when clicked on the DrawChart.action. (I added the println statement in the
> display method to find out that the div is not refreshing)  I have to log
> out and log in (invalidate session) to get the new chart. I am missing
> something
>
>
>
>          public String display() throws Exception {
>               System.out.println("I AM IN THE DISPLAY NOW ");
>                    Map attributes =
> ActionContext.getContext().getSession();
>                this.chart = (JFreeChart) attributes.get("CHART");
>
>                if(chart == null) {
>                    return Constants.FORWARD_INVALIDACTION;
>                }
>                return Constants.FORWARD_SUCCESS;
>            }
>
>
>         private void setChart(JFreeChart chart){
>                 Map attributes = ActionContext.getContext().getSession();
>                 attributes.put("CHART", null);
>                 this.chart = chart;
>                 attributes.put("CHART", this.chart);
>          }
>
> public JFreeChart getChart() {
>                return chart;
>        }
>
>
>
> Leena Borle wrote:
> >
> > Hello,
> >  See if this helps you.
> >  I have a form with remote DIV which displays chart after user clicks on
> > submit.
> > Trick here is to generate chart object, store it in session and display
> it
> > in separate JSP.   Remove the form part if you want to display just the
> > dynamic-DIV using Chart image.
> >
> > Form.jsp [
> >         <s:form>
> >             <s:url id="display_chart" value="DrawChart_draw.action"
> > namespace="/user" />
> >
> >             <s:submit value="Draw chart" href="%{display_chart}"
> > theme="ajax" targets="*chart_div*"  />
> >             <br />
> >          </s:form>
> >
> >     <h4>Your Running Chart</h4>
> >         <div id="*chart_div*">
> >         </div>    <!-- End display chart -->
> >     </div>
> >
> > ]
> >
> >
> > display_chart.jsp [
> > <body>
> >
> >       /MyApp/user/DrawChart_display.action
> > </body>
> >
> > ]
> >
> >
> > struts.xml[
> >            <package name="user"  extends
> > ="struts-default,jfreechart-default">
> >             <!--  Separate method to draw and  display due to Remote
> > DIV/Button tag contsraints.
> >              -->
> >             <action name="DrawChart_input" method="input"
> > class=".xxx.DrawChart">
> >                     <result name="input">form.jsp </result>
> >             </action>
> >
> >             <action name="DrawChart_draw" method="draw"
> > class="xxx..DrawChart">
> >                     <result name="success">/jsp/display_chart.jsp
> > </result>
> >             </action>
> >             <action name="DrawChart_display" method="display"
> > class="xxx.DrawChart">
> >                     <result name="success" type="chart">
> >                         400
> >                         300
> >                      </result>
> >             </action>
> >
> >            </package>
> > ]
> >
> >
> > DrawChart.java [
> >      JFreeChart chart;
> >     public String draw() throws Exception {
> >                  //chart creation logic.
> >               //generate chart object
> >               chart = ....
> >              session = ....
> >              session.put("CHART", chart);
> >             return success;
> >     }
> >
> >     /**
> >      * returns chart obejct from the session.
> >        This methos is used by display_chart.jsp
> >     */
> >     public String display() throws Exception {
> >         session = ...get session ...
> >         this.chart = (JFreeChart) session.get("CHART");
> >         if(chart == null) {
> >             addActionError(getText("error.nochart"));
> >             return ERROR;
> >         }
> >         return SUCCESS;
> >     }
> >
> >     // this method will get called if we specify chart
> >     public JFreeChart getChart() {
> >             return chart;
> >     }
> >
> >     /**
> >      * <p> input action
> >      */
> >     public String input() throws Exception {
> >         return INPUT;
> >     }
> >
> > ]
> >
> >
> >
> > Leena
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18857105.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Struts 2 And JFreeChart

Posted by dynamicd <dh...@gmail.com>.
This is cool.. I tried it out. However once the 
chart_display.jsp is called the first time through the image tag. it does
not call the DisplayChart.action again to refresh the image with a new one
when clicked on the DrawChart.action. (I added the println statement in the
display method to find out that the div is not refreshing)  I have to log
out and log in (invalidate session) to get the new chart. I am missing
something


	  
	  public String display() throws Exception {
	      System.out.println("I AM IN THE DISPLAY NOW "); 
		    Map attributes = ActionContext.getContext().getSession();
	        this.chart = (JFreeChart) attributes.get("CHART");
	        
	        if(chart == null) {
	            return Constants.FORWARD_INVALIDACTION;
	        }
	        return Constants.FORWARD_SUCCESS;
	    } 
	  
	 
	 private void setChart(JFreeChart chart){
		 Map attributes = ActionContext.getContext().getSession();
		 attributes.put("CHART", null);
		 this.chart = chart;
		 attributes.put("CHART", this.chart);
	 }

public JFreeChart getChart() {
		return chart;
	}



Leena Borle wrote:
> 
> Hello,
>  See if this helps you.
>  I have a form with remote DIV which displays chart after user clicks on
> submit.
> Trick here is to generate chart object, store it in session and display it
> in separate JSP.   Remove the form part if you want to display just the
> dynamic-DIV using Chart image.
> 
> Form.jsp [
>         <s:form>
>             <s:url id="display_chart" value="DrawChart_draw.action"
> namespace="/user" />
> 
>             <s:submit value="Draw chart" href="%{display_chart}"
> theme="ajax" targets="*chart_div*"  />
>             <br />
>          </s:form>
> 
>     <h4>Your Running Chart</h4>
>         <div id="*chart_div*">
>         </div>    <!-- End display chart -->
>     </div>
> 
> ]
> 
> 
> display_chart.jsp [
> <body>
> 
>       /MyApp/user/DrawChart_display.action 
> </body>
> 
> ]
> 
> 
> struts.xml[
>            <package name="user"  extends
> ="struts-default,jfreechart-default">
>             <!--  Separate method to draw and  display due to Remote
> DIV/Button tag contsraints.
>              -->
>             <action name="DrawChart_input" method="input"
> class=".xxx.DrawChart">
>                     <result name="input">form.jsp </result>
>             </action>
> 
>             <action name="DrawChart_draw" method="draw"
> class="xxx..DrawChart">
>                     <result name="success">/jsp/display_chart.jsp
> </result>
>             </action>
>             <action name="DrawChart_display" method="display"
> class="xxx.DrawChart">
>                     <result name="success" type="chart">
>                         400
>                         300
>                      </result>
>             </action>
> 
>            </package>
> ]
> 
> 
> DrawChart.java [
>      JFreeChart chart;
>     public String draw() throws Exception {
>                  //chart creation logic.
>               //generate chart object
>               chart = ....
>              session = ....
>              session.put("CHART", chart);
>             return success;
>     }
> 
>     /**
>      * returns chart obejct from the session.
>        This methos is used by display_chart.jsp
>     */
>     public String display() throws Exception {
>         session = ...get session ...
>         this.chart = (JFreeChart) session.get("CHART");
>         if(chart == null) {
>             addActionError(getText("error.nochart"));
>             return ERROR;
>         }
>         return SUCCESS;
>     }
> 
>     // this method will get called if we specify chart
>     public JFreeChart getChart() {
>             return chart;
>     }
> 
>     /**
>      * <p> input action
>      */
>     public String input() throws Exception {
>         return INPUT;
>     }
> 
> ]
> 
> 
> 
> Leena
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-And-JFreeChart-tp18740589p18857105.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org