Author: drobiazko Date: Mon Nov 7 17:25:34 2011 New Revision: 1198824 URL: http://svn.apache.org/viewvc?rev=1198824&view=rev Log: Back porting changes for Checklist from 5.4.
Modified: tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java tapestry/tapestry5/branches/5.3/tapestry-core/src/main/resources/org/apache/tapestry5/default.css Modified: tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java?rev=1198824&r1=1198823&r2=1198824&view=diff ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java (original) +++ tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checklist.java Mon Nov 7 17:25:34 2011 @@ -24,6 +24,7 @@ import org.apache.tapestry5.ioc.annotati import org.apache.tapestry5.ioc.internal.util.CollectionFactory; import org.apache.tapestry5.services.ComponentDefaultProvider; import org.apache.tapestry5.services.Request; +import org.apache.tapestry5.services.javascript.JavaScriptSupport; import java.util.Collections; import java.util.List; @@ -92,6 +93,9 @@ public class Checklist extends AbstractF @Inject private ComponentDefaultProvider defaultProvider; + @Inject + private JavaScriptSupport javaScriptSupport; + @Property private List<Renderable> availableOptions; @@ -108,19 +112,21 @@ public class Checklist extends AbstractF public void render(MarkupWriter writer) { - writer.element("label"); - writer.write(model.getLabel()); - writer.end(); + final String clientId = javaScriptSupport.allocateClientId(componentResources); final String clientValue = encoder.toClient(model.getValue()); - final Element checkbox = writer.element("input", "type", "checkbox", "name", getControlName(), "value", clientValue); + final Element checkbox = writer.element("input", "type", "checkbox", "id", clientId, "name", getControlName(), "value", clientValue); if (getSelected().contains(model.getValue())) { checkbox.attribute("checked", "checked"); } writer.end(); + + writer.element("label", "for", clientId); + writer.write(model.getLabel()); + writer.end(); } } Modified: tapestry/tapestry5/branches/5.3/tapestry-core/src/main/resources/org/apache/tapestry5/default.css URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/main/resources/org/apache/tapestry5/default.css?rev=1198824&r1=1198823&r2=1198824&view=diff ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-core/src/main/resources/org/apache/tapestry5/default.css (original) +++ tapestry/tapestry5/branches/5.3/tapestry-core/src/main/resources/org/apache/tapestry5/default.css Mon Nov 7 17:25:34 2011 @@ -210,12 +210,8 @@ DIV.t-checklist-row { } DIV.t-checklist-row LABEL { - width: 150px; - display: block; - float: left; text-align: right; - clear: left; - padding-right: 3px; + padding-left: 5px; vertical-align: middle; } @@ -519,4 +515,4 @@ DIV.t-exception-container .t-exception-c border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -} \ No newline at end of file +}