RE: Exception while rendering button in a component
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Rajesh,
Based on the error that is occurring, it is apparent that you are using a
browser that isn't recognized as supporting javascript by Barracuda or you
are using a render strategy equal to RenderStrategy.NEVER_SCRIPT, otherwise
that block of code would never be reached. Notice...
//if the client supports Javascript...
if (vc.getViewCapabilities().getScriptingType() instanceof
ScriptingType.JavaScript1x
&& comp.getRenderStrategy() != RenderStrategy.NEVER_SCRIPT) {
...
...
} else { //else do it the manual way
//make sure the button type is submit
if (!"submit".equalsIgnoreCase(el.getType())) {
String errmsg = "Cannot render Input action listener; input type
is not 'submit': "+el;
logger.warn(errmsg);
throw new NoSuitableRendererException(errmsg);
}
//rename the button appropriately (don't encode)
el.setName(FormGateway.FORM_TARGET+comp.getAction(vc, true));
//redirect the form to event forwarding servlet (encode)
fel.setAction(URLRewriter.encodeURL(vc,
NamingHelper.getName(fel)+FormGateway.FORM_EXT));
}
So, that's one issue. What browser are you using? The other issue is
that, currently, if any browser recognized by Barracuda as supporting
javascript has javascript turned off, we still render as if the browser has
javascript turned on. That is, we run the "if" block rather than the
"else" block no matter what (except, of course for the case where Barracuda
doesn't recognize the browser as supporting javascript in the first place
or scripting is explicitly turned off by the developer).
Those issues aside, the reason why it is coded this way is that your <input
type="button"> element is useless unless javascript is enabled. How will
an <input type="button"> submit a form except via javascript? That said,
it might be worth considering how we might treat this as a non-fatal
situation or maybe switch the <input type="button"> to <input
type="submit"> on the fly. Of course, first we have to actually detect
that the browser's javascript is currently enabled or not, not just that
the browser of this type theoretically supports javascript. And again,
Rajesh, what browser are you using? I'm not even sure how to test the
current code to enter into the "else" block except for forcing the browser
to send a bogus user agent header.
And then there is the question about where exactly that null pointer
exception is coming from? I have a hunch, but can't test it unless I tweak
some code to force the "if" block to be run. Hmmm....
Jake
At 05:25 PM 6/23/2003 -0700, you wrote:
>Hello Jake,
>
>I have changed 'HTMLActionRenderer.java' file to support button of type
>'button' -- other than sumbit button( see line# 246). Otherwise the code
>throws an exception 'NoSuitableRendererException'. I have attached the
>changed java file.
>Let me know if there is any other way to support button of type 'button'.
>
>Thanks.
>Rajesh
>
>
>
>Stack Trace:
>17:13:45,527 INFO [BComponent] adding in temp views [@56acfa]
>
>17:13:45,527 INFO [BComponent] rendering view: View:@768dc8 (bound to Node:)
>
>17:13:45,527 INFO [AbstractBComponent] Looking up renderer factory for
>comp:class org.enhydra.barracuda.core.comp.BAction fo
>
>r dom:class org.enhydra.xml.lazydom.html.HTMLInputElementImpl
>
>17:13:45,527 INFO [HTMLActionRenderer] Rendering based on HTMLInputElement
>interface...
>
>17:13:45,527 ERROR [STDERR] java.lang.NullPointerException
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.html.HTMLActionRenderer.manipulateActionElement(HTMLActionRenderer.java:246)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.html.HTMLActionRenderer.manipulateActionElement(HTMLActionRenderer.java:122)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.html.HTMLActionRenderer.renderComponent(HTMLActionRenderer.java:99)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.renderView(BComponent.java:567)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.render(BComponent.java:462)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.render(BComponent.java:480)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.render(BComponent.java:388)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.getNode(TemplateHelper.java:462)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.copyChildNodes(TemplateHelper.java:131)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.getNode(TemplateHelper.java:618)
>
>17:13:45,527 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.copyChildNodes(TemplateHelper.java:131)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.getNode(TemplateHelper.java:618)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.copyChildNodes(TemplateHelper.java:131)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.getNode(TemplateHelper.java:618)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.copyChildNodes(TemplateHelper.java:131)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.getNode(TemplateHelper.java:618)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.copyChildNodes(TemplateHelper.java:131)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.TemplateHelper.render(TemplateHelper.java:109)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.renderer.html.HTMLTemplateRenderer.renderComponent(HTMLTemplateRenderer.java:114)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.renderView(BComponent.java:567)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.render(BComponent.java:462)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.comp.BComponent.render(BComponent.java:388)
>
>17:13:45,543 ERROR [STDERR] at
>com.efi.apps.mayfly.presentation.screens.QuickTicketLiteScreen$RenderQuickTicketLiteHandler.handleViewEventQuickTicketLiteScreen.java:912)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.DefaultBaseEventListener.handleEvent(DefaultBaseEventListener.java:66)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.DefaultEventDispatcher.notifyListeners(DefaultEventDispatcher.java:421)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.DefaultEventDispatcher.dispatch(DefaultEventDispatcher.java:185)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.DefaultEventDispatcher.dispatchEvent(DefaultEventDispatcher.java:122)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.DefaultEventBroker.dispatchEvent(DefaultEventBroker.java:494)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.ApplicationGateway.handleDefaultExt(ApplicationGateway.java:404)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.ApplicationGateway.handleDefault(ApplicationGateway.java:234)
>
>17:13:45,543 ERROR [STDERR] at
>com.efi.apps.mayfly.PrintMeProGateway.handleDefault(PrintMeProGateway.java:117)
>
>17:13:45,543 ERROR [STDERR] at
>org.enhydra.barracuda.core.event.ApplicationGateway.doGet(ApplicationGateway.java:717)
>
>17:13:45,543 ERROR [STDERR] at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>
>17:13:45,543 ERROR [STDERR] at
>javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
>17:13:45,543 ERROR [STDERR] at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
>
>17:13:45,543 ERROR [STDERR] at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
>
>17:13:45,543 ERROR [STDERR] at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
>
>17:13:45,543 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
>
>17:13:45,543 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
>
>17:13:45,543 ERROR [STDERR] at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1040)
>
>17:13:45,558 ERROR [STDERR] at
>org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1151)
>
>17:13:45,558 ERROR [STDERR] at java.lang.Thread.run(Thread.java:536)
>
>17:13:45,558 INFO [DefaultEventBroker] Dispatch complete!
>
>17:13:45,558 INFO [ApplicationGateway] Dispatching complete! (handled in
>8702 of 8702 millis)
>
>17:13:45,558 INFO [DefaultEventPool] Releasing event
>com.efi.modules.pmpro.presentation.events.GetQuickTicketLite@11050be
>
>17:13:45,558 INFO [ObjectRepository] Removed session repository:
>SessionOR_HttpProcessor[80][1]
>
>17:13:45,558 INFO [ObjectRepository] Removed local repository:
>LocalOR_HttpProcessor[80][1]
>
>
>
>
>-----Original Message-----
>From: Jacob Kjome [mailto:[email protected]]
>Sent: Monday, June 23, 2003 3:16 PM
>To: [email protected]
>Subject: Re: [Barracuda] Exception while rendering button in a component
>
>
>Hi Rajesh,
>
>I will look at this later tonight. Hopefully have a fix for you by early
>tomorrow.
>
>Can you help me out a bit by providing the full stack trace that you see
>either in the logs or from the console? That would help immensely.
>
>thanks,
>
>Jake
>
>At 11:42 AM 6/23/2003 -0700, you wrote:
>>Hi,
>>As we know that we can insert any component into a page. e.g. I have a
>>page which contains several component.
>>Html details is given below.
>>
>>
>><html id="XyzPage">
>><head>
>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>> <link rel="stylesheet"
>> href="../../../../../resources/style/q_style.css" type="text/css">
>>
>> <script type="text/javascript" language="JavaScript"
>> src="../../../../../resources/js/common_vx.js" ></script>
>> </head>
>>
>> <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0"
>> marginwidth="0" marginheight="0" >
>> <form name="vxform" method="POST" >
>> ...
>> ...
>><td class="list-content-reg Dir::Get_Data.Shipping.DeliveryComponent"
>>width="300" valign="top">
>> <table summary="" id="Delivery_Component" class="list-content"
>> width="300" border="0" cellspacing="0" cellpadding="0">
>> <tr ID="delivery_edit_comp">
>> <td class="list-content-col" width="20"> </td>
>> <td class="section-title" width="100"> </td>
>> <td class="section-title" width="160">
>> <div align="right"> Delivery
>> </div>
>> </td>
>> <td class="list-content-col" width="20"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18"
>> class="list-content-label">To:</td>
>> <td width="160" height="18" class="list-content">
>> <span class="Dir::Get_Data.Shipping.PersonFullName_TEXT">
>> Mike McKenzie
>> </span>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18"
>> class="list-content-label">Attn:</td>
>> <td width="160" height="18" class="list-content">
>> <input type="text"
>> class="Dir::Get_Data.Shipping.DeliveryAttn_TEXT"
>> name="shipAttention" maxlength="16" size="12"
>> value="Daisy">
>> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18"
>> class="list-content-label">Deliver:</td>
>> <td width="160" height="18" class="list-content">
>> <select
>> class="Dir::Get_Data.Shipping.DeliveryDeliver_SELECT" name="deliverWhat">
>> <option value="originals">Originals</option>
>> <option value="copies">Copies</option>
>> <option>Everything</option>
>> <option value=" " selected>< what ></option>
>> </select>
>> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18"
>> class="list-content-label">Method:</td>
>> <td width="160" height="18" class="list-content">
>> <select
>> class="Dir::Get_Data.Shipping.DeliveryMethod_SELECT" name="deliverMethod">
>> <option value="S1">Delivery</option>
>> <option value="S2">Pick-up</option>
>> <option value="S3">UPS</option>
>> <option value="S4">FedEx</option>
>> <option value="S5">DHL</option>
>> <option value="S6">US Post</option>
>> <option value="S7">Inter-office</option>
>> <option value="S8">Best Way</option>
>> <option selected>< select ></option>
>> </select>
>> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr>
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18"
>> class="list-content-label"> </td>
>> <td align="left" height="18" width="160" class="list-content">
>> <input
>> class="Dir::Get_Data.QuickTicket.SelectShipToButton" type="button"
>> value="Contacts..." name="SelectReceiver"
>> onClick="document.vxform.action='overview.html';document.vxform.submit();
>> return false;">
>> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> </table>
>></td>
>> ...
>> ...
>></form>
>></html>
>>
>>
>>Component details:
>>
>><html>
>><head>
>> <title>Delivery Edit Component</title>
>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>> <link rel="stylesheet"
>> href="../../../../../../resources/style/q_style.css" type="text/css">
>></head>
>> <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0"
>> marginwidth="0" marginheight="0">
>>
>><table summary="" id="Delivery_Component" class="list-content"
>>width="300" border="0" cellspacing="0" cellpadding="0">
>> <tr ID="delivery_edit_comp">
>> <td class="list-content-col" width="20"> </td>
>> <td class="section-title" width="100"> </td>
>> <td class="section-title" width="160"><div
>> align="right">Delivery</div></td>
>> <td class="list-content-col" width="20"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18" class="list-content-label">To:</td>
>> <td width="160" height="18" class="list-content"> <span
>> class="Dir::Get_Data.Shipping.PersonFullName_TEXT">
>> Mike McKenzie </span>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18" class="list-content-label">Attn:</td>
>> <td width="160" height="18" class="list-content"> <input type="text"
>> class="Dir::Get_Data.Shipping.DeliveryAttn_TEXT"
>> name="shipAttention" maxlength="16" size="12"
>> value="Daisy">
>> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18" class="list-content-label">Deliver:</td>
>> <td width="160" height="18" class="list-content"> <select
>> class="Dir::Get_Data.Shipping.DeliveryDeliver_SELECT" name="deliverWhat">
>> <option value="originals">Originals</option>
>> <option value="copies">Copies</option>
>> <option>Everything</option>
>> <option value=" " selected>< what ></option>
>> </select> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr valign="middle">
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18" class="list-content-label">Method:</td>
>> <td width="160" height="18" class="list-content"> <select
>> class="Dir::Get_Data.Shipping.DeliveryMethod_SELECT" name="deliverMethod">
>> <option value="S1">Delivery</option>
>> <option value="S2">Pick-up</option>
>> <option value="S3">UPS</option>
>> <option value="S4">FedEx</option>
>> <option value="S5">DHL</option>
>> <option value="S6">US Post</option>
>> <option value="S7">Inter-office</option>
>> <option value="S8">Best Way</option>
>> <option selected>< select ></option>
>> </select> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>> <tr>
>> <td width="20" height="18" class="list-content"> </td>
>> <td width="100" height="18" class="list-content-label"> </td>
>> <td align="left" height="18" width="160" class="list-content">
>> <input class="Dir::Get_Data.QuickTicket.SelectShipToButton"
>> type="button" value="Contacts..." name="SelectReceiver">
>> </td>
>> <td width="20" height="18" class="list-content"> </td>
>> </tr>
>></table>
>> </body>
>></html>
>>Processing component directive in the model.
>>
>> public Object getItem(String key)
>> {
>> if (key.equals("DeliveryComponent"))
>> {
>> try
>> {
>> String compClassName = "classname";
>> ViewContext vc = getViewContext();
>> Document comp =
>> DefaultDOMLoader.getGlobalInstance().getDOM( compClassName);
>> Node specCompNode =
>> comp.getElementById("Document_Component");
>> return( vc.getElementFactory().getDocument().importNode(
>> specCompNode, true ) );
>> }
>> catch (IOException ioe)
>> {
>> ...
>> }
>> return(null);
>> }
>> ...
>> ...
>>
>>Here I am inserting a delivery component into the main page which has a
>>form whereas component does not have any form.
>>This code was working with xmlc2.1 with xerces-1.4.4-xmlc2.1.jar. Now I
>>am try to use latest Barracuda code and I am getting NullPointerException
>>while rendering the button. I have gone through 'HTMLActionRenderer' code
>>and it fails in manipulateActionElement function
>>
>>//redirect the form to event forwarding servlet (encode)
>> fel.setAction(URLRewriter.encodeURL(vc,
>> NamingHelper.getName(fel)+FormGateway.FORM_EXT));
>>
>>Let me know if you need more clarification.
>>Please, help me.
>>
>>
>>Thanks,
>>Rajesh
>>
>