PF 7.0.1 - Expression will just be added to the renderIds.

UI Components for JSF
Post Reply
marcelocaser
Posts: 122
Joined: 13 Dec 2011, 15:07

23 Apr 2019, 20:24

Hi,

Before the version PF 6.2.19 I had the following code:

Code: Select all

		<h:form id="frmAtendimento">
                        <p:poll .../>
                        <p:toolbar>
                            <f:facet name="right">
                                <p:commandButton ../>
                                <p:commandButton ..>
                                    <p:dataExporter type="xls" .. pageOnly="true"  />
                                </p:commandButton>
                                <p:tooltip for="timers" escape="false" ... position="top" />
                                <p:selectOneMenu id="timers" ... style="width:70px">
                                    <p:ajax event="change" partialSubmit="true" ../>
                                    <f:selectItem itemLabel="30''" itemValue="30"  />
                                    <f:selectItem itemLabel="2'" itemValue="120" />
                                    <f:selectItem itemLabel="5'" itemValue="300" />
                                </p:selectOneMenu>
                            </f:facet>

                            <f:facet name="left">
                                <p:commandButton ../>
                            </f:facet>
                        </p:toolbar>
                        <p:dataTable id="dtAtendimentos" var="twebatendimentosTO" widgetVar="atendimentos">
                            <f:facet name="{Exporters}">
                                <p:outputPanel id="pnlGlobalFilter" style="float: left;">
                                    <p:focus for="globalFilter"/>
                                    <p:tooltip for="globalFilter" showEffect="clip" escape="false" position="top">
                                       ...
                                    </p:tooltip>
                                    <p:inputText id="globalFilter" placeholder="#{msg.pesquisar}..." class="hidden-xm-down"/>
                                    <p:commandButton icon="fa fa-search" oncomplete="PF('atendimentos').filter()" style="margin-left: 10px" update="pnlGlobalFilter"/>
                                </p:outputPanel>
                            </f:facet>

                            <p:column ... visible="false">
                                <h:outputText .../>
                            </p:column>
                            
                            .....
              </h:form>
And in my "managed bean"

Code: Select all


public class CACBean  {

	....
	
@PostConstruct
    public void init() {
    ...
    listar();
}

public void listar() {
        try {
            lazyModelAtendimento = new LazyDataModel<TwebatendimentosTO>() {

                List<TwebatendimentosTO> twebatendimentosTOs = new ArrayList<>();

                @Override
                public List<TwebatendimentosTO> load(int first, int pageSize,
                        String sortField, SortOrder sortOrder,
                        Map<String, Object> filters) {
                    ...
                    return twebatendimentosTOs;
                }

                @Override
                public TwebatendimentosTO getRowData(String rowKey) {
                    ...
                    return null;
                }

                @Override
                public Object getRowKey(..) {
                    ..
                }

            };
            primefacesScrollTo("body");
            primefacesUpdate("frmAtendimento");
        } catch (Exception ex) {
            tratarExcecao(ex);
        }
        getFlash().put("lazyModelAtendimento", lazyModelAtendimento);
        }
}
}
	
and it worked normally. But now (PF 7.x) I'm getting the following exception:

Code: Select all

[http-nio-8084-exec-9] org.primefaces.PrimeFaces$Ajax.update PrimeFaces.current().ajax().update() called but component can't be resolved!Expression will just be added to the renderIds.
 org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression "frmAtendimento" referenced from "j_id1".
What is the best way to call the component update in my managed bean using PF 7.x?

I've noticed that the method call primefacesUpdate ("frmAtendimento"); is passing this exception:

Code: Select all

protected void primefacesUpdate(String idComponente) {
        if (idComponente != null && !idComponente.isEmpty()) {
            //getRequestContext().update(idComponente);
           PrimeFaces.current().ajax().update(idComponente);
        }
    }
PF 7.0.1
Mojarra 2.3.8
JEE 8

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

23 Apr 2019, 21:36

Please google how "findComponent" API of JSF works exactly.
If you frmAtendimento is a naming container, it can't be resolved with just the formId.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

marcelocaser
Posts: 122
Joined: 13 Dec 2011, 15:07

24 Apr 2019, 15:38

Hi,

Thanks for the tip!

I just implemented the code below:

Code: Select all

protected UIComponent getComponentById(String idComponente) {
        UIViewRoot view = getContext().getViewRoot();
        UIComponent component = view.findComponent(idComponente);
        return component;
    }
before calling:

Code: Select all

PrimeFaces.current().ajax().update(idComponente);
thanks!

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

24 Apr 2019, 15:59

hmpf, that should actually be the same result. If you can provide a example xhtml+bean which is runnable (maybe based on the showcase), i can check it.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

marcelocaser
Posts: 122
Joined: 13 Dec 2011, 15:07

24 Apr 2019, 16:29

very simple

Code: Select all

@Controller //spring implementation
@ViewScope //spring implementation
public class TestBean {

	private String name;

	@PostConstruct
	public void init() {
		list();	
	}
	
	public void list() {
		PrimeFaces.current().ajax().update("testForm:nameForm");
	}
	
	...... get/set

}

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:body>

    <h1>JSF Component</h1>

    <h:form id="testForm">
        <h:inputText id="nameForm" value="#{testBean.name}"/>
    </h:form>

</h:body>
</html>
When you run, you will receive the exception:

Code: Select all

[http-nio-8084-exec-9] org.primefaces.PrimeFaces$Ajax.update PrimeFaces.current().ajax().update() called but component can't be resolved!Expression will just be added to the renderIds.
But when you check if the "component" exists in the view:

Code: Select all

	...
	 UIComponent component = view.findComponent(idComponente);
...before calling:

Code: Select all

	PrimeFaces.current().ajax().update("testForm:nameForm");
the exception no longer occurs.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

24 Apr 2019, 16:47

works fine for me :/
copied the bean+xhtml into the showcase + switched the annotations to CDI (i dont use spring) and i dont get the warning/exception
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

marcelocaser
Posts: 122
Joined: 13 Dec 2011, 15:07

24 Apr 2019, 16:58

Maybe because I'm using Spring implementation ... = (, but in previous versions 6.2.19, it worked too .. without giving exception !!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests