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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:41:08+00:00 2026-05-28T05:41:08+00:00

I am new to Stack Overflow and have a question about JSF 2.0 and

  • 0

I am new to Stack Overflow and have a question about JSF 2.0 and custom components (i use primefaces 3 too, buts not that important i think). Here is the situation: I have a nested data object of type AdvancedCriterion, which contains a list of AdvancedCriterion or Criterion (via an interface criteria). These criterions are used to create a complex filter object like this:

  • Advanced Criterion: AND
    • Criterion: PRODUCT equals “ABC”
    • Criterion: USER startswith “A”
    • AdvancedCriterion: OR
      • CRITERION: param1 > 5
      • CRITERION: param2 <= 20

I created two new components in Java: AdvancedCriterion.java and SimpleCriterion.java to do the recursion, because the first attempt to do it with a composite fails. and recursive call of a composite in a composite creates a stack overflow 🙁

Until know i can display a static filter object and it looks fine, but the user should add or delete criterions. So i addes some buttons (here came primefaces into it). Here some code, i started with the first criterion, which is always AdvancedCriterion.

<myTag:advancedCriteriaComponent criteria="#{manageFiltersBean.filterBuilder.criteria}" />

I create know the Button and want to give the parent object to the ActionListener:

CommandButton addButton = new CommandButton();
addButton.setId("btnAdd" + UUID.randomUUID());
addButton.setAjax(true);
addButton.setValue(" + ");
addButton.addActionListener(new CriteriaActionListener());
addButton.getAttributes().put("criteria", this.currentCriteria);

Well, and here comes the CriteriaActionListener:

@Override
    public void processAction(ActionEvent event) throws AbortProcessingException {
        AdvancedCriteria criteria = (AdvancedCriteria) event.getComponent().getAttributes().get("criteria");
        criteria.addCriteria(new Criterion());
        System.out.println("number of children: " + criteria.getChildren().size());

    }

In the component the currentCriteria is well known and i can see his child-elements. In the CriteriaActionListener the object is empty (It has the right type, but looks like a fresh initalized object of this type) The question now: How could i get the currentCriteria Object into the CriteriaActionListener?

I tried a attribute in the ActionListener and set it from the component, then the whole object is NULL. I although tried to make an ELExpression and get it right to the bean (#{manageFiltersBean.addCriterion(criteria}) but the object is NULL. I have no more ideas and unfortunatly i am very new to JSF (about a few weeks).

Maybe it is about the id of the buttons? They are random, because the number of buttons is dynamic. I read, that every button must have an unique id to work properly. Or it is something about the attributes/params?

Thank you for your help,

Felix

  • 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-05-28T05:41:08+00:00Added an answer on May 28, 2026 at 5:41 am

    This problem is solved, some others occur. Well, like commented above, the problem was more like an problem with the implementation of the ‘AdvancedCriteria’ object. There was no connection or hint to the ‘CommandButton’, just a miss-named getter.

    Probably the added line implements Serialiable helps although, I don’t know exactly, because I tried a lot of things (save and restore states, enumeration propKeys with setters and getters and stuff like this), overall these weren’t the solution.

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

Sidebar

Related Questions

I'm new to Stack Overflow, but I have a question about writing some Java
I am fairly new to Java and in another Stack Overflow question about for
I'm new to SOA (and to Stack Overflow too...) Some services and web applications
First question on Stack Overflow, apologies if it is not well formed. I am
I have already come across the Stack Overflow question Is there a way to
I'm aware that questions about the stack vs. the heap have been asked several
I'm new here to stackoverflow, so bear with me. I have a book that
This is my first question here on stack overflow. i need help on a
A couple of years ago, before I knew about Stack Overflow, I was working
In a recent question on Stack Overflow , I asked how I might parse

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.