• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

A Cewolf ChartPostProcessor with dynamic variable

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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}".
 
MichaelJ McCabe
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

String maxX = (String) params.get(String.valueOf(maxXValue));


That should read

String maxX = (String) params.get("maxXValue");
 
MichaelJ McCabe
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic