p:dataTable disappears after page update

UI Components for JSF
Post Reply
marcos.alcantara
Posts: 8
Joined: 28 Jul 2010, 19:30

28 Jul 2010, 21:21

Hi,

My problem seems to be like this one http://primefaces.prime.com.tr/forum/vi ... 23&p=16373, but I am not using axaj request and have other issues that I will try to explain (and sorry for my poor english):

I have register in faces-config a custom ExceptionHandlerWrapper that handle certain types of exception, to show a friendly message to the end user. Snippet code:

Code: Select all

public class CustomExceptionHandler extends ExceptionHandlerWrapper {

    private ExceptionHandler wrapped;
	
    public CustomExceptionHandler(ExceptionHandler wrapped) {
        this.wrapped = wrapped;
    }
 
    @Override
    public ExceptionHandler getWrapped() {
        return this.wrapped;
    }

    @Override
    public void handle() throws FacesException {
        for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
            ExceptionQueuedEvent event = i.next();
            ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
            Throwable t = context.getException();
            BussinesException be = this.getBussinesException(t); // BussinesException is my custom exception
            if (be != null) {
                // if it is BussinesException add a message
            	FacesContext facesContext = FacesContext.getCurrentInstance();
            	facesContext.addMessage(null, 
            			new FacesMessage(FacesMessage.SEVERITY_WARN, be.getMessage(), ""));
            	facesContext.renderResponse();
                // remove exception from the stack
                i.remove();
                continue;
            }
         }
        // all BussinesException was removed
        // let the default handle do your job
        getWrapped().handle();
 
    }

...

}
Here´s my MBean:

Code: Select all

@Named
@ViewScoped 
public class TestMBean implements Serializable {

	private String testStr;

	public List<String> getAll() {
		List<String> all = new ArrayList<String>();
		all.add("test");
		all.add("test1");
		all.add("test2");
		return all;
	}
	
	public void testException() {
		throw new BussinesException("exception test!");
	}

        // gets and sets

}
xhtml:

Code: Select all

...
	<h:inputText id="input" value="#{testMBean.testStr}" label="Test str" required="true"/>

	<p:dataTable var="item" value="#{testMBean.all}">
	    <p:column>
	           #{item}
	    </p:column>
	    <p:column>
	           <p:commandButton title="test" 
	           	immediate="true" ajax="false"
	           	action="#{testMBean.testException}"
	           	image="ui-icon-trash"/>
	    </p:column>
	</p:dataTable>

...
The <p:dataTable> disappears when the testMBean.testException is requested by <p:commandButton>.
Actually, the <p:dataTable> only disappears because of "facesContext.renderResponse();" on the CustomExceptionHandler, but I really need this line because in my xhtml I have an input with "required='true'", and I don´t want this validation occurs.

I must say that all is working if I use the <h:dataTable>.

That is it.
Marcos.
primefaces 3.0M4, JDK 1.6, glassfish v3.1.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests