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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:41:21+00:00 2026-06-17T18:41:21+00:00

I have a problem when dynamically instantiating a PF 3.4.2 AutoComplete component. The component

  • 0

I have a problem when dynamically instantiating a PF 3.4.2 AutoComplete component.
The component intially renders ok, its value is refreshed on partial processing
but the suggestions are never displayed.

I am instantiating this control the following way :

    AutoComplete ac = (AutoComplete) context.getApplication().createComponent(AutoComplete.COMPONENT_TYPE);
    final String varName = "p";

    ValueExpression ve = JSFUtils.createValueExpression("#{minContext.selected.sen}"), Sen.Type);
    ac.setValueExpression("value", ve);

    ac.setForceSelection(true);

    ac.setVar(varName);

    ValueExpression itemLabel = JSFUtils.createValueExpression("#{sc:senLibelle(p)}"), String.class);
    ac.setValueExpression("itemLabel", itemLabel);

    ValueExpression itemValue = JSFUtils.createValueExpression("#{" + varName + "}");
    ac.setValueExpression("itemValue", itemValue);

    MethodExpression completeMethod = JSFUtils.createMethodExpression("#{senUtils.completeAllSens}", List.class,new Class[]{String.class});
    ac.setCompleteMethod(completeMethod);

then adding it to parent control using

    getChildrens().add(ac);

The parent component is a derivation of PF PanelGrid. I use this approach successfully to generate various edition panels and it works like a charm. But I can not figure why it does not with autoComplete.

The parent control looks like :

@FacesComponent(SenatDataTableEntryDetail.SENAT_COMPONENT_TYPE)
public class SenatDataTableEntryDetail extends PanelGrid {

    /** Leaving renderer unchanged, so that PF renderer for PanelGrid is used.
     */
    public static final String SENAT_COMPONENT_FAMILY = "fr.senat.faces.components";
    public static final String SENAT_COMPONENT_TYPE = SENAT_COMPONENT_FAMILY + ".SenatDataTableEntryDetail";

    private enum PropertyKeys { mapper, bean; }

    @Override
    public void encodeBegin(FacesContext context) throws IOException {
        super.encodeBegin(context);
        addDynamicChildren(context);
    }

    @Override
    public boolean getRendersChildren()
    {
        return true;
    }

    ...

    private Boolean isInitialized() {
        return (Boolean)getStateHelper().eval(SENAT_INITIALIZED,false);
    }

    private void setInitialized(Boolean param) {
        getStateHelper().put(SENAT_INITIALIZED, param);
    }

    private void addDynamicChildren(FacesContext context)  throws IOException {
        if(isInitialized()) {
            return;
        }
        setInitialized(true);
        /* components are instiated and added as children only once */
    }    
}

It just adds children to the panel grid.

The other aspects of custom component declaration (in taglib and so on) are ok.

The problem doest not seem to be in EL expressions, completeMethod definition, etc. If I include in my test xhtml page an instanciation of the p:autoComplete with the very same parameters, it just works as expected :

    <p:autoComplete value="#{minContext.selected.sen}" forceSelection="true" 
                        var="p" itemLabel="#{sc:senLibelle(p)}" itemValue="#{p}"
                        completeMethod="#{senUtils.completeAllSens}"/>

I noticed that the PF AutoComplete component is a bit special as it renders differently
when a query is detected. See AutoCompleteRenderer source code in http://primefaces.googlecode.com/files/primefaces-3.4.2.zip .

In the “dynamically instantiated” case, the decode method of this component is not called. I failed to find why those last days, but did not succeed.

I look forward for your suggestions on what to check to correct this annoying “bug”.

  • 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-17T18:41:22+00:00Added an answer on June 17, 2026 at 6:41 pm

    So, the problem was in id generation (see the two comments).

    The beginning of component instantiation becomes :

    AutoComplete ac = (AutoComplete) context.getApplication().createComponent(AutoComplete.COMPONENT_TYPE);
    ac.setParent(this);
    ac.setId(...some application specific unique id generation...);
    
    final String varName = "p";
    

    This way, the naming container is properly taken in account on client id generation.

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

Sidebar

Related Questions

I am loading some text dynamically into a div, but have the problem that
I have a button which needs to get created dynamically but the problem is
Hi I have a problem about dynamically displaying the value of a HtmlSelectOneMenu. Below
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
so I have a problem with dynamically adding items to menuStrip. I mean I
I have a problem with adding OPTIONS to SELECT tag dynamically. Here is my
Fact: I'm not that good with jQuery. Problem: I have a form containing dynamically
I have run into a strange problem, i am creating a lot of dynamically
Newbie here! My problem is as follows: I have a dynamically populating ul where
I have a problem with dynamically added script element (using jQuery). Code for adding

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.