2

JFS1.2 + Richfaces 3.3

Situation is as follows:

JSP page renders conditionally one or another panelGroup.

Within each panelGroup there are couple setters and one command button. Each of two panelGroups uses own bean for setting and performing action.

On the top of a page there's selectOneRadio with (obvious) two items - coresponding tow options of conditional rendering.

Page renders properly, switcher causes to render appropriate panel. Case is, commands buttons doesn't call an action.

I know what's going on - when I click a button to call action dom is regenerated, but the value that hold my decision to display particular panel doesn't exist anymore. The button is not recreated, action is not fired.

Technically:

<h:selectOneRadio value="#{reportType}">
                <f:selectItem itemLabel="x" itemValue="x"/>
                <f:selectItem itemLabel="y" itemValue="y"/>
                <a4j:support event="onclick" reRender="xPanel, yPanel/>
</h:selectOneRadio>

<h:panelGrid id="xPanel "columns="2" rendered="#{reportType eq 'x'}">
    <...some setters>
    <... commandbutton>
</h:panelGrid>

<h:panelGrid id="yPanel "columns="2" rendered="#{reportType eq 'y'}">
    <...some setters>
    <... commandbutton>
</h:panelGrid>

Question is, how to design the page to obtain proper rendering and actions? For now, I created additional session bean that holds switching value (x|y), but that desing smells bad for me...

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
wilu
  • 549
  • 1
  • 12
  • 26
  • I think this a classical example of the not enough scopes in `JSF 1.2`. Everything greater than `request` must be `session`... `JSF 2.0` is much better:) – Petar Minchev Aug 24 '11 at 06:57
  • Look at this question - http://stackoverflow.com/questions/5897262/jsf-1-2-how-to-keep-managed-bean-with-request-scope – Petar Minchev Aug 24 '11 at 06:58
  • BTW, I think your solution is good enough. – Petar Minchev Aug 24 '11 at 07:04
  • Well, I would use tomahawk gladly.. unfortunately it's marked deprecated in my project... Lack of scopes... indeed, view would fit beautifly, sadly, that option (upgrade to JSF2) also cannot be taken uder consideration (project requirements). What would make me happy - is it possible to brake the problem WITHOUT additional session bean holding decision value? – wilu Aug 24 '11 at 07:16
  • There are some `JSF` gurus here like `BalusC`. He can tell you for sure. – Petar Minchev Aug 24 '11 at 07:27

1 Answers1

1

RichFaces 3.3 offers the <a4j:keepAlive> tag which does basically the same as Tomahawk's <t:saveState> and JSF2 @ViewScoped. Add the following line somewhere in your view:

<a4j:keepAlive beanName="#{bean}" />

This will keep the bean alive as long as you're returning null or void from action(listener) methods.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555