You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ken in Nashua <kc...@live.com> on 2011/09/18 22:39:21 UTC

why read ony ComponentEventException

Folks,

I have a page feeding read/write property

Home.JAVA
    @Property(read = true, write = true)                                // no getter/setter needed
    @Persist("session")
    private int itemsPerPage;

to a component parameter

Gallery.JAVA
    @Property(read = true, write = true)
    @Parameter(required = true, cache = true, defaultPrefix = "50")
    private int itemsPerPage;
    
    @BeginRender

    public void beginRender()

    {

        //itemsPerPage = 50;

        //tableColumns = 3;

    }

org.apache.tapestry5.runtime.ComponentEventExceptionFailure
 writing parameter 'value' of component 
Home:gallerywidget.itemsperpageselect: Failure writing parameter 
'itemsPerPage' of component Home:gallerywidget: Binding 
org.apache.tapestry5.internal.services.AttributeExpansionBinding@3e963f38
 is read-only.

here are some sources... to possbly indicate the issue but I cannot spot why.

Any ideas ? I would think that the annotations provided are sufficient? Also if I try to set a value to this parameter within the component I receive the same thing...


HOME.TML
...
    <t:form t:id="galleryForm" t:name="galleryForm" clientValidation="true">
        <t:errors/>
        
        <t:Gallery t:id="GalleryWidget"
            collection="${collection}"
            itemsPerPage="${itemsPerPage}"
            tableColumns="${tableColumns}"
            cursor="${cursor}"
            />
    </t:form>

</t:layout>


 		 	   		  

Re: why read ony ComponentEventException

Posted by Bob Harner <bo...@gmail.com>.
This is a frequently-occurring user mistake, especially by developers
new to tapestry. And sometimes the error message is even more
misleading:

    org.apache.tapestry5.ioc.util.UnknownValueException: "Could not
find a coercion from type java.lang.String to type com.example.Foo"

I wonder if there's something that can be done to help, like making
the exception message more verbose about the common causes, or maybe
emitting a warning whenever ${...} is used in a component parameter in
a tml file and that parameter has a default binding prefix of "prop:"
or "var:"

On Sun, Sep 18, 2011 at 5:44 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
> ${...} doesn't do what you think it does.  It specifically extracts
> the expression and converts it to a String, and the expression is
> read-only.
>
> Bind it like this:
>
>  itemsPerPage="itemsPerPage"
>
> this binds the component parameter field directly to the containing
> page's property, so it's read/write.
>
> The use of ${...} was intended for attributes  ordinary
> (non-component) elements.
>
> On Sun, Sep 18, 2011 at 1:39 PM, Ken in Nashua <kc...@live.com> wrote:
>>
>> Folks,
>>
>> I have a page feeding read/write property
>>
>> Home.JAVA
>>    @Property(read = true, write = true)                                // no getter/setter needed
>>    @Persist("session")
>>    private int itemsPerPage;
>>
>> to a component parameter
>>
>> Gallery.JAVA
>>    @Property(read = true, write = true)
>>    @Parameter(required = true, cache = true, defaultPrefix = "50")
>>    private int itemsPerPage;
>>
>>    @BeginRender
>>
>>    public void beginRender()
>>
>>    {
>>
>>        //itemsPerPage = 50;
>>
>>        //tableColumns = 3;
>>
>>    }
>>
>> org.apache.tapestry5.runtime.ComponentEventExceptionFailure
>>  writing parameter 'value' of component
>> Home:gallerywidget.itemsperpageselect: Failure writing parameter
>> 'itemsPerPage' of component Home:gallerywidget: Binding
>> org.apache.tapestry5.internal.services.AttributeExpansionBinding@3e963f38
>>  is read-only.
>>
>> here are some sources... to possbly indicate the issue but I cannot spot why.
>>
>> Any ideas ? I would think that the annotations provided are sufficient? Also if I try to set a value to this parameter within the component I receive the same thing...
>>
>>
>> HOME.TML
>> ...
>>    <t:form t:id="galleryForm" t:name="galleryForm" clientValidation="true">
>>        <t:errors/>
>>
>>        <t:Gallery t:id="GalleryWidget"
>>            collection="${collection}"
>>            itemsPerPage="${itemsPerPage}"
>>            tableColumns="${tableColumns}"
>>            cursor="${cursor}"
>>            />
>>    </t:form>
>>
>> </t:layout>
>>
>>
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: why read ony ComponentEventException

Posted by Howard Lewis Ship <hl...@gmail.com>.
${...} doesn't do what you think it does.  It specifically extracts
the expression and converts it to a String, and the expression is
read-only.

Bind it like this:

  itemsPerPage="itemsPerPage"

this binds the component parameter field directly to the containing
page's property, so it's read/write.

The use of ${...} was intended for attributes  ordinary
(non-component) elements.

On Sun, Sep 18, 2011 at 1:39 PM, Ken in Nashua <kc...@live.com> wrote:
>
> Folks,
>
> I have a page feeding read/write property
>
> Home.JAVA
>    @Property(read = true, write = true)                                // no getter/setter needed
>    @Persist("session")
>    private int itemsPerPage;
>
> to a component parameter
>
> Gallery.JAVA
>    @Property(read = true, write = true)
>    @Parameter(required = true, cache = true, defaultPrefix = "50")
>    private int itemsPerPage;
>
>    @BeginRender
>
>    public void beginRender()
>
>    {
>
>        //itemsPerPage = 50;
>
>        //tableColumns = 3;
>
>    }
>
> org.apache.tapestry5.runtime.ComponentEventExceptionFailure
>  writing parameter 'value' of component
> Home:gallerywidget.itemsperpageselect: Failure writing parameter
> 'itemsPerPage' of component Home:gallerywidget: Binding
> org.apache.tapestry5.internal.services.AttributeExpansionBinding@3e963f38
>  is read-only.
>
> here are some sources... to possbly indicate the issue but I cannot spot why.
>
> Any ideas ? I would think that the annotations provided are sufficient? Also if I try to set a value to this parameter within the component I receive the same thing...
>
>
> HOME.TML
> ...
>    <t:form t:id="galleryForm" t:name="galleryForm" clientValidation="true">
>        <t:errors/>
>
>        <t:Gallery t:id="GalleryWidget"
>            collection="${collection}"
>            itemsPerPage="${itemsPerPage}"
>            tableColumns="${tableColumns}"
>            cursor="${cursor}"
>            />
>    </t:form>
>
> </t:layout>
>
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


RE: why read ony ComponentEventException

Posted by Ken in Nashua <kc...@live.com>.
Thanks Howard... i wondered if this one would get your attention and glad I can move onward.
maybe i am getting old in my age but I got 5 years of hard C, 10 years of C++, 12 years of JAVA and a boat load of front end to back end...
conceptual expression parsing and de-referencing caught me up a bit I guess...
 
and I have thought recently (as I have in the past with tap3 and tap4)... why does tapestry have to be so hard... but I think it's just me

maybe I am asking too much for these semantics should be flagged too... and articulated for the developer  

anyway... thanks... in the end tapestry is worth it and I could not think of developing with anything else as extensible and flexible

- cheers


From: kcolassi@live.com
To: users@tapestry.apache.org
Subject: why read ony ComponentEventException
Date: Sun, 18 Sep 2011 16:39:21 -0400








Folks,

I have a page feeding read/write property

Home.JAVA
    @Property(read = true, write = true)                                // no getter/setter needed
    @Persist("session")
    private int itemsPerPage;

to a component parameter

Gallery.JAVA
    @Property(read = true, write = true)
    @Parameter(required = true, cache = true, defaultPrefix = "50")
    private int itemsPerPage;
    
    @BeginRender

    public void beginRender()

    {

        //itemsPerPage = 50;

        //tableColumns = 3;

    }

org.apache.tapestry5.runtime.ComponentEventExceptionFailure
 writing parameter 'value' of component 
Home:gallerywidget.itemsperpageselect: Failure writing parameter 
'itemsPerPage' of component Home:gallerywidget: Binding 
org.apache.tapestry5.internal.services.AttributeExpansionBinding@3e963f38
 is read-only.

here are some sources... to possbly indicate the issue but I cannot spot why.

Any ideas ? I would think that the annotations provided are sufficient? Also if I try to set a value to this parameter within the component I receive the same thing...


HOME.TML
...
    <t:form t:id="galleryForm" t:name="galleryForm" clientValidation="true">
        <t:errors/>
        
        <t:Gallery t:id="GalleryWidget"
            collection="${collection}"
            itemsPerPage="${itemsPerPage}"
            tableColumns="${tableColumns}"
            cursor="${cursor}"
            />
    </t:form>

</t:layout>