Can we have a component-scoped bean in a JSF2 composite component?

Posted by Pradyumna on Stack Overflow See other posts from Stack Overflow or by Pradyumna
Published on 2010-06-08T12:48:01Z Indexed on 2010/06/08 12:52 UTC
Read the original article Hit count: 234

Filed under:
|
|

Hi,

I was wondering how I could create "component-scoped" beans, or so-to-say, "local variables inside a composite component" that are private to the instance of the composite component, and live as long as that instance lives.

Below are more details, explained with an example:

Suppose there is a "calculator" component - something that allows users to type in a mathematical expression, and evaluates its value. Optionally, it also plots the associated function.

I can make a composite component that has:

  • a text box for accepting the math expression
  • two buttons called "Evaluate", and "Plot"
  • another nested component that plots the function

It is evidently a self-contained piece of function; so that somebody who wants to use it may just say <math:expressionEvaluator />

But obviously, the implementation would need a java object - something that evaluates the expression, something that computes the plot points, etc. - and I imagine it can be a bean - scoped just for this instance of this component, not a view-scoped or request-scoped bean that is shared across all instances of the component.

How do I create such a bean? Is that even possible with composite components?

© Stack Overflow or respective owner

Related posts about java

Related posts about jsf