You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dustin Frazier <du...@philanthropix.org> on 2003/08/05 00:12:33 UTC

help with binding error

I'm working on a component which renders a top-level set of tabs and a set of
links on a second level for each tab.  I have a LinkedHashMap of Maps, each of
which has three values under the keys 'name', 'page', and 'links'.  The 'name'
and 'page' values are strings, and the 'links' value is itself an ArrayList of
Maps.  Each top-level Map represents a top-level tab, and each link Map
represents a name/page pair for links within that tab.  (This whole wad is
created within the static initializer for the component class.)

I've had great success getting the top-level tabs to render, but I'm getting a
BindingException ("Binding value may not be updated") when I try to render the
links.  Here are some snippets of my code:

Tabs.html:
<span jwcid="@Foreach" source="ognl:@<class>@TABS.values"
value="ognl:currentTab">
<td jwcid="@Any" element="td" class="ognl:classForCurrentTab">
  <a jwcid="@PageLink" page="ognl:currentTab.page">
    &nbsp;&nbsp;&nbsp;<span jwcid="@Insert"
value="ognl:currentTab.name"/>&nbsp;&nbsp;&nbsp;
  </a>
</td>
</span>
<span jwcid="@Foreach" source="ognl:@<class>@TABS[selectedTab].links"
value="currentLink">
  &nbsp;&nbsp;&nbsp;<span jwcid="@Insert" value="ognl:currentLink"/> </span>

Tabs.jwc:
...
  <parameter name="selectedTab" type="java.lang.String" direction="in"
required="yes"/>

  <property-specification name="currentTab"  type="java.util.Map"
persistent="no"/>
  <property-specification name="currentLink" type="java.util.Map"
persistent="no"/> ...

I have Tabs.java declared as abstract, with abstract methods for
getSelectedTab() and getCurrentTab(), since I need to reference these in my
code (e.g. getClassForCurrentTab()).

I'm pretty sure the OGNL expression for the second Foreach is correct, since
it doesn't give me any errors and works fine for tabs that don't have any
links (i.e. where the 'links' value in the top-level tab Map is null).  The
stack trace I see starts out with:

org.apache.tapestry.BindingException 
Binding value may not be updated. 
binding: StaticBinding[currentLink] 
Stack Trace: 
org.apache.tapestry.binding.AbstractBinding.createReadOnlyBindingException(Abs
tractBinding.java:282) 
org.apache.tapestry.binding.AbstractBinding.setObject(AbstractBinding.java:232
) 
org.apache.tapestry.components.Foreach.renderComponent(Foreach.java:155) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896) 
org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:159) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896) 
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:673) 
org.apache.tapestry.html.Body.renderComponent(Body.java:304) 
...

Any help with how to debug this would be much appreciated...

Dustin


RE: help with binding error

Posted by Dustin Frazier <du...@philanthropix.org>.
<blush>  Thanks, Howard.  I've accidentally left off the "ognl:" before, but
never on a bi-directional binding, I guess.  Thanks again...

Dustin

-----Original Message-----
From: Howard M. Lewis Ship [mailto:hlship@comcast.net] 
Sent: Monday, August 4, 2003 3:40 PM
To: 'Tapestry users'
Subject: RE: help with binding error


In the second Foreach, it is 
	value="currentLink"

but should be

	value="ognl:currentLink"

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components http://jakarta.apache.org/tapestry



> -----Original Message-----
> From: Dustin Frazier [mailto:dustin@philanthropix.org]
> Sent: Monday, August 04, 2003 6:13 PM
> To: tapestry-user@jakarta.apache.org
> Subject: help with binding error
> 
> 
> I'm working on a component which renders a top-level set of
> tabs and a set of links on a second level for each tab.  I 
> have a LinkedHashMap of Maps, each of which has three values 
> under the keys 'name', 'page', and 'links'.  The 'name' and 
> 'page' values are strings, and the 'links' value is itself an 
> ArrayList of Maps.  Each top-level Map represents a top-level 
> tab, and each link Map represents a name/page pair for links 
> within that tab.  (This whole wad is created within the 
> static initializer for the component class.)
> 
> I've had great success getting the top-level tabs to render,
> but I'm getting a BindingException ("Binding value may not be 
> updated") when I try to render the links.  Here are some 
> snippets of my code:
> 
> Tabs.html:
> <span jwcid="@Foreach" source="ognl:@<class>@TABS.values"
> value="ognl:currentTab">
> <td jwcid="@Any" element="td" class="ognl:classForCurrentTab">
>   <a jwcid="@PageLink" page="ognl:currentTab.page">
>     &nbsp;&nbsp;&nbsp;<span jwcid="@Insert"
> value="ognl:currentTab.name"/>&nbsp;&nbsp;&nbsp;
>   </a>
> </td>
> </span>
> <span jwcid="@Foreach" source="ognl:@<class>@TABS[selectedTab].links"
> value="currentLink">
>   &nbsp;&nbsp;&nbsp;<span jwcid="@Insert" 
> value="ognl:currentLink"/> </span>
> 
> Tabs.jwc:
> ...
>   <parameter name="selectedTab" type="java.lang.String"
> direction="in" required="yes"/>
> 
>   <property-specification name="currentTab"
> type="java.util.Map" persistent="no"/>
>   <property-specification name="currentLink" 
> type="java.util.Map" persistent="no"/> ...
> 
> I have Tabs.java declared as abstract, with abstract methods for
> getSelectedTab() and getCurrentTab(), since I need to
> reference these in my code (e.g. getClassForCurrentTab()).
> 
> I'm pretty sure the OGNL expression for the second Foreach is
> correct, since it doesn't give me any errors and works fine 
> for tabs that don't have any links (i.e. where the 'links' 
> value in the top-level tab Map is null).  The stack trace I 
> see starts out with:
> 
> org.apache.tapestry.BindingException
> Binding value may not be updated. 
> binding: StaticBinding[currentLink] 
> Stack Trace: 
> org.apache.tapestry.binding.AbstractBinding.createReadOnlyBind
> ingException(Abs
> tractBinding.java:282) 
> org.apache.tapestry.binding.AbstractBinding.setObject(Abstract
> Binding.java:232
> ) 
> org.apache.tapestry.components.Foreach.renderComponent(Foreach
> .java:155) 
> org.apache.tapestry.AbstractComponent.render(AbstractComponent
> .java:896) 
> org.apache.tapestry.BaseComponent.renderComponent(BaseComponen
> t.java:159) 
> org.apache.tapestry.AbstractComponent.render(AbstractComponent
> .java:896) 
> org.apache.tapestry.AbstractComponent.renderBody(AbstractCompo
> nent.java:673) 
> org.apache.tapestry.html.Body.renderComponent(Body.java:304) 
> ...
> 
> Any help with how to debug this would be much appreciated...
> 
> Dustin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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


RE: help with binding error

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
In the second Foreach, it is 
	value="currentLink"

but should be

	value="ognl:currentLink"

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry



> -----Original Message-----
> From: Dustin Frazier [mailto:dustin@philanthropix.org] 
> Sent: Monday, August 04, 2003 6:13 PM
> To: tapestry-user@jakarta.apache.org
> Subject: help with binding error
> 
> 
> I'm working on a component which renders a top-level set of 
> tabs and a set of links on a second level for each tab.  I 
> have a LinkedHashMap of Maps, each of which has three values 
> under the keys 'name', 'page', and 'links'.  The 'name' and 
> 'page' values are strings, and the 'links' value is itself an 
> ArrayList of Maps.  Each top-level Map represents a top-level 
> tab, and each link Map represents a name/page pair for links 
> within that tab.  (This whole wad is created within the 
> static initializer for the component class.)
> 
> I've had great success getting the top-level tabs to render, 
> but I'm getting a BindingException ("Binding value may not be 
> updated") when I try to render the links.  Here are some 
> snippets of my code:
> 
> Tabs.html:
> <span jwcid="@Foreach" source="ognl:@<class>@TABS.values"
> value="ognl:currentTab">
> <td jwcid="@Any" element="td" class="ognl:classForCurrentTab">
>   <a jwcid="@PageLink" page="ognl:currentTab.page">
>     &nbsp;&nbsp;&nbsp;<span jwcid="@Insert" 
> value="ognl:currentTab.name"/>&nbsp;&nbsp;&nbsp;
>   </a>
> </td>
> </span>
> <span jwcid="@Foreach" source="ognl:@<class>@TABS[selectedTab].links"
> value="currentLink">
>   &nbsp;&nbsp;&nbsp;<span jwcid="@Insert" 
> value="ognl:currentLink"/> </span>
> 
> Tabs.jwc:
> ...
>   <parameter name="selectedTab" type="java.lang.String" 
> direction="in" required="yes"/>
> 
>   <property-specification name="currentTab"  
> type="java.util.Map" persistent="no"/>
>   <property-specification name="currentLink" 
> type="java.util.Map" persistent="no"/> ...
> 
> I have Tabs.java declared as abstract, with abstract methods for
> getSelectedTab() and getCurrentTab(), since I need to 
> reference these in my code (e.g. getClassForCurrentTab()).
> 
> I'm pretty sure the OGNL expression for the second Foreach is 
> correct, since it doesn't give me any errors and works fine 
> for tabs that don't have any links (i.e. where the 'links' 
> value in the top-level tab Map is null).  The stack trace I 
> see starts out with:
> 
> org.apache.tapestry.BindingException 
> Binding value may not be updated. 
> binding: StaticBinding[currentLink] 
> Stack Trace: 
> org.apache.tapestry.binding.AbstractBinding.createReadOnlyBind
> ingException(Abs
> tractBinding.java:282) 
> org.apache.tapestry.binding.AbstractBinding.setObject(Abstract
> Binding.java:232
> ) 
> org.apache.tapestry.components.Foreach.renderComponent(Foreach
> .java:155) 
> org.apache.tapestry.AbstractComponent.render(AbstractComponent
> .java:896) 
> org.apache.tapestry.BaseComponent.renderComponent(BaseComponen
> t.java:159) 
> org.apache.tapestry.AbstractComponent.render(AbstractComponent
> .java:896) 
> org.apache.tapestry.AbstractComponent.renderBody(AbstractCompo
> nent.java:673) 
> org.apache.tapestry.html.Body.renderComponent(Body.java:304) 
> ...
> 
> Any help with how to debug this would be much appreciated...
> 
> Dustin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>