Hi George. I answered your base question on a different thread, but for the sake of search engines:
I don't think you'll come across a scenario where you need to get the BindingSource and create your own bindings in this way. In general the binding that you want is defined in your TML or via the @Component annotation. <t:textfield t:id="quantity" disabled="quantityDisabled"/> or @Component(id = "quantity", parameters = {"disabled=quantityDisabled"}) where quantityDisabled is either a @Property or a method (getQuantityDisabled, or isQuantityDisabled) In your case, where you don't want to create a dozen isXXXDisabled methods to correspond to a dozen fields, you could use a mapping: <t:textfield t:id="quantity" disabled="disabled"/> public boolean isDisabled() { // Instead of a bunch of ifs we loop over the fields stored in the map for (String componentId : disabledComponents.keySet()) { if (resources.getEmbeddedComponent(componentId).getComponentResources().isRendering()) { Boolean disabled = disabled.get(componentId); return disabled != null ? disabled : false; } } return false; } On Fri, Nov 25, 2011 at 7:26 AM, George Christman <gchrist...@cardaddy.com> wrote: > Hi all, I'm very new to binding and I found an article on the mailing list > that seemed pretty close what I needed in regards to dynamic disabling. I'm > trying to dynamically disable particular fields within my form at different > states. These fields will come from the db and selected within my for loop. > I have the following code and I get the following exception. > > Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: > Expression 'disabled' for class > org.apache.tapestry5.corelib.components.TextField is read-only. > at > org.apache.tapestry5.internal.bindings.PropBinding.set(PropBinding.java:76) > at > org.healthresearch.eprs.components.PurchaseRequestForm.onValidateFromPR(PurchaseRequestForm.java:416) > at > org.healthresearch.eprs.components.PurchaseRequestForm$Shim_b586eaee4d4e0.invoke(Unknown > Source) > at > org.apache.tapestry5.internal.plastic.MethodHandleImpl.invoke(MethodHandleImpl.java:48) > at > org.apache.tapestry5.internal.transform.BaseEventHandlerMethodInvoker.invokeEventHandlerMethod(BaseEventHandlerMethodInvoker.java:53) > ... 114 more > > Could someone please guide me and tell me what I'm doing wrong? > > > @Inject > private Request req; > @Inject > private ComponentResources componentResources; > @Inject > private BindingSource source; > > void setupRender() { > for (String field : req.getParameterNames()) { > if (field.equals("quanity")) { > ComponentResources component = > componentResources.getEmbeddedComponent(field).getComponentResources(); > > String defaultPrefix = "prop"; > String description = "descrip"; > String expression = "disabled"; > > Binding b = source.newBinding(description, component, > defaultPrefix, expression); > b.set(true); > } > } > } > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/Dynamic-Disabled-fields-with-binding-tp5023027p5023027.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org