Two Laptop Bag*
The moose likes Other Open Source Projects and the fly likes A Cewolf ChartPostProcessor with dynamic variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "A Cewolf ChartPostProcessor with dynamic variable" Watch "A Cewolf ChartPostProcessor with dynamic variable" New topic
Author

A Cewolf ChartPostProcessor with dynamic variable

MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
I am setting a cewolf's chart maxX value as follows



The problem I am having, is that the 'value' needs to change in relation to a session variable. I obviously cant do

(Integer)session.getAttribute("maxXValue")

because of the local variable "session" being accessed from within a inner class. How would I go about injecting a variable into this chart processor?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
You can use the JSP EL to pass the value to the postprocessor:

<cewolf:param name="maxXValue" value="${maxXValue}"/>

Assuming that there are no other attributes with that name in the page or request scope, it will get it from the session. Or you can use "${sessionScope.maxXValue}".


Ping & DNS - my free Android networking tools app
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:You can use the JSP EL to pass the value to the postprocessor:

<cewolf:param name="maxXValue" value="${maxXValue}"/>

Assuming that there are no other attributes with that name in the page or request scope, it will get it from the session. Or you can use "${sessionScope.maxXValue}".


I dont need to get a value to my JSP page though. I need to set the max X value within the ChartPostProcessor i have below

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
I'm not sure what you mean by "get a value to my JSP page" - JSP has access to the user's session, so it can retrieve the value.

The "params" Map in the processChart method contains all values that are passed in via cewolf:param tags, so I think adding that single line of JSP code is all it takes to implement this (plus the Java code that retrieves the element from the Map and uses it).
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Ulf Dittmer wrote:I'm not sure what you mean by "get a value to my JSP page" - JSP has access to the user's session, so it can retrieve the value.

The "params" Map in the processChart method contains all values that are passed in via cewolf:param tags, so I think adding that single line of JSP code is all it takes to implement this (plus the Java code that retrieves the element from the Map and uses it).


Ah ok, I understand. But I am getting "cannot find symbol - maxXValue" when trying to compile.

I am using this in my processChart method



and this in my jsp page cewolf chart

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
String maxX = (String) params.get(String.valueOf(maxXValue));

That should read

String maxX = (String) params.get("maxXValue");
MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Thank you very much, again, for all your help. I now have it working.

Both ${maxXValue} and ${sessionScope.maxXValue} didnt work so I ended up doing

<% int maxXValue = (Integer)session.getAttribute("maxXValue"); %>

then using

value="<%=maxXValue %>"

looking great
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
Good to hear that you got it working. It sounds as if your web app may not be set up correctly for EL; http://faq.javaranch.com/java/ElOrJstlNotWorkingAsExpected may help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Cewolf ChartPostProcessor with dynamic variable
 
Similar Threads
Line chart problem
Label Rotation in Flex 3..
JFreeChart - How to define custom maximum value of axis
Jfree Chart Problem
Setting Initial Value In JFreeChart