Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2013-02-18T11:19:52Z by Jutx
Jutx
Jutx
2 Posts
ACCEPTED ANSWER

Pinned topic using f:ajax and regular submit causes duplicate fields

‏2013-02-15T12:29:47Z |
Hi.

I'm using jsf20-portletbridge.jar and myfaces 2.0.14 in a JSF 2.0 portlet (Portal 7.0.2, WAS 7.0.25)

this is the scenario:

A simple page with inputText, and two buttons; one of the with an ajax tag and the other regular one.

Clicking the non-ajax button which action returns null causes the elements in the page be duplicated. There is a trace of the exception showed in the console below, which is a nullpointerException and IllegalstateException whith this message:

javax.portlet.PortletException: Client-id : form1 is duplicated in the faces tree. Component : viewns_Z7_R4MM1KJ4006A00I7R4L96F1047_:form1

This is a weird problem using simple functionality and i'm very lost in this and it makes the f:ajax functionality unusable...

This is the facelet fragment:

<f:view>
<h:form styleClass="form" id="form1" name="form1">
<h:inputText styleClass="inputText" id="textCounter" label="test"
required="true" value="#{myBean.counter }" size="40"></h:inputText>
<h:commandButton action="#{myBean.add }" value="add" id="boton1">
<f:ajax render="textCounter" id="theAjax" ></f:ajax>
</h:commandButton>
<h:commandButton action="#{vistaScope.doNothing }" value="submit duplicates components" id="boton2" />
</h:form>
</f:view>

---
The methods managedBean:

@ManagedBean(name="myBean")
@SessionScoped
...
public String add(){
System.out.println("adding ");
counter++;
return null;
}

public String doNothing(){
return null;
}


trace
java.lang.NullPointerException
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.getRenderer(UIComponentBase.java:1304)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponent$EventListenerWrapper.restoreState(UIComponent.java:1430)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:1884)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component._DeltaList.restoreState(_DeltaList.java:253)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:1884)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.restoreFullSystemEventListenerClassMap(UIComponentBase.java:2190)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:2044)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIOutput.restoreState(UIOutput.java:213)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1599)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1643)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1614)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:772)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at com.ibm.faces20.portlet.FacesPortlet.restoreViewState(FacesPortlet.java:955)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at com.ibm.faces20.portlet.FacesPortlet.restoreViewState(FacesPortlet.java:976)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at com.ibm.faces20.portlet.FacesPortlet.restoreView(FacesPortlet.java:1399)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at com.ibm.faces20.portlet.FacesPortlet.doRender(FacesPortlet.java:447)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at com.ibm.faces20.portlet.FacesPortlet.doView(FacesPortlet.java:506)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at com.ibm.faces20.portlet.FacesPortlet.doDispatch(FacesPortlet.java:383)
15/02/13 13:08:41:461 CET 00000050 SystemErr R at javax.portlet.GenericPortlet.render(GenericPortlet.java:222)
...
Updated on 2013-02-18T11:19:52Z at 2013-02-18T11:19:52Z by Jutx
  • Jasi
    Jasi
    241 Posts
    ACCEPTED ANSWER

    Re: using f:ajax and regular submit causes duplicate fields

    ‏2013-02-16T07:16:17Z  in response to Jutx
    Well, JSF 2 on WAS 7 (hence WP7) was always meant to be a stop-gap arrangement to get your hands dirty till proper product support came out. So it would have surprises like the one you mentioned.
    A more solid and error-proof approach will be to get onto latest WP8001 on WAS8005. And in case you face any issue there, you can even log a PMR.
    • Jutx
      Jutx
      2 Posts
      ACCEPTED ANSWER

      Re: using f:ajax and regular submit causes duplicate fields

      ‏2013-02-18T11:19:52Z  in response to Jasi
      Hi Jasi.

      Unfortunately it will took a while for us to upgrade to WP8.

      I've been able to get more info about ajax tag issue and I think the question is about the outputScript. the portlet bridge is not able to find a proper render kit for javax.faces.resource.Script, which is added automatically by the ajax tag. May be be I should open a different thread...

      I'm trying to declare the proper render kit in faces-config.xml, but no success...

      • No Renderer found for component {Component-Path : Class: com.ibm.faces20.portlet.UIPortletViewRoot,ViewId: /ajax.xhtmlClass: org.apache.myfaces.component.ComponentResourceContainer,Id: javax_faces_location_headClass: javax.faces.component.UIOutput,Id: j_id0} (component-family=javax.faces.Output, renderer-type=javax.faces.resource.Script)

      • No Renderer found for component {Component-Path : Class: com.ibm.faces20.portlet.UIPortletViewRoot,ViewId: /ajax.xhtmlClass: javax.faces.component.UIOutput,Id: j_id_2} (component-family=javax.faces.Output, renderer-type=javax.faces.resource.Script)

      Any ideas? thanks