incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Huber <mhu...@project-team.de>
Subject Re: Required attribute throws NullPointerException
Date Fri, 02 Mar 2007 15:10:13 GMT
Hello Matthias,

I wrote something about partial-page rendering to show and hide 
components to the wiki.

You find it under:
http://wiki.apache.org/myfaces/Partial-page_rendering

So others can add here examples to work with this feature. ;-)

Regards
Marco

Matthias Wessendorf wrote:
> Hello Marco,
> 
> would be great if you put that to our wiki ;-)
> 
> Thanks!
> Matthias
> 
> On 3/2/07, Marco Huber <mhuber@project-team.de> wrote:
>> Thank you Adam for your response.
>>
>> The solution putting the a4j component outside the form wouldn't work
>> for me, because I need both data (the selected item and the text) in my
>> action.
>>
>> But you gave me a hint about the partial-page rendering. I removed the
>> a4j commonents and use now the partial-page rendering supported from
>> trinidad. At that was the solution.
>> If I put now the required=true attribute to my inputText it works as
>> espected.
>>
>> Here my changed code, for those having a similar problem:
>>
>> <tr:selectOneRadio id="userAttributes"
>>      label="#{messages['selection']}"
>>      value="#{editAction.userAttribute}"
>>      required="true"
>>      requiredMessageDetail="#{messages['userAttribute.required']}"
>>      autoSubmit="true" >
>>          <f:selectItems value="#{editAction.userAttributeList}"/>
>> </tr:selectOneRadio>
>>
>> <tr:panelGroupLayout layout="horizontal" id="showCustomAttribute"
>> partialTriggers="editForm:userAttributes" >
>>      <tr:inputText id="customAttribute"
>>             label="#{messages['userAttribute.text']}"
>>             value="#{editAction.userAttribute.text}"
>>             rendered="#{editAction.userAttributeSelected}"
>>             required="true" />
>> </tr:panelGroupLayout>
>>
>> Thank you again
>> Marco
>>
>> Adam Winer wrote:
>> > The problem is in how Ajax4JSF handles partial-page rendering.  It 
>> skips
>> > over the form component entirely, so the Trinidad RenderingContext does
>> > not have a FormData object attached.
>> >
>> > Any Trinidad component that has client-side validation will result 
>> in the
>> > same error.
>> >
>> > Trinidad implements partial-page rendering very differently, using
>> > ResponseWriter
>> > filtering to only render the necessary component.
>> >
>> > You'd have to move the appropriate a4j: component outside of the h:form
>> > to get it working.
>> >
>> > -- Adam
>> >
>> >
>> >
>> > On 3/1/07, Marco Huber <mhuber@project-team.de> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> I have the problem that a required attribute throws a npe, but I can't
>> >> figured out where the problem lies. I hope some can help me on this
>> >> issue.
>> >>
>> >> I have a JSF page like followed:
>> >>
>> >>
>> >> <f:view xmlns="http://www.w3.org/1999/xhtml"
>> >>          xmlns:s="http://jboss.com/products/seam/taglib"
>> >>          xmlns:ui="http://java.sun.com/jsf/facelets"
>> >>          xmlns:f="http://java.sun.com/jsf/core"
>> >>          xmlns:h="http://java.sun.com/jsf/html"
>> >>          xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
>> >>          xmlns:tr="http://myfaces.apache.org/trinidad"
>> >>          xmlns:trh="http://myfaces.apache.org/trinidad/html" >
>> >>
>> >>      <h:form id="editForm">
>> >>
>> >>        <tr:selectOneRadio id="userAttributes"
>> >>                             label="#{messages['selection']}"
>> >>                             value="#{editAction.userAttribute}"
>> >>                             required="true"
>> >>
>> >> requiredMessageDetail="#{messages['userAttribute.required']}" >
>> >>              <f:selectItems value="#{editAction.userAttributeList}"/>
>> >>              <a4j:support event="onclick" 
>> reRender="showCustomAttribute"
>> >> />
>> >>
>> >>          </tr:selectOneRadio>
>> >>          <a4j:outputPanel id="showCustomAttribute" >
>> >>              <tr:inputText id="customAttribute"
>> >>                            label="#{messages['userAttribute.text']}"
>> >>                            value="#{editAction.userAttribute.text}"
>> >>                            
>> rendered="#{editAction.userAttributeSelected}"
>> >>                            required="true"
>> >>                          />
>> >>          </a4j:outputPanel>
>> >>
>> >>          <h:commandButton action="#{editAction..save}"
>> >> value="#{messages['button.save']}" />
>> >>          <h:commandButton action="#{editAction..cancel}"
>> >> value="#{messages['button.cancel']}" immediate="true" />
>> >>
>> >>      </h:form>
>> >>
>> >> </f:view>
>> >>
>> >> The UserAttribute is a abstract class with 2 inheritances:
>> >> BuildInAttribute and a CustomAttribute in which a text can added.
>> >> If I left out the required="true" in my tr:inputText all works 
>> fine. If
>> >> I define the attribute and I click on an instance of an new
>> >> CustomAttribute I got the following StackTrace:
>> >>
>> >> 12:01:26,765 ERROR [SeamExceptionFilter] exception root cause
>> >> java.lang.NullPointerException
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.EditableValueRenderer.addOnSubmitConverterValidators

>>
>> >>
>> >> (EditableVal
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputTextRenderer.encodeAllAsElement

>>
>> >>
>> >> (SimpleInputTextRender
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormElementRenderer.encodeAll

>>
>> >>
>> >> (FormElementRenderer.java:69)
>> >>          at
>> >> org.apache.myfaces.trinidad.render.CoreRenderer.delegateRenderer(
>> >> CoreRenderer.java:297)
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.InputLabelAndMessageRenderer.renderFieldCellContents

>>
>> >>
>> >> (InputLabelA
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.LabelAndMessageRenderer._renderFieldCell

>>
>> >>
>> >> (LabelAndMessageRenderer
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.LabelAndMessageRenderer.encodeAll

>>
>> >>
>> >> (LabelAndMessageRenderer.java:2
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.InputLabelAndMessageRenderer.encodeAll

>>
>> >>
>> >> (InputLabelAndMessageRende
>> >>          at
>> >> org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(
>> >> CoreRenderer.java:184)
>> >>          at
>> >> org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(
>> >> UIXComponentBase.java:701)
>> >>          at
>> >> 
>> org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java 
>>
>> >>
>> >> :249)
>> >>          at
>> >> org.ajax4jsf.framework.renderer.RendererBase.renderChildren(
>> >> RendererBase.java:225)
>> >>          at
>> >> org.ajax4jsf.renderers.ajax.AjaxOutputPanelRenderer.encodeChildren(
>> >> AjaxOutputPanelRenderer.java:74)
>> >>          at
>> >> 
>> javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java
>> >> :527)
>> >>          at
>> >> 
>> org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java 
>>
>> >>
>> >> :245)
>> >>          at
>> >> org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxChild(
>> >> AjaxChildrenRenderer.java:120)
>> >>          at
>> >> org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxChild(
>> >> AjaxChildrenRenderer.java:111)
>> >>          at
>> >> org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxChild(
>> >> AjaxChildrenRenderer.java:111)
>> >>          at
>> >> org.ajax4jsf.framework.renderer.AjaxChildrenRenderer.encodeAjaxChild(
>> >> AjaxChildrenRenderer.java:111)
>> >>          at
>> >> org.ajax4jsf.framework.renderer.AjaxContainerRenderer.encodeAjax(
>> >> AjaxContainerRenderer.java:126)
>> >>          at
>> >> 
>> org.ajax4jsf.framework.ajax.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:570) 
>>
>> >>
>> >>          at
>> >> 
>> org.ajax4jsf.framework.ajax.AjaxContext.renderAjaxRegion(AjaxContext.java
>> >> :301)
>> >>          at
>> >> org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(
>> >> AjaxViewHandler.java:249)
>> >>          at
>> >> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(
>> >> RenderResponseExecutor.java:41)
>> >>          at
>> >> 
>> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
>> >>          at
>> >> javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> >> ApplicationFilterChain.java:252)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> >> ApplicationFilterChain.java:173)
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter 
>>
>> >>
>> >> (TrinidadFilterImpl.java:210)
>> >>          at
>> >>
>> >> 
>> org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl 
>>
>> >>
>> >> (TrinidadFilterImpl.java:167)
>> >>          at
>> >> 
>> org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(
>> >> TrinidadFilterImpl.java:140)
>> >>          at
>> >> org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(
>> >> TrinidadFilter.java:93)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> >> ApplicationFilterChain.java:202)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> >> ApplicationFilterChain.java:173)
>> >>          at
>> >> org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(
>> >> BaseXMLFilter.java:75)
>> >>          at
>> >> 
>> org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java
>> >> :213)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> >> ApplicationFilterChain.java:202)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> >> ApplicationFilterChain.java:173)
>> >>          at
>> >> 
>> org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java 
>>
>> >>
>> >> :29)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> >> ApplicationFilterChain.java:202)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> >> ApplicationFilterChain.java:173)
>> >>          at
>> >> org.jboss.seam.servlet.SeamExceptionFilter.doFilter(
>> >> SeamExceptionFilter.java:43)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> >> ApplicationFilterChain.java:202)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> >> ApplicationFilterChain.java:173)
>> >>          at
>> >> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
>> >> ReplyHeaderFilter.java:96)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>> >> ApplicationFilterChain.java:202)
>> >>          at
>> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(
>> >> ApplicationFilterChain.java:173)
>> >>          at
>> >> org.apache.catalina.core.StandardWrapperValve.invoke(
>> >> StandardWrapperValve.java:213)
>> >>          at
>> >> org.apache.catalina.core.StandardContextValve.invoke(
>> >> StandardContextValve.java:178)
>> >>          at
>> >> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(
>> >> SecurityAssociationValve.java:175)
>> >>          at
>> >> org.jboss.web.tomcat.security.JaccContextValve.invoke(
>> >> JaccContextValve.java:74)
>> >>          at
>> >> 
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>> >> :126)
>> >>          at
>> >> 
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>> >> :105)
>> >>          at
>> >> org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(
>> >> CachedConnectionValve.java:156)
>> >>          at
>> >> org.apache.catalina.core.StandardEngineValve.invoke(
>> >> StandardEngineValve.java:107)
>> >>          at
>> >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
>> >> :148)
>> >>          at
>> >> 
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) 
>>
>> >>
>> >>          at
>> >>
>> >> 
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection

>>
>> >>
>> >> (Http11BaseProtocol.java:664)
>> >>          at
>> >> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
>> >> PoolTcpEndpoint.java:527)
>> >>          at
>> >> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(
>> >> MasterSlaveWorkerThread.java:112)
>> >>          at java.lang.Thread.run(Thread.java:619)
>> >>
>> >> All attribute in my class are initialized, so I don't think that the
>> >> problem lies on the access of the text attribute in my 
>> CustomAttribute.
>> >>
>> >> Thanks for you help
>> >> Marco
>> >>
>> >
>>
>>
> 
> 


Mime
View raw message