Can we have a bean with components in a composite component of JSF2?

I was wondering how I could create local <component cloud> beans variables or the so-called "local variables inside a composite component", which are private to an instance of the composite component and live as long as this instance lives.

The following is more detailed information explained with an example:

Suppose there is a โ€œcalculatorโ€ component - something that allows users to enter a mathematical expression and evaluate its value. If desired, it also displays a related function.

I can create a composite component that has:

  • text field for accepting a mathematical expression
  • two buttons called "Grade" and "Story"
  • another nested component that displays a function

This is obviously a closed part of the function; so someone who wants to use it can simply say: lt; math: expressionEvaluator />

But, obviously, the implementation will require a Java object - something that evaluates the expression, something that calculates the points of the graph, etc. - and I believe that it can be a bean - the scope only for this instance of this component, not covered by the scope or bean with a common query coverage that is common to all instances of the component.

How to create such a bean? Is this possible with composite components?

+3
source share
2 answers

" ". .

ViewScoped bean - " " .

bean - , , , bean. , "" bean.

, , , ViewScoped bean, , . , .

0

UIComponent Java. JSF 1.x " ", JSF 2.0 Facelets .

UIComponents Java , . , UIComponents Java - , .

0

Source: https://habr.com/ru/post/1749017/


All Articles