There are at least a few reasonable approaches to this problem, different approaches make more sense depending on how you're storing the data.
For instance, I can't tell from your description whether you are determining the enable/disable state using business logic about the workflow/role, or if you are pulling storing that state in a DB and pulling it out later. If you have an entity that contains the logic per field the you could do something like: <t:textfield t:id="fieldOne" t:value="dbObject.fieldOne" t:disabled="fieldState.fieldOneDisabled"/> <t:textfield t:id="fieldTwo" t:value="dbObject.fieldTwo" t:disabled="fieldState.fieldTwoDisabled"/> That works, but catching bugs could be annoying (whoops, checked fieldOneDisabled for fieldTwo) especially if you have a lot of fields. Your original code looked good to me too, although I think in the effort to make it generic some of the intent may have been lost. I assume your isDisabled function would have an "if" statement for every field that you wanted to test, with logic to determine whether that field was enabled/disabled. If your data is stored in a way that accessing it as a map is convenient then the following could work: <t:textfield t:id="fieldOne" t:disabled="disabled"/> <t:textfield t:id="fieldTwo" t:disabled="disabled"/> @Persist private HashMap<String, Boolean> disabled; void onActivate() { if ( disabled == null ) { disabled = new HashMap<String, Boolean>(); disabled.put("fieldOne", false); disabled.put("fieldTwo", true); } } public boolean isDisabled() { // Instead of a bunch of ifs we loop over the fields stored in the map for (String componentId : disabled.keySet()) { if (resources.getEmbeddedComponent(componentId).getComponentResources().isRendering()) { Boolean disabled = disabled.get(componentId); return disabled != null ? disabled : false; } } return false; } You're probably not dealing with enough fields that this iteration to find the rendering field is going to cause noticeable CPU usage... although if you want faster you could use a parameter to your isDisabled method: <t:textfield t:id="fieldOne" t:disabled="isDisabled('fieldOne')"/> <t:textfield t:id="fieldTwo" t:disabled="isDisabled('fieldTwo')"/> public boolean isDisabled(String field) { Boolean disabled = disabled.get(fieldId) return disabled != null ? disabled : false; } But you get back the potential for "whoops used the wrong fieldId" type TML defect. Josh On Mon, Nov 28, 2011 at 6:56 AM, George Christman <gchrist...@cardaddy.com> wrote: > Thanks Thiago for your response. I have a single form with a very large > workflow, throughout the workflow individual fields are either disabled or > enabled depending on user role and workflow state. I have all the field id's > stored in the db, so on render I was hoping to get my list of my > disabled/enabled fields from the db and dynamically set the t:disabled > boolean. I was hoping there was a way to do it without having to use a bunch > of unique variables within the tml. So to answer your question, I'm not > certain what logic I should be using. > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/T5-dynamically-set-disabled-attribute-tp2414476p5029087.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