Updating a4j:regions inside a4j:outputPanels.
---------------------------------------------
Key: RF-3896
URL: http://jira.jboss.com/jira/browse/RF-3896
Project: RichFaces
Issue Type: Bug
Affects Versions: 3.2.1
Environment: JSE1.5.0,Richfaces 3.2.1, Tomcat 5.5
Reporter: Slawomir Wojtasiak
a4j:region tags are not always transparent for Java Script code on client side.
As you can see in examples bellow there is problem during render response phase
processing when a4j:outputPanels containing a4j:regions are rendered. Take a
look at first example which uses two independent regions. The first one with id
set to "submitRegion" is used for request submitting only. When region is
submitted and response is sent to the client, following "Ajax-Update-Ids"
element is generated for JavaScript on client side:
"mainForm:testOutputPanel,mainForm:testButton,mainForm:problematicRegion". As
you can see there is "problematicRegion" element added. It is id of the
a4j:region inside output panel in the first example. This region is not
rendered in any way in html code (see AjaxRegionRenderer) so suitable element
will not be found in DOM tree. My opinion is that if a4j:region is not rendered
it also shouldn't be used inside Ajax-Update-Ids. Take into account that
"testButton1" which!
is placed inside this region ("problematicRegion") is sent in response the
same way as it is sent in second example where "problematicRegion" is removed
from outputPanel. See the <body> elements in the responses of the both
examples, they are the same. In this case a4j:region is transparent as it
should be...
I'm pretty sure that this region should be transparent and "Ajax-Update-Ids"
element in example 1 should be generated the same way as it is generated in
example 2.
Mentioned examples:
Example 1.
See a4j:region inside outputPanel, in example 2 there is no such region.
Page template:
<h:form id="mainForm" style="margin: 0px;">
<a4j:region id="submitRegion">
<a4j:commandButton id="submitButton"
action="#{sessionBean.submitAction}" reRender="testOutputPanel" value="Submit"/>
</a4j:region>
<br/>
<a4j:outputPanel id="testOutputPanel" layout="none">
<h:outputText id="testButton" value="#{sessionBean.value}"/>
<a4j:region id="problematicRegion">
<h:outputText id="testButton1"
value="#{sessionBean.value}"/>
....
</a4j:region>
</a4j:outputPanel>
</h:form>
Wrong response:
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link type="text/css" rel="stylesheet"
href="/jsf/a4j_3_2_1-SNAPSHOTorg/richfaces/renderkit/html/css/basic_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf"
class="component" />
<link type="text/css" rel="stylesheet"
href="/jsf/a4j_3_2_1-SNAPSHOTorg/richfaces/renderkit/html/css/extended_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf"
class="component" />
<script type="text/javascript"
src="/jsf/a4j_3_2_1-SNAPSHOTorg.ajax4jsf.javascript.AjaxScript.jsf">
</script>
</head>
<body>
<span id="mainForm:testButton">8</span>
<span id="mainForm:testButton1">8</span>
<meta name="Ajax-Update-Ids"
content="mainForm:testOutputPanel,mainForm:testButton,mainForm:problematicRegion"
/>
<span id="ajax-view-state"><input type="hidden"
name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id2"
/></span>
<meta id="Ajax-Response" name="Ajax-Response" content="true" />
</body>
</html>
Example 2.
Page template:
<h:form id="mainForm" style="margin: 0px;">
<a4j:region id="submitRegion">
<a4j:commandButton id="submitButton"
action="#{sessionBean.submitAction}" reRender="testOutputPanel" value="Submit"/>
</a4j:region>
<br/>
<a4j:outputPanel id="testOutputPanel" layout="none">
<h:outputText id="testButton" value="#{sessionBean.value}"/>
<h:outputText id="testButton1" value="#{sessionBean.value}"/>
</a4j:outputPanel>
</h:form>
Correct response:
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link type="text/css" rel="stylesheet"
href="/jsf/a4j_3_2_1-SNAPSHOTorg/richfaces/renderkit/html/css/basic_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf"
class="component" />
<link type="text/css" rel="stylesheet"
href="/jsf/a4j_3_2_1-SNAPSHOTorg/richfaces/renderkit/html/css/extended_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf"
class="component" />
<script type="text/javascript"
src="/jsf/a4j_3_2_1-SNAPSHOTorg.ajax4jsf.javascript.AjaxScript.jsf">
</script>
</head>
<body>
<span id="mainForm:testButton">3</span>
<span id="mainForm:testButton1">3</span>
<meta name="Ajax-Update-Ids"
content="mainForm:testOutputPanel,mainForm:testButton,mainForm:testButton1" />
<span id="ajax-view-state"><input type="hidden"
name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id3"
/></span>
<meta id="Ajax-Response" name="Ajax-Response" content="true" />
</body>
</html>
a4j:region renderer doesn't render region in any way:
public class AjaxRegionRenderer extends AjaxContainerRenderer {
public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxRegionRenderer";
/* (non-Javadoc)
* @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
protected void doEncodeBegin(ResponseWriter writer, FacesContext
context, UIComponent component) throws IOException {
// AjaxRendererUtils.encodeClientScript(context,component);
}
/* (non-Javadoc)
* @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
// if (((AjaxContainer) component).isAjaxRequest()) {
// AjaxRendererUtils.encodeAreas(context,component);
// }
}
}
Problem might be located here:
AjaxOutputPanelRenderer treats regions as any renderable component and adds
their ids to the ajaxRenderedAreas list.
/* (non-Javadoc)
* @see
javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
*/
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException {
//
UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
if ("none".equals(panel.getLayout())) {
if (component.getChildCount() > 0) {
AjaxContext ajaxContext =
AjaxContext.getCurrentInstance(context);
boolean ajaxRequest =
ajaxContext.isAjaxRequest();
Set ajaxRenderedAreas =
ajaxContext.getAjaxRenderedAreas();
for (Iterator it =
component.getChildren().iterator(); it.hasNext();) {
UIComponent child = (UIComponent)
it.next();
String childId =
child.getClientId(context);
if (child.isRendered()) {
renderChild(context, child);
} else {
// Render "dummy" span.
ResponseWriter out =
context.getResponseWriter();
out.startElement(HTML.SPAN_ELEM,child);
out.writeAttribute(HTML.id_ATTRIBUTE,childId,HTML.id_ATTRIBUTE);
out.writeAttribute(HTML.style_ATTRIBUTE,"display: none;","style");
out.endElement(HTML.SPAN_ELEM);
}
// register child as rendered
if(ajaxRequest && null !=
ajaxRenderedAreas) {
ajaxRenderedAreas.add(childId);
}
}
}
} else {
renderChildren(context,component);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
richfaces-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/richfaces-issues