Target Unreachable, 'null' returned null javax.el.PropertyNo

UI Components for JSF
Post Reply
pr0x1
Posts: 20
Joined: 15 Sep 2010, 04:15
Location: Cali-Colombia

19 Oct 2010, 06:22

Hi.. i have been reading the topics with this problem but don´t exist a solution,

for representante this problem i will use the showcase exaplames "Collector http://www.primefaces.org/showcase/ui/collector.jsf and datatable Instant Row Selection
http://www.primefaces.org/showcase/ui/d ... nstant.jsf

when I press add , the code throw a exception
javax.faces.component.UpdateModelException: javax.el.PropertyNotFoundException: /Test.xhtml @91,65 value="#{createBookBean.book.editorial}": Target Unreachable, 'book' returned null
So, when i change de inputText in the p:dialog by a outputText works fine, Any idea?

Please somebody help me!!! i hope your comments

this is the code xhtml

Code: Select all

         <ui:define name="content">
        
          <h:form id="form">

                <p:panel header="Create a new book">
					<h:panelGrid columns="2">
						<h:outputLabel value="Title : *" for="txt_title"></h:outputLabel>
						<h:inputText id="txt_title" value="#{createBookBean.titulo}" required="true"/>
						
						<h:outputLabel value="Author : *" for="txt_author"></h:outputLabel>
						<h:inputText id="txt_author" value="#{createBookBean.autor}" required="true"/>
						
						<p:commandButton value="Reset" type="reset"/>
						<p:commandButton value="Add" update="books"  action =  "#{createBookBean.reinit}"  actionListener = "#{createBookBean.add}"/>
							
					
					</h:panelGrid>
				</p:panel>
				
				<p:ajaxStatus style="width:16px;height:16px;">
					<f:facet name="start">
						<h:graphicImage value="../design/ajaxloading.gif" />
					</f:facet>
					
					<f:facet name="complete">
						<h:outputText value="" />
					</f:facet>
				</p:ajaxStatus>
				
				<p:outputPanel id="books">
			
				<p:dataTable id="entries" value="#{createBookBean.books}" var="book"  emptyMessage="No entries found" dynamic="true"
					selection="#{createBookBean.book}" selectionMode="single" onselectComplete="carDialog.show()" update="display"					>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Title" />
							</f:facet>
							<h:outputText value="#{book.title}" />
						</p:column>
	
						<p:column>
							<f:facet name="header">
								<h:outputText value="Author" />
							</f:facet>
							<h:outputText value="#{book.author}" />
						</p:column>
	
						<p:column>
							<f:facet name="header">
								<h:outputText value="Operation" />
							</f:facet>
							<p:commandLink value="Remove" update="books">
								<p:collector value="#{book}" removeFrom="#{createBookBean.books}" />
							</p:commandLink>
						</p:column>
						<p:column style="width:32px">  
            					<p:commandButton update="display" oncomplete="carDialog.show()" >  
                						<f:setPropertyActionListener value="#{book}"  target="#{createBookBean.book}" />  
            			</p:commandButton>  
        				</p:column> 
 
					</p:dataTable>
				</p:outputPanel>
				
		 <p:dialog header="Car Detail" widgetVar="carDialog" resizable="false"  
                           width="200" modal="true" draggable="false">  

       			<h:panelGrid id="display" columns="2" cellpadding="4">  
            				<h:inputText value="#{createBookBean.book.editorial}" />  
            		</h:panelGrid>
          </p:dialog>

			</h:form>
			
				
         </ui:define>

CreateBookBean

Code: Select all


@ManagedBean(name="createBookBean") 
@ViewScoped
public class CreateBookBean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4760165510561347983L;

	private Book book = new Book();
	private String titulo;
	private String autor;
	private List<Book> books = new ArrayList<Book>();
	
	private BookService bookService = new BookServiceImpl();	
	
	
	public CreateBookBean(){
		 books = new ArrayList<Book>();
		 book = new Book();
		 bookService = new BookServiceImpl();	
		
	}
	public String reinit() {
		Book s= new Book();
		s.setAuthor(autor);
		s.setTitle(titulo);
		book = s;
		
		return null;
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public List<Book> getBooks() {
		return books;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}
	public void add(ActionEvent e){
		Book s= new Book();
		s.setAuthor(autor);
		s.setTitle(titulo);
		book = s;
		books.add(book);
	}

	public void setTitulo(String titulo) {
		this.titulo = titulo;
	}

	public String getTitulo() {
		return titulo;
	}

	public void setAutor(String autor) {
		this.autor = autor;
	}

	public String getAutor() {
		return autor;
	}
}

Book bean

Code: Select all

/*
 * Copyright 2009 Prime Technology.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package bean;



import java.io.Serializable;



public class Book implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5245540204809648658L;
	/**
	 * 
	 */
	

	private String title;
    private String editorial;
    private String genero;
	private String author;

	private String publisher;

	private Integer pages;

	public Book(){
		
	}
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public Integer getPages() {
		return pages;
	}

	public void setPages(Integer pages) {
		this.pages = pages;
	}

	public boolean equals(Object obj) {
		if(!(obj instanceof Book))
			return false;
		
		Book book = (Book) obj;
		
		return (book.getTitle() != null && book.getTitle().equals(title)) && (book.getAuthor() != null && book.getAuthor().equals(author));
	}

	public int hashCode() {
		int hash = 1;
		if(title != null)
			hash = hash * 31 + title.hashCode();
		
		if(author != null)
			hash = hash * 29 + author.hashCode();

		return hash;
	}

	public void setEditorial(String editorial) {
		this.editorial = editorial;
	}

	public String getEditorial() {
		return editorial;
	}

	public void setGenero(String genero) {
		this.genero = genero;
	}

	public String getGenero() {
		return genero;
	}
	
}

Please somebody help me!!! i hope your comments
  • primefaces 2.2.RC2
    Mojarra 2.0.3 (FCS b03)
    Eclipse Helios
    Tomcat 7.0.2

pr0x1
Posts: 20
Joined: 15 Sep 2010, 04:15
Location: Cali-Colombia

20 Oct 2010, 05:36

Any idea???
  • primefaces 2.2.RC2
    Mojarra 2.0.3 (FCS b03)
    Eclipse Helios
    Tomcat 7.0.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests