Rather writing out your own disabled attribute, try having your Mixin bind to the disabled parameter:
@BindParameter private boolean disabled; then set this to false and have the input component disable itself: void beginRender() { disabled = true; } -- Steve Eynon ------------------------------- "If at first you don't succeed, so much for skydiving!" On 15 May 2012 03:52, Emmanuel DEMEY <demey.emman...@gmail.com> wrote: > Hi Alexander > > I think the problem come from the fact that the input element of the > datefield is closed (writer.end()) in the beginRender phase. So when your > mixin is executed, it is too late. > > You should maybe test if the field using the mixin is a Datefield, and if > this the case, get the Input Element (one of the children of the current > element) and set the disable attribute. > > Manu > > 2012/5/14 sommeralex <alexander.som...@gmail.com> > >> Hello! >> >> I have a mixin which is responsible for deactivating some input-form >> elements (textfields, textareas, and datefields). >> >> My mixin function works on select fields and on textfields, but with one >> exception: if i am using my mixin on t:datefield, it does not work. >> >> My Mixin in short: >> >> @MixinAfter >> public class DecoFeatureInput { >> >> ... >> ... >> >> @BeginRender >> void beginRender(MarkupWriter writer){ >> if( >> !productService.isAvailableProduct(userService.getCurrentUser(), >> productName) ){ >> writer.attributes("disabled" ,"true"); >> } >> } >> } >> >> >> My TML components is: >> >> <t:textfield t:mixins="decoFeatureInput" productName="Question" >> value="message.question" /> >> >> and this works, the resulting HTML is: >> >> <input disabled="true" id="textfield_0" name="textfield_0" >> type="text"></input> >> >> *therefore, the disabled tag is on the right position. * >> >> BUT >> >> <t:datefield t:mixins="decoFeatureInput" productName="Schedule" >> value="message.endDate" t:id="endDate" /> >> >> does not work. My datefield is not deactivated, even if the Product >> "schedule" is not available. >> >> the resulting HTML is: >> >> *<TD disabled="true">*<input value="" id="endDate" name="endDate" >> type="text"></input> >> >> *so, the disabled tag is written BEFORE the input tag. * >> >> >> the complete code: >> >> >> <t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> >> >> >> >> <t:form> >> <t:hidden value="groupID" /> >> >> Message >> >> <label class="inputLabel" for="text">${message:Text}</label><br></br> >> <t:textarea style="width:450px;" t:id="text" value="message.text" rows="2" >> validate="required" /> >> <br></br> >> >> <br></br> >> Location >> >> <label class="inputLabel" for="address">${message:Address}</label><br></br> >> <input id="address" type="text" style="width:430px" >> onChange="goToAddress(this.value);" onKeyPress="return checkEnter();"/> >> <button name="Go" type="button" class="button" >> onclick="goToAddress($('address').value);">${message:Go}</button> >> <br/> >> <div style="width:450px;"> >> ${message:AddressInGroupScope} ${message:DragMapOrMarkerToLocation} >> <br/> >> <t:googleMaps /> >> </div> >> >> <br></br> >> javascript:void(0); ${message:AdvancedLocation} >> >> <div style="width:450px;"> >> <div id="divAdvancedLocation" style="display:none"> >> <t:textfield t:id="longitude" t:label="${message:Longitude}" >> value="message.geoPoint.longitude" validate="required" >> onChange="javascript:goToLatLng(map, $('latitude').value, >> this.value);" >> t:mixins="decoField" /> >> >> <t:textfield t:id="latitude" t:label="${message:Latitude}" >> value="message.geoPoint.latitude" validate="required" >> onChange="javascript:goToLatLng(map, this.value, >> $('longitude').value);" >> t:mixins="decoField" /> >> </div> >> </div> >> >> <div class ="map" id="map"></div> >> >> >> >> <br /> >> >> <div class="sliderfeature"> >> >> >> >> >> >> >> >> <t:slider t:id="slider" onSlide="onSlide(value);" >> value="message.radiusInMeters" /> >> >> ${message:scope} >> >> m. >> >> km. >> >> ${message:Miles} >> >> >> <t:html.hidden t:id="scopeRadius" >> value="message.radiusInMeters" /> >> >> </div> >> >> <t:if test="groupHasFeatures"> >> >> Features >> >> </t:if> >> >> <br></br> >> <t:if test="group.hasEmotions"> >> <div class="feature"> >> <div class="featureIcon"> >> /img/icon/attributes/icon_emotion_55x55.png >> </div> >> <div class="featureLabel"> >> <label class="inputLabel" >> for="emotion">${message:Emotion}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.emotion" >> id="emotion" >> t:mixins="decoFeatureInput" >> productName="Emotions" /> >> </div> >> </div> >> </t:if> >> >> >> <t:if test="group.hasRelationship"> >> <div class="feature"> >> <div class="featureIcon"> >> >> /img/icon/attributes/icon_relationship_55x55.png >> </div> >> <div class="featureLabel"> >> <label class="inputLabel" >> for="Relationship">${message:Relationship}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.relationship" >> id="relationship" >> t:mixins="decoFeatureInput" >> productName="Relationship" /> >> </div> >> </div> >> </t:if> >> >> <t:if test="group.hasWealth"> >> <div class="feature"> >> <div class="featureIcon"> >> /img/icon/attributes/icon_money_55x55.png >> </div> >> <div class="featureLabel"> >> <label class="inputLabel" >> for="Wealth">${message:Wealth}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.wealth" >> t:id="Wealth" >> t:mixins="decoFeatureInput" >> productName="Wealth" /> >> </div> >> </div> >> </t:if> >> >> <t:if test="group.hasWeatherDegree"> >> <div class="feature"> >> <div class="featureIcon"> >> >> /img/icon/attributes/icon_temperature_55x55.png >> </div> >> <div class="featureLabel"> >> <label class="inputLabel" >> for="Temperature">${message:Temperature}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.weatherDegree" >> t:id="temperature" >> t:mixins="decoFeatureInput" >> productName="WeatherDegree" /> >> </div> >> </div> >> </t:if> >> >> <t:if test="group.hasWeatherType"> >> <div class="feature"> >> <div class="featureIcon"> >> /img/icon/attributes/icon_weather_55x55.png >> </div> >> <div class="featureLabel"> >> <label >> class="inputLabel">${message:Weather}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.weatherType" >> t:mixins="decoFeatureInput" >> productName="WeatherType" /> >> </div> >> </div> >> </t:if> >> >> <t:if test="group.hasGender"> >> <div class="feature"> >> <div class="featureIcon"> >> /img/icon/attributes/icon_gender_55x55.png >> </div> >> <div class="featureLabel"> >> <label >> class="inputLabel">${message:Gender}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.gender" >> t:mixins="decoFeatureInput" >> productName="Gender" /> >> </div> >> </div> >> </t:if> >> >> <t:if test="group.hasAge"> >> <div class="feature"> >> <div class="featureIcon"> >> /img/icon/attributes/icon_age_55x55.png >> </div> >> <div class="featureLabel"> >> <label >> class="inputLabel">${message:Age}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:select value="message.age" >> t:mixins="decoFeatureInput" >> productName="Age" /> >> </div> >> </div> >> </t:if> >> >> <t:if test="group.hasPick"> >> <div class="feature"> >> <div class="featureIcon"> >> /img/icon/attributes/icon_pick_55x55.png >> </div> >> <div class="featureLabel"> >> <label >> class="inputLabel">${message:Pick}</label> >> <br></br> >> </div> >> <div class="featureInput"> >> <t:textfield value="message.amount" >> t:mixins="decoFeatureInput" >> productName="Pick" /> >> </div> >> </div> >> </t:if> >> <div class="complexFeatures"> >> >> <t:if test="group.hasEncryption"> >> <div class="complexFeature"> >> <div class="featureIcon"> >> >> /img/icon/attributes/icon_quiz_55x55.png >> </div> >> <TABLE> >> <TR> >> <TD> >> <label >> class="inputLabel">${message:Quiz}</label> >> </TD> >> <TD></TD> >> </TR> >> <TR> >> <TD>${message:Question}</TD> >> <TD></TD> >> </TR> >> <TR> >> <TD> >> <t:textfield >> t:mixins="decoFeatureInput" >> >> productName="Question" value="message.question" /> >> </TD> >> <TD></TD> >> </TR> >> <TR> >> <TD>${message:Answer}</TD> >> <TD></TD> >> </TR> >> <TR> >> <TD> >> <t:textfield >> t:mixins="decoFeatureInput" >> >> productName="Question" value="message.answer" /> >> </TD> >> <TD></TD> >> </TR> >> </TABLE> >> </div> >> </t:if> >> >> <t:if test="group.hasSchedule"> >> <div class="complexFeature"> >> <div class="featureIcon"> >> >> /img/icon/attributes/icon_time_55x55.png >> </div> >> <TABLE> >> <TR> >> <TD> >> <label >> class="inputLabel">${message:Schedule}</label> >> </TD> >> <TD></TD> >> </TR> >> <TR> >> >> <TD>${message:BeginDate}</TD> >> <TD></TD> >> </TR> >> <TR> >> <TD> >> <t:datefield >> >> productName="Schedule" t:mixins="decoFeatureInput" >> value="message.startDate" t:id="startDate" /> >> </TD> >> <TD></TD> >> </TR> >> <TR> >> <TD>${message:EndDate}</TD> >> <TD></TD> >> </TR> >> <TR> >> <TD> >> <t:datefield >> >> productName="Schedule" value="message.endDate" t:id="endDate" >> t:mixins="decoFeatureInput" /> >> >> </TD> >> <TD></TD> >> </TR> >> </TABLE> >> </div> >> </t:if> >> </div> >> >> <div class="createButton"> >> <t:linkSubmit class="button">${message:CreateAirmessage} >> </t:linkSubmit> >> </div> >> >> </t:form> >> >> </t:layout> >> >> >> package com.myProject.frontend.mixins; >> >> import org.apache.tapestry5.Asset; >> >> import org.apache.tapestry5.BindingConstants; >> import org.apache.tapestry5.MarkupWriter; >> import org.apache.tapestry5.annotations.AfterRender; >> import org.apache.tapestry5.annotations.AfterRenderTemplate; >> import org.apache.tapestry5.annotations.BeforeRenderTemplate; >> import org.apache.tapestry5.annotations.BeginRender; >> import org.apache.tapestry5.annotations.CleanupRender; >> import org.apache.tapestry5.annotations.MixinAfter; >> import org.apache.tapestry5.annotations.Parameter; >> import org.apache.tapestry5.annotations.Path; >> import org.apache.tapestry5.annotations.SetupRender; >> import org.apache.tapestry5.ioc.Messages; >> import org.apache.tapestry5.ioc.annotations.Inject; >> >> import com.myProject.domain.Product; >> import com.myProject.domain.UserProduct; >> import com.myProject.service.data.ProductService; >> import com.myProject.service.data.UserService; >> >> @MixinAfter >> public class DecoFeatureInput { >> @Parameter(defaultPrefix=BindingConstants.LITERAL, required=true) >> private String productName; >> >> @Inject >> private Messages messages; >> >> @Inject >> private ProductService productService; >> @Inject >> private UserService userService; >> @Inject >> @Path("context:/img/icon/icon_star_25x24.png") >> private Asset assetStarImage; >> >> private UserProduct userProduct; >> private Product product; >> >> @SetupRender >> void setupRender(MarkupWriter writer){ >> userProduct = >> productService.getUserProduct(userService.getCurrentUser(), >> productName); >> product = productService.getProduct(productName); >> >> } >> >> @BeginRender >> void beginRender(MarkupWriter writer){ >> if( >> !productService.isAvailableProduct(userService.getCurrentUser(), >> productName) ){ >> writer.attributes("disabled" ,"true"); >> } >> } >> >> @CleanupRender >> void cleanupRender(MarkupWriter writer){ >> if( userProduct == null && product != null ){ >> writer.write(" "); >> >> if( >> !productService.isAvailableProduct(userService.getCurrentUser(), >> productName) ){ >> >> writer.element("div", "class", >> "featureLevelRequired"); >> >> writer.write(messages.get("level-required")); >> writer.element("img", "src", >> assetStarImage.toClientURL()); >> writer.end(); >> writer.write(" " + product.getLevel()); >> writer.end(); >> } else { >> writer.element("div", "class", >> "featureLevelAvailable"); >> >> writer.write(messages.get("feature-available")); >> writer.end(); >> } >> } >> } >> >> } >> >> >> >> -- >> View this message in context: >> http://tapestry.1045711.n5.nabble.com/mixin-with-t-datefield-bug-tp5709435.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 >> >> > > > -- > Emmanuel DEMEY > Ingénieur Etude et Développement > ATOS Worldline > +33 (0)6 47 47 42 02 > demey.emman...@gmail.com > > Twitter : @gillespie59 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org