I have wrote the solution I have found before reading this.
Actually It was enough to put it after the form.
The null component was the text field component not the Form.
You almost got it because sure the position of @Script matters.

It seems that getForm returns something even if the form has already
been rendered.

Andreas Andreou ha scritto:
> You don't specify which object you've found to be null... but anyway, let
> me try...
>
> looking at the FormFocus.script code from
> http://tapestry.apache.org/tapestry4.1/components/general/script.html
> i see ${component.form.name} and ${component.name}, so either
> component or component.form is null (according to the error message)
>
> Looking at the javadocs for AbstractFormComponent
> http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/form/AbstractFormComponent.html
> I read
> getForm() : returns the IForm which contains the component, or null if
> the component is
> not contained by a form, or if the containing Form is not currently rendering.
>
> Finally, looking at your code I see that @Script is outside the @Form,
> so according
> to the javadocs, getForm() should indeed return null !
>
> The cure? move the @Script inside @Form - or rewrite the script so that it
> doesn't use getForm() perhaps...
>
> On Wed, Dec 30, 2009 at 23:35, Ivano Luberti <lube...@archicoop.it> wrote:
>   
>> Thanks Andreas , the problem is that everything works until I insert the
>> javascript.
>> In fact the exception is thrown inside the Script implementation. Down
>> here you'll find the init part of the srtack trace.
>> I was wondering if not using the @Body in the component html template is
>> correct, given the fact that it is used in the html template of the page
>> that call the component.
>>
>>
>>
>>
>>    * ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2203)
>>    * ognl.ASTProperty.getValueBody(ASTProperty.java:114)
>>    * ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
>>    * ognl.SimpleNode.getValue(SimpleNode.java:258)
>>    * ognl.ASTChain.getValueBody(ASTChain.java:141)
>>    * ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
>>    * ognl.SimpleNode.getValue(SimpleNode.java:258)
>>    * ognl.Ognl.getValue(Ognl.java:494)
>>    * ognl.Ognl.getValue(Ognl.java:458)
>>    * 
>> org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.readCompiled(ExpressionEvaluatorImpl.java:123)
>>
>>    * 
>> org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.read(ExpressionEvaluatorImpl.java:112)
>>
>>    * 
>> $ExpressionEvaluator_125e178e557.read($ExpressionEvaluator_125e178e557.java)
>>
>>    * 
>> org.apache.tapestry.script.ScriptSessionImpl.evaluate(ScriptSessionImpl.java:86)
>>
>>    * org.apache.tapestry.script.AbstractToken.evaluate(AbstractToken.java:84)
>>
>>    * org.apache.tapestry.script.InsertToken.write(InsertToken.java:48)
>>    * 
>> org.apache.tapestry.script.AbstractToken.writeChildren(AbstractToken.java:71)
>>
>>    * org.apache.tapestry.script.LetToken.write(LetToken.java:53)
>>    * 
>> org.apache.tapestry.script.AbstractToken.writeChildren(AbstractToken.java:71)
>>
>>    * org.apache.tapestry.script.ParsedScript.execute(ParsedScript.java:82)
>>    * org.apache.tapestry.html.Script.renderComponent(Script.java:159)
>>    * org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    * 
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    * 
>> org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:107)
>>
>>    * org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:724)
>>
>>    * 
>> org.apache.tapestry.services.impl.DefaultResponseBuilder.render(DefaultResponseBuilder.java:187)
>>
>>    * 
>> org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:538)
>>
>>    * org.apache.tapestry.html.Body.renderComponent(Body.java:38)
>>
>>
>> Andreas Andreou ha scritto:
>>     
>>> Hi,
>>> The error message says that something.getName() is trying to get evaluated 
>>> but
>>> something is null
>>>
>>> Finding where exactly the error is thrown will show you which object is 
>>> null...
>>>
>>> On Wed, Dec 30, 2009 at 20:51, Ivano Luberti <lube...@archicoop.it> wrote:
>>>
>>>       
>>>> Hello, I'm trying to include some simple javascript in a component in my
>>>> T4 application.
>>>> I want my only textfield to  get focus when is displayed.
>>>> I'm following the instructions provided at:
>>>>
>>>> http://tapestry.apache.org/tapestry4.1/components/general/script.html
>>>>
>>>> The template of the page including the component has @Shell and @Body
>>>> specified.
>>>> My component looks like this:
>>>>
>>>> <html>
>>>> <head>
>>>> <title>MET Online</title>
>>>> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
>>>> <link href="css/stile_palmare.css" rel="stylesheet" type="text/css">
>>>> </head>
>>>> <body>
>>>>  <span jwcid="@Script"
>>>> script="/it/archimede/met/metgestioneingressi/tapestry/scripts/FormFocus.script"
>>>> component="ognl:components.barCode"/>
>>>>
>>>>    <div id="box_operazione">
>>>>    <h1>Lettura BarCode</h1>
>>>>        <br />
>>>>          <h2>passare il barcode sotto il lettore ottico</h2>
>>>>    <form method="post" action="" jwcid="barCodeForm">
>>>>          <input type="text" jwcid="barCode" class="text_box" value="" />
>>>>          <br /><br />
>>>>        <input type="submit" name="Submit" value="Submit" class="bottone">
>>>>      </form>
>>>>   </div>
>>>>
>>>> </body>
>>>> </html>
>>>>
>>>> The Script template file is the last one provides at:
>>>>
>>>> http://tapestry.apache.org/tapestry4.1/components/general/script.html
>>>>
>>>> the one without CDATA
>>>>
>>>> When I try to display the page I get:
>>>>
>>>> [ +/- ] Exception: Unable to read OGNL expression '<parsed OGNL
>>>> expression>' of
>>>> {component=$textfield_...@81eb97c1[homeloggeduser/barCodeForm.barCode]}:
>>>> source is null for getProperty(null, "name")
>>>>
>>>> I have already tried putting a bad component name in the @Script span
>>>> and the error changes, so it seem the name is right. I have put a bad
>>>> path to the script file and the error changes , then the path is correct.
>>>>
>>>> Can someone point me in the right direction?
>>>>
>>>>
>>>>
>>>> --
>>>> ==================================================
>>>> dott. Ivano Mario Luberti
>>>> Archimede Informatica societa' cooperativa a r. l.
>>>> Sede Operativa
>>>> Via Gereschi 36 - 56126- Pisa
>>>> tel.: +39-050- 580959
>>>> tel/fax: +39-050-9711344
>>>> web: www.archicoop.it
>>>> ==================================================
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>         
>>>
>>>
>>>       
>> --
>> ==================================================
>> dott. Ivano Mario Luberti
>> Archimede Informatica societa' cooperativa a r. l.
>> Sede Operativa
>> Via Gereschi 36 - 56126- Pisa
>> tel.: +39-050- 580959
>> tel/fax: +39-050-9711344
>> web: www.archicoop.it
>> ==================================================
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>>     
>
>
>
>   

-- 
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to