Note that there are some explanatory texts on larger screens.

plurals
  1. POchange outputText to inputText in primesface showcases
    primarykey
    data
    text
    <p>In the showcase <a href="http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf" rel="nofollow">http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf</a></p> <p>When the user click the edit button on row, we call </p> <pre><code>&lt;f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" /&gt; </code></pre> <p>to set the selectedCar and after that <code>update=":form:display"</code> will update the data of <code>h:outputText</code> in dialog and shown.</p> <p>But when I change the <code>&lt;h:outputText&gt;</code> to <code>&lt;h:inputText&gt;</code> the <code>&lt;f:setPropertyActionListener&gt;</code> does not work anymore, so it raise the exception. Here is the code and exception: datatableRowSelection.xhtml</p> <pre><code> &lt;h:form id="form"&gt; &lt;p:growl id="msgs" showDetail="true" /&gt; &lt;p:dataTable id="cars" var="car" value="#{tableBean.carsSmall}"&gt; &lt;p:column headerText="Model" style="width:24%"&gt; &lt;h:outputText value="#{car.model}" /&gt; &lt;/p:column&gt; &lt;p:column headerText="Year" style="width:24%"&gt; &lt;h:outputText value="#{car.year}" /&gt; &lt;/p:column&gt; &lt;p:column headerText="Manufacturer" style="width:24%"&gt; &lt;h:outputText value="#{car.manufacturer}" /&gt; &lt;/p:column&gt; &lt;p:column headerText="Color" style="width:24%"&gt; &lt;h:outputText value="#{car.color}" /&gt; &lt;/p:column&gt; &lt;p:column style="width:4%"&gt; &lt;p:commandButton id="selectButton" update=":form:display" oncomplete="carDialog.show()" icon="ui-icon-search" title="View"&gt; &lt;f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" /&gt; &lt;/p:commandButton&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;p:dialog header="Car Detail" widgetVar="carDialog" resizable="false" id="carDlg" showEffect="fade" hideEffect="explode" modal="true"&gt; &lt;h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;"&gt; &lt;f:facet name="header"&gt; &lt;p:graphicImage value="/images/cars/#{tableBean.selectedCar.manufacturer}.jpg"/&gt; &lt;/f:facet&gt; &lt;h:outputText value="Model:" /&gt; &lt;h:outputText value="#{tableBean.selectedCar.model}" style="font-weight:bold"/&gt; &lt;h:outputText value="Year:" /&gt; &lt;h:outputText value="#{tableBean.selectedCar.year}" style="font-weight:bold"/&gt; &lt;h:outputText value="Manufacturer:" /&gt; &lt;h:inputText value="#{tableBean.selectedCar.manufacturer}" style="font-weight:bold"/&gt; &lt;!-- I changed outputText to inputText here --&gt; &lt;h:outputText value="Color:" /&gt; &lt;h:inputText value="#{tableBean.selectedCar.color}" style="font-weight:bold"/&gt; &lt;!-- I changed outputText to inputText here --&gt; &lt;/h:panelGrid&gt; &lt;/p:dialog&gt; &lt;/h:form&gt; </code></pre> <p>TableBean.java</p> <pre><code>import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; import org.primefaces.examples.domain.Car; public class TableBean { static { colors = new String[10]; colors[0] = "Black"; colors[1] = "White"; colors[2] = "Green"; colors[3] = "Red"; colors[4] = "Blue"; colors[5] = "Orange"; colors[6] = "Silver"; colors[7] = "Yellow"; colors[8] = "Brown"; colors[9] = "Maroon"; manufacturers = new String[10]; manufacturers[0] = "Mercedes"; manufacturers[1] = "BMW"; manufacturers[2] = "Volvo"; manufacturers[3] = "Audi"; manufacturers[4] = "Renault"; manufacturers[5] = "Opel"; manufacturers[6] = "Volkswagen"; manufacturers[7] = "Chrysler"; manufacturers[8] = "Ferrari"; manufacturers[9] = "Ford"; } private final static String[] colors; private final static String[] manufacturers; private List&lt;Car&gt; cars; private Car selectedCar; public TableBean() { cars = new ArrayList&lt;Car&gt;(); populateRandomCars(cars, 50); } private void populateRandomCars(List&lt;Car&gt; list, int size) { for(int i = 0 ; i &lt; size ; i++) list.add(new Car(getRandomModel(), getRandomYear(), getRandomManufacturer(), getRandomColor())); } public Car getSelectedCar() { return selectedCar; } public void setSelectedCar(Car selectedCar) { this.selectedCar = selectedCar; } public List&lt;Car&gt; getCars() { return cars; } private int getRandomYear() { return (int) (Math.random() * 50 + 1960); } private String getRandomColor() { return colors[(int) (Math.random() * 10)]; } private String getRandomManufacturer() { return manufacturers[(int) (Math.random() * 10)]; } private String getRandomModel() { return UUID.randomUUID().toString().substring(0, 8); } } </code></pre> <p>And the Exception is:</p> <pre><code>WARNING: datatableRowSelection.xhtml value="#{tableBean.selectedCar.model}": Target Unreachable, 'selectedCar' returned null javax.el.PropertyNotFoundException: datatableRowSelection.xhtml value="#{tableBean.selectedCar.model}": Target Unreachable, 'selectedCar' returned null at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95) at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1034) at javax.faces.component.UIInput.validate(UIInput.java:964) at javax.faces.component.UIInput.executeValidate(UIInput.java:1237) at javax.faces.component.UIInput.processValidators(UIInput.java:702) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:506) at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1612) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) at javax.faces.component.UIForm.visitTree(UIForm.java:371) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:378) at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:253) at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183) at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1162) at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) </code></pre> <p>Could you please tell me why? Thanks so much</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload