Simple custom widget causes an error.

I have a simple widget:

<div xmlns:c=“” xmlns:h=“” xmlns:f=“” xmlns:nxu=“” xmlns:nxd=“”> < h:outputText style = “color: red; background: yellow; font-size: 40px;”

 value = "A string"/>&lt; /div>

I've built a layout with Studio which uses this widget to display the result: A static constant string in the value clause of the outputText tag.

The correct string is returned the first few (it varies)times; however after several successive calls to this widget I get the following error in the log:

java.lang.IllegalStateException: duplicate Id for a component document_edit:nxl_layout_BESMoldPeelTape-edit:nxw_template _1

    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.TreeStructureNode.apply(
    at org.ajax4jsf.application.AjaxStateManager.getTreeStructureToSave(
    at org.ajax4jsf.application.AjaxStateManager.buildViewState(
    at org.ajax4jsf.application.AjaxStateManager$SeamStateManagerWrapper.saveView(
    at org.jboss.seam.jsf.SeamStateManager.saveView(
    at org.ajax4jsf.application.AjaxStateManager.saveSerializedView(
    at com.sun.facelets.FaceletViewHandler.renderView(
    at org.ajax4jsf.application.ViewHandlerWrapper.renderView(
    at org.ajax4jsf.application.AjaxViewHandler.renderView(
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(
    at com.sun.faces.lifecycle.Phase.doPhase(

: The successive calls to this are after the document has transitioned to a different life cycle state or a new document is opened in some arbitrary life cycle state. If I uses a standard widget, to display some data about the document and cycle through the life cycle states and/or documents everything seems to work fine.

I believe there is something wrong with this widget.

Any suggestions?

0 votes

2 answers



I found the problem and a work around for my application. I do believe however there is more work that needs to be done defining exactly whether the operations which build the JSF id are a bug or a feature ;-)

It appears I had a JSF id collision between my custom widget and header widgets which were in some of the child documents mentioned in my comment above.

Bottom line is the custom widget ID's (JSF component ID's) in the Listings & Views -> Forms Layout used as a global header in each of the edit views of the child documents collided with the ID's generated by Nuxeo Header widgets I was using in each document. The collisions only occurred when I used a custom widget to display the “dynamic” string I mentioned above.

The workaround was to use a generic template/text widget with a value = #{my EL call}. It seems the generic template/text widget generates an ID for the Listing & Views -> Forms Layout “global header” that does not collide with the individual headers generated in the edit views of some of my child documents. The culprit seemed to be the word “template” that was used as a base for the ID with a suffix of one. Both the Listing & View and the individual edit-view software seemed to use the same algorithm to generate the ID's and they are unaware of each others existence hence the collision.

To see this problem create an edit view with a header widget and some text. Then create a Listing View-> Form Layout with a custom widget which just puts a static string into the value property. Try to display the edit-view and you should get the duplicate Id error seen above.

1 votes

Hi Karl,

Many thanks for this debugging, i'll definitely have a look as soon as i can, as this kind of situation is more and more likely to happen: we're spreading the layout model to more parts of the page (used in the "tabs" feature coming for 5.6).

I guess that's a bug in the machinery: trying to generate meaningful ids, but still keep them unique can be tricky…



Can't see what's wrong with this widget, what Nuxeo version are you using?

The error you see is a JSF error stating that two components with the same id are used in the page, but i'm not sure how it's related to your template, as it does not use the widget name or id and as you do not set any id attribute neither.

Are you using a custom layout template maybe?

And i don't understand if you're using this in a table layout or in a result layout. When you say “the first few times”, can you describe what you're referring to?

0 votes

Custom Layout: Studio generated custom layout in the Listings & Views -> Form Layout section. I created a layout and added a Template which uses my widget. The layout contains a single entry, not a table, which is my widget.

First Few Times: I have a container document which contains several 10-20 other documents. The container and each the documents within the container have a unique lifecycle. The parent document is cycled to its first lifecycle state. In the container each state corresponds to which of the child documents is currently active(the name of the state is the child document type therefore the current parent state is the currently active child document). Because child documents each have unique document types which correspond to the states of the parent document, the state of the parent dictates which child is current AND the sequence of activation for the child documents.

The life cycle of the "first" and subsequent child documents is started and is stepped through until and end point is reached, using custom Java actions. All this linkage and transitions between the parent and children is working and has worked for quite a while. The POJO that handles the all the transitions is an Automation Operation which gets called every time a "Next" button is pushed. Screen validation occurs in the POJO then a new (next child document) edit screen is displayed.

All this works with Nuxeo's standard widgets. The display is always in the EDIT view.

I have debugged the issue to JSF and my implementation of custom widget. Since the POJO logic and transitions are working I'm working on the view of these document and designing a custom widget based on a use case.

The "First Few Times" means I can sequence through the life cycle of the first child document to the end, the parent makes its transition to the next life cycle state and the next child document becomes "active" (a life cycle state other than start state). I can move the second child document through it's first transition and going into the second the error occurs, all of this occurs in the same screen without logging out so the JSF Sean context is the same.

Again error does not occur if I use a nuxeo standard widgets and display for example the currentLifeCycleState of the child document, I can cycle through 20 parent lifecycle states which implies 20 child document each with several life cycle states.

I need the custom widget to display text based on the current document's lifecycle state, I plan on using a EL call to fill in the value property in the widget when I get it working with a static string. I replaced the EL call with the static string, as part of my troubleshooting, this change did nothing, NO CHANGE, in the error. I only submitted the static string version to "Q&A" because the dynamic string generation EL call was not being used and wasn't the issue. Because the Nuxeo standard widgets work, I've concluded it's my custom widget implementation.


I forgot using V5.5 DM