Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:29:37+00:00 2026-06-17T11:29:37+00:00

It appears that primefaces <p:tree> is not an EditableValueHolder, even though it offers the

  • 0

It appears that primefaces <p:tree> is not an EditableValueHolder, even though it offers the ability to make the tree selectable. To me this seems like the very definition of EditableValueHolder as it both holds values (the list of nodes that are selected) and is editable (you can change the selection). In making the tree selectable, it basically turns it into a selectOneXxx/selectManyXxx. This is the fashion in which I use this widget. However, not being an EditableValueHolder, I cannot attach a validator to it directly. I could add validation to the form submission action with an actionListener but then it is out of the appropriate lifecycle phase and is much more difficult to get at the UITree component to check for attributes like the i18n message for failed validation. Has anyone dealt with this before? What do you do?

———- EDIT ———-

I found an issue posted in the primefaces bug tracker that seems releated:

http://code.google.com/p/primefaces/issues/detail?id=4137

And a forum post:

http://forum.primefaces.org/viewtopic.php?f=3&t=22340

———- EDIT ———-

This is the solution I came up with. Some of the jQuery is pretty hairy as it uses server side el to generate the client side javascript. But for the most part it works. Just have to figure out why an empty array skips validation… but thats another story.

<h:panelGroup id="pnpCois" styleClass="pnp-input-group pnp-cois">
  <h:outputLabel for="inputCois"
    value="#{i18n['communities-of-interest']}" />
  <p:tree id="inputCois"
    value="#{subscriptions.selected.coiTreeRootNode}" var="node"
    selectionMode="checkbox"
    selection="#{subscriptions.selected.selectedCoiNodes}">
    <p:ajax event="select" process="@this :#{component.clientId}_validator" update="@this"
      onstart="$('##{component.clientId}_validator'.replace(':','\\:')).val($('##{component.clientId}_selection'.replace(':','\\:')).val());" />
    <p:ajax event="unselect" process="@this :#{component.clientId}_validator" update="@this"
      onstart="$('##{component.clientId}_validator'.replace(':','\\:')).val($('##{component.clientId}_selection'.replace(':','\\:')).val());" />
    <p:treeNode>
      <h:outputText value="#{node}" />
    </p:treeNode>
  </p:tree>
  <h:inputHidden id="inputCois_validator">
    <f:converter converterId="asias.stringCsvToArray" /> 
    <f:validator validatorId="asias.atLeastOneSelected" />
    <f:attribute name="atLeastOneSelectedMessage"
      value="#{i18n['at-least-one-coi-must-be-selected']}" />
  </h:inputHidden>
</h:panelGroup>

———- EDIT ———-

After working through some suggestions with BalusC, I think I’m gonna give up on <p:tree> and find another way… 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:29:38+00:00Added an answer on June 17, 2026 at 11:29 am

    You can trick it with a required hidden input field whose value is altered on node click. You can use the selections property of the <p:tree> widget variable to get the available selections as an array.

    E.g.

    <h:form id="form">
        <p:tree widgetVar="tree" 
            onNodeClick="$('#form\\:treeSelections').val(tree.selections.length != 0 ? 'ok' : '')">
            ...
        </p:tree>
        <h:inputHidden id="treeSelections" required="true" 
            requiredMessage="Please select at least one tree node" />
        <p:message for="treeSelections" />
    </h:form>
    

    The 'ok' value is purely arbitrary. The point is that the hidden field is filled, so that the required validator doesn’t get triggered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It appears that that you can generate a standard documentation website (like this one
It appears that LIKE is not supported in Cypher queries. Is there any other
Appears that WAS does not support the integration binding. I've tried setting it up
It appears that second windows are not closing. Here is what I am doing....
Appears that java's sound API's work well for single streams, and even for setting
It appears that my script does not want to wait for the $.post call
It appears that glColorMaterial() is absent from OpenGL ES . According to this post
I have a button in primefaces, that when is pressed I make some calculations
It appears that I am not able to choose between two names for a
It appears that the Hibernate NotEmpty annotation does not result in an error for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.