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 8401323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:46:36+00:00 2026-06-09T21:46:36+00:00

I am new with Primefaces and I try to use a treeTable from Primefaces

  • 0

I am new with Primefaces and I try to use a treeTable from Primefaces 3.3.1.
Only the first record of the TreeTable is shown at the beginning. Then, when I click on the little image to expand the TreeTable, nothing happens. In FireBug, I can se the following result:

<partial-response>
    <error>
        <error-name>class java.lang.StringIndexOutOfBoundException</error-name>
        <error-message>String index out of range: -1</error-message>
    </error>
</partial-response>

If I force my treeTable to be expanded with node0.setExpanded(true), then the TreeTable is expanded. Then I can collapse it but again, I am no more able to expand it.
In other posts, it is written that the model and/or the bean must implements Serializable. I try but it does not work.

Below, my model (what will be placed in each record of the TreeTable):

public class MyModel{
    private String field_1;
    private String field_2;
    public MyModel(){};
    public MyModel(String field_1, String field_2){
        this.field_1 = field_1;
        this.field_2 = field_2;
    }
    //Getters and setters
}    

Below, the JSF Managed bean that create the TreeTable:

@ManagedBean
@SessionScoped
public class MyManagedBean{
    public TreeNode root;
}
public MyManagedBean{
    root = new DefaultTreeNode("root",null);
    TreeNode node0 = new DefaultTreeNode(new MyModel("Field 1", "Field 2"), root);
    TreeNode sub0 = new DefaultTreeNode(new MyModel("Sub", "Sub"), node0);
    //node0.setExpanded(true);
}
public TreeNode getRoot(){
    return root;
}

Finally, my JSF file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>
        <h:body>
            <p:treeTable value="#{myManagedBean.root}" var="test">    
            <p:column>
                <f:facet name="header">
                    Field 1
                </f:facet>
                <h:outputText value="#{test.field_1}" />
            </p:column>
            <p:column>
                <f:facet name="header">
                    Field 2
                </f:facet>
                <h:outputText value="#{test.field_2}" />
            </p:column>
        </p:treeTable>
    </h:body>
</f:view>

Thank you in advance for your help!

  • 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-09T21:46:38+00:00Added an answer on June 9, 2026 at 9:46 pm

    Solved it. I forgot to wrap the treeTable in an h:form tag. It works fine now.

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

Sidebar

Related Questions

I am new to primefaces and I want to use autocomplete tag of primeface.So
hi im kind of new at jsf enviroment, im trying to update a primefaces
New to PHP and MySQL, have heard amazing things about this website from Leo
New developer here,Im using the Custom Image Picker by ray wenderlich. But what I
I am new to jQuery. I have PrimeFaces dataTable. when it is converted to
i am new to primeface. i have tried to test an example of primefaces
Hope you all will be fine. Actually i want to upload image files from
I am trying to display a button with image only on my page but
I am new to Eclipse. Currently developing a sample web application using primefaces 3.1
I want to dynamically load images from a database withing a PrimeFaces data table.

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.