-
1. ajax rerender + request scoped beans
ilya40umov Feb 10, 2011 6:54 PM (in response to svkap)Try to use a4j:keepAlive it should save your bean's state until a user is viewing the page.
-
2. ajax rerender + request scoped beans
svkap Feb 13, 2011 9:37 AM (in response to ilya40umov)I can use ViewScoped beans. Unfortunatelly this does not seem ti affect other parts of the site (initialized by other beans). That is why I wanted to have some certralized mechanism of Ajax regions updates. I guess that this is a common problem so probably there are some examples.
For example I have 2 beans. First one generates some content and passes HtmlPanelGroup to the second one. The second bean generates another content using the passed HtmlPanelGroup. However, the second bean refreshes only its generated content and not the whole HtmlPanelGroup.
-
3. ajax rerender + request scoped beans
nbelaevski Feb 14, 2011 9:55 AM (in response to svkap)Hi,
Can you please post some code to additionaly clarify the issue?
-
4. Re: ajax rerender + request scoped beans
svkap Feb 14, 2011 11:34 AM (in response to nbelaevski)Of course. This is not the exact code but I think that these are the important parts.
// bean1
private HtmlPanelGroup panelRoot = new HtmlPanelGroup();
....
public void init() {
// panelRoot initialization with some controls
....
....
panelMsgRoot.getChildren().add(panelMain);
panelRoot.getChildren().add(panelMsgRoot);
Bean2 bean2 = new Bean2();
bean2.setRoot(panelRoot);
// init jsf controls of bean2
bean2.init();
// custom helper class
JSFHelper.setBean("bean2", bean2);
}
// bean2
public void init() {
...
HtmlAjaxCommandButton button = new HtmlAjaxCommandButton();
button.setId("button_id_" + getRandom());
button.setAjaxSingle(false);
button.setType("submit");
button.setValue("Button");
button.setReRender("panelRoot_id");
MethodExpression btnActionExpression = expressionFactory
.createMethodExpression(elContext,
"#{bean2.buttonAction}", null,
new Class[] { ActionEvent.class });
MethodExpressionActionListener listenerBtn = new MethodExpressionActionListener(
btnActionExpression);
button.addActionListener(listenerBtn);
....
panelRoot.getChildren().add(button);
}
// jsf
<a4j:form id="form_id" ajaxSubmit="true" reRender="panelRoot_id" >
<h:panelGroup layout="block" id="panelRoot_id" style="width:580px;"
binding="#{bean1.panelRoot}" />
</a4j:form>
Probably the problem is in my code.
public void setPanelRootHtmlPanelGroup panelRoot) { } is called when button is clicked. However, I need to reload the content of panelRoot (currently loaded by public void init() {} method of bean1)