Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Primefaces autoComplete

aCascaisFeb 17 2015 — edited Feb 19 2015

Hi.

I'm trying to implement Primefaces (version 5.1) using jdeveloper (version 11.1.2.4.0). This is the example i'm trying to implement: http://www.primefaces.org/showcase/ui/input/autoComplete.xhtml

I've been googling it around for the last 5 hours or so, but I still haven't solved my problem.

What did I do?

I created a new project from scratch and added the Primefaces library to both "Libraries and Classpath" and "Facelets Tag Libraries".

Then I created my view and 4 managed beans that represent the 4 classes that you can see in that example: AutoCompleteView, ThemeService, Theme and ThemeConverter.

Then I added the component to my view:

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"

        xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">

    <af:document title="view1.jsf" id="d1" binding="#{backingBeanScope.backing_view1.d1}">

        <af:form id="f1" binding="#{backingBeanScope.backing_view1.f1}">

            <af:commandButton text="commandButton 1" id="cb1" binding="#{backingBeanScope.backing_view1.cb1}"/>

        </af:form>

        <h:form>

    <p:growl id="msgs" showDetail="true" />

    <h:panelGrid columns="2" cellpadding="5">

        <p:outputLabel value="Custom Content:" for="themeCustom" />

        <p:autoComplete id="themeCustom" value="#{autoCompleteView.theme2}" completeMethod="#{autoCompleteView.completeTheme}"

                        var="theme" itemLabel="#{theme.displayName}" itemValue="#{theme}" converter="themeConverter" forceSelection="true"/>

            <p:column>

                <h:outputText styleClass="ui-theme ui-theme-#{theme.name}" />

            </p:column>

            <p:column>

                <h:outputText value="#{theme.displayName}" />

            </p:column>

        </p:autoComplete>

    </h:panelGrid>

    <p:commandButton value="Submit" icon="ui-icon-check" update="output msgs" oncomplete="PF('dlg').show()" />

    <p:dialog header="Values" resizable="false" showEffect="fade" widgetVar="dlg">

        <p:panelGrid id="output" columns="2" columnClasses="label, value">

            <h:outputText value="Custom Content:" />

            <h:outputText value="#{autoCompleteView.theme2}" />

        </p:panelGrid>

    </p:dialog>

</h:form>

    </af:document>

    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_view1-->

</f:view>

My problem is in completeMethod="#{autoCompleteView.completeTheme}" because I get the warning "completeTheme is an unknown property".

In my completeTheme method, the service variable is always null, so I'm getting a null point exception.

public List<Theme> completeTheme(String query) {
      
    List<Theme> allThemes = service.getThemes();
    List<Theme> filteredThemes = new ArrayList<Theme>();
   
    for (int i = 0; i < allThemes.size(); i++) {
        Theme skin = allThemes.get(i);
        if(skin.getName().toLowerCase().contains(query)) {
            filteredThemes.add(skin);
        }
    }
   
    return filteredThemes;
}

Then I tried to initialize the service variable in my method, but I still don't have the expected results. I get "

<PprResponseWriter$PPRTag> <finish> no PPR-capable ID found for elements of: org.primefaces.component.autocomplete.AutoComplete@a0dbd2"

public List<Theme> completeTheme(String query) {
    if(this.service==null){
        FacesContext context=FacesContext.getCurrentInstance();
        this.service=context.getApplication().evaluateExpressionGet(context, "#{themeService}",ThemeService.class);
    }
      
    List<Theme> allThemes = service.getThemes();
    List<Theme> filteredThemes = new ArrayList<Theme>();
   
    for (int i = 0; i < allThemes.size(); i++) {
        Theme skin = allThemes.get(i);
        if(skin.getName().toLowerCase().contains(query)) {
            filteredThemes.add(skin);
        }
    }
   
    return filteredThemes;
}

So... can anyone help me please? I'm probably doing some n00b mistake since I've only been working with ADF for the last 2 weeks or so...

Thank you in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2015
Added on Feb 17 2015
5 comments
773 views