You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/04/25 14:10:31 UTC
svn commit: r1330229 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/...
Author: lofwyr
Date: Wed Apr 25 12:10:30 2012
New Revision: 1330229
URL: http://svn.apache.org/viewvc?rev=1330229&view=rev
Log:
TOBAGO-1111: tc:datePicker should have the standard attributes
Added:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java (contents, props changed)
- copied, changed from r1328229, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIDatePicker.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUILink.java
Removed:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIDatePicker.java
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DatePickerTagDeclaration.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/LinkTagDeclaration.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/date/date-tobago-1105.xhtml
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java Wed Apr 25 12:10:30 2012
@@ -19,4 +19,7 @@ package org.apache.myfaces.tobago.intern
public abstract class AbstractUIDate extends AbstractUIInput {
+ public abstract boolean isDisabled();
+
+ public abstract boolean isReadonly();
}
Copied: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java (from r1328229, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIDatePicker.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java?p2=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java&p1=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIDatePicker.java&r1=1328229&r2=1330229&rev=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/UIDatePicker.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java Wed Apr 25 12:10:30 2012
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.component;
+package org.apache.myfaces.tobago.internal.component;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,66 +17,30 @@ package org.apache.myfaces.tobago.compon
* limitations under the License.
*/
-import org.apache.myfaces.tobago.internal.component.AbstractUIForm;
+import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.OnComponentCreated;
import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
import javax.faces.render.Renderer;
-import java.util.List;
-/*
- * Date: 30.05.2006
- * Time: 19:22:40
- */
-public class UIDatePicker extends UILink implements OnComponentCreated {
+public abstract class AbstractUIDatePicker extends AbstractUILink implements OnComponentCreated {
- public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.DatePicker";
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractUIDatePicker.class);
- private String forComponent;
+ public abstract String getFor();
- public Object saveState(FacesContext context) {
- Object[] values = new Object[2];
- values[0] = super.saveState(context);
- values[1] = forComponent;
- return values;
- }
-
- public void restoreState(FacesContext context, Object savedState) {
- Object[] values = (Object[]) savedState;
- super.restoreState(context, values[0]);
- forComponent = (String) values[1];
- }
-
- private UIComponent getUIDateInput(UIComponent parent) {
- for (UIComponent child : (List<UIComponent>) parent.getChildren()) {
- if (child instanceof UIDate) {
- return child;
- }
- }
- return null;
- }
+ public abstract void setDisabled(boolean disabled);
- public String getFor() {
- return forComponent;
- }
-
- // XXX May be better use ComponentUtils.evaluateAutoFor()
public UIComponent getForComponent() {
- if ("@auto".equals(forComponent)) {
- UIComponent component = getUIDateInput(getParent());
- if (component == null && getParent() instanceof AbstractUIForm) {
- component = getUIDateInput(getParent().getParent());
- }
- return component;
- } else {
- return findComponent(forComponent);
- }
- }
-
- public void setFor(String forComponent) {
- this.forComponent = forComponent;
+ ComponentUtils.evaluateAutoFor(this, AbstractUIDate.class);
+ return ComponentUtils.findFor(this);
}
public void broadcast(FacesEvent facesEvent) {
@@ -99,4 +63,8 @@ public class UIDatePicker extends UILink
((RendererBase) renderer).onComponentCreated(context, this, parent);
}
}
+
+ public String getTarget() {
+ return null;
+ }
}
Propchange: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUILink.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUILink.java?rev=1330229&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUILink.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUILink.java Wed Apr 25 12:10:30 2012
@@ -0,0 +1,29 @@
+package org.apache.myfaces.tobago.internal.component;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public abstract class AbstractUILink extends AbstractUICommand {
+
+ public abstract java.lang.String getImage();
+
+ public abstract Integer getTabIndex();
+
+ public abstract String getTip();
+
+ public abstract boolean isDisabled();
+}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DatePickerTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DatePickerTagDeclaration.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DatePickerTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DatePickerTagDeclaration.java Wed Apr 25 12:10:30 2012
@@ -19,14 +19,14 @@ package org.apache.myfaces.tobago.intern
import org.apache.myfaces.tobago.apt.annotation.Tag;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasCurrentMarkup;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasFor;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasTabIndex;
-
-/*
- * Date: 30.05.2006
- * Time: 19:17:28
- */
+import org.apache.myfaces.tobago.internal.taglib.declaration.IsGridLayoutComponent;
/**
* Renders a date picker.
@@ -37,10 +37,34 @@ import org.apache.myfaces.tobago.interna
@Tag(name = "datePicker")
@UIComponentTag(
uiComponent = "org.apache.myfaces.tobago.component.UIDatePicker",
- uiComponentBaseClass = "org.apache.myfaces.tobago.component.UILink",
- generate = false,
+ uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIDatePicker",
componentType = "org.apache.myfaces.tobago.DatePicker",
rendererType = RendererTypes.DATE_PICKER,
allowedChildComponenents = "NONE")
-public interface DatePickerTagDeclaration extends HasFor, HasTabIndex {
+public interface DatePickerTagDeclaration
+ extends HasFor, HasTabIndex, HasIdBindingAndRendered, HasMarkup, HasCurrentMarkup, IsGridLayoutComponent {
+
+ @UIComponentTagAttribute()
+ void setLink(String link);
+
+ @UIComponentTagAttribute()
+ void setResource(String resource);
+
+ @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
+ void setJsfResource(String jsfResource);
+
+ @UIComponentTagAttribute()
+ void setOnclick(String onclick);
+
+ @UIComponentTagAttribute()
+ void setTip(String tip);
+
+ @UIComponentTagAttribute()
+ void setImage(String image);
+
+ @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
+ void setDisabled(String disabled);
+
+ @UIComponentTagAttribute(type = "java.lang.String[]")
+ void setRenderedPartially(String componentIds);
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/LinkTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/LinkTagDeclaration.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/LinkTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/LinkTagDeclaration.java Wed Apr 25 12:10:30 2012
@@ -43,7 +43,7 @@ import org.apache.myfaces.tobago.interna
@BodyContentDescription(anyTagOf = "facestag")
@UIComponentTag(
uiComponent = "org.apache.myfaces.tobago.component.UILink",
- uiComponentBaseClass = "org.apache.myfaces.tobago.component.UICommand",
+ uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUILink",
interfaces = "org.apache.myfaces.tobago.component.UILinkCommand",
rendererType = RendererTypes.LINK,
allowedChildComponenents = "NONE",
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Wed Apr 25 12:10:30 2012
@@ -285,7 +285,9 @@ public class ComponentUtils {
* In case that the value is equals to "@auto" the children of the parent will be
* checked if they are a UIInput. The "id" of the first one will be used to reset the "for"
* attribute of the component.
+ * @deprecated
*/
+ @Deprecated
public static void evaluateAutoFor(UIComponent component) {
String forComponent = (String) component.getAttributes().get(Attributes.FOR);
if (LOG.isDebugEnabled()) {
@@ -293,16 +295,50 @@ public class ComponentUtils {
}
if ("@auto".equals(forComponent)) {
for (Object object : component.getParent().getChildren()) {
- UIComponent child = (UIComponent) object;
- if (child instanceof UIInput) {
- forComponent = child.getId();
- component.getAttributes().put(Attributes.FOR, forComponent);
+ if (setForToInput(component, (UIComponent) object, AbstractUIInput.class)) {
break;
}
}
}
}
+ /**
+ * Looks for the attribute "for" of the component.
+ * In case that the value is equals to "@auto" the children of the parent will be
+ * checked if they are of the type of the parameter clazz. The "id" of the first one will be used to reset the "for"
+ * attribute of the component.
+ */
+ public static void evaluateAutoFor(UIComponent component, Class<? extends UIComponent> clazz) {
+ String forComponent = (String) component.getAttributes().get(Attributes.FOR);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("for = '" + forComponent + "'");
+ }
+ if ("@auto".equals(forComponent)) {
+ // grand parent
+ for (Object object : component.getParent().getChildren()) {
+ if (setForToInput(component, (UIComponent) object, clazz)) {
+ return;
+ }
+ }
+ // grand parent
+ for (Object object : component.getParent().getParent().getChildren()) {
+ if (setForToInput(component, (UIComponent) object, clazz)) {
+ return;
+ }
+ }
+ }
+ }
+
+ private static boolean setForToInput(UIComponent component, UIComponent child, Class<? extends UIComponent> clazz) {
+ final String forComponent;
+ if (clazz.isAssignableFrom(child.getClass())) { // find the matching component
+ forComponent = child.getId();
+ component.getAttributes().put(Attributes.FOR, forComponent);
+ return true;
+ }
+ return false;
+ }
+
public static boolean isInActiveForm(UIComponent component) {
while (component != null) {
if (component instanceof AbstractUIForm) {
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/date/date-tobago-1105.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/date/date-tobago-1105.xhtml?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/date/date-tobago-1105.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/date/date-tobago-1105.xhtml Wed Apr 25 12:10:30 2012
@@ -25,22 +25,22 @@
<tc:page id="page">
<tc:box>
<f:facet name="layout">
- <tc:gridLayout columns="2*;*" rows="auto;auto;auto"/>
+ <tc:gridLayout columns="2*;*" rows="auto;auto;auto;auto;auto"/>
</f:facet>
<tc:gridLayoutConstraint width="900px" height="300px" marginLeft="10px" marginTop="10px" marginRight="10px"/>
- <tc:date readonly="#{false}" id="x">
- <f:convertDateTime type="date" pattern="HH:mm:ss"/>
+ <tc:date readonly="#{false}" id="normal">
+ <f:convertDateTime/>
</tc:date>
- <tc:datePicker for="x"/>
+ <tc:datePicker for="normal"/>
<tc:date readonly="#{true}" id="readonly">
- <f:convertDateTime type="date" pattern="HH:mm:ss"/>
+ <f:convertDateTime/>
</tc:date>
<tc:datePicker for="readonly" id="readonlyPicker"/>
<tc:date disabled="#{true}" id="disabled">
- <f:convertDateTime type="date" pattern="HH:mm:ss"/>
+ <f:convertDateTime/>
</tc:date>
<tc:datePicker for="disabled" id="disabledPicker"/>
@@ -49,13 +49,15 @@
<tc:script onload="check()">
function check() {
// assertions
- if (jQuery(Tobago.Utils.escapeClientId("page:readonlyPicker")).filter("span").size() == 0) {
- LOG.error("The element with id='" + "page:readonlyPicker" + "' was not found or is not a 'span' tag!");
+ var id1 = "page:readonlyPicker";
+ if (jQuery(Tobago.Utils.escapeClientId(id1)).filter("span").size() == 0) {
+ LOG.error("The element with id='" + id1 + "' was not found or is not a 'span' tag!");
}
// assertions
- if (jQuery(Tobago.Utils.escapeClientId("page:disabledPicker")).filter("span").size() == 0) {
- LOG.error("The element with id='" + "page:disabledPicker" + "' was not found or is not a 'span' tag!");
+ var id2 = "page:disabledPicker";
+ if (jQuery(Tobago.Utils.escapeClientId(id2)).filter("span").size() == 0) {
+ LOG.error("The element with id='" + id2 + "' was not found or is not a 'span' tag!");
}
}
</tc:script>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java Wed Apr 25 12:10:30 2012
@@ -183,7 +183,7 @@ public class DatePickerRenderer extends
UIDatePicker picker = (UIDatePicker) component;
UIDate dateInput = (UIDate) picker.getForComponent();
if (dateInput == null) {
- LOG.error("No required UIDate component found.");
+ LOG.error("The required UIDate component wasn't found for component id='" + component.getId());
return;
}
// this can't be done in "onComponentPopulated()" of the picker, it seems to be to early
@@ -246,7 +246,7 @@ public class DatePickerRenderer extends
if (dateInput != null) {
super.encodeEnd(facesContext, component);
} else {
- LOG.error("No required UIDate component found.");
+ LOG.error("The required UIDate component wasn't found for component id='" + component.getId());
}
}
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java Wed Apr 25 12:10:30 2012
@@ -19,6 +19,7 @@ package org.apache.myfaces.tobago.render
import org.apache.myfaces.tobago.component.UILabel;
import org.apache.myfaces.tobago.context.Markup;
+import org.apache.myfaces.tobago.internal.component.AbstractUIDate;
import org.apache.myfaces.tobago.internal.util.AccessKeyMap;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
@@ -44,7 +45,7 @@ public class LabelRenderer extends Layou
public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
super.prepareRender(facesContext, component);
- ComponentUtils.evaluateAutoFor(component);
+ ComponentUtils.evaluateAutoFor(component, AbstractUIDate.class);
// adding the markups from the corresponding input component
final UILabel label = (UILabel) component;
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java?rev=1330229&r1=1330228&r2=1330229&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java Wed Apr 25 12:10:30 2012
@@ -17,16 +17,10 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
-/*
- * Created 07.02.2003 16:00:00.
- * $Id$
- */
-
-import org.apache.myfaces.tobago.component.UILink;
import org.apache.myfaces.tobago.config.Configurable;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUILink;
import org.apache.myfaces.tobago.internal.util.AccessKeyMap;
-import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.layout.Measure;
import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
@@ -52,7 +46,7 @@ public class LinkRenderer extends Comman
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
- UILink link = (UILink) component;
+ AbstractUILink link = (AbstractUILink) component;
String clientId = link.getClientId(facesContext);
CommandRendererHelper helper = new CommandRendererHelper(facesContext, link, CommandRendererHelper.Tag.ANCHOR);
String href = helper.getHref();
@@ -71,13 +65,7 @@ public class LinkRenderer extends Comman
if (helper.getTarget() != null) {
writer.writeAttribute(HtmlAttributes.TARGET, helper.getTarget(), true);
}
- Integer tabIndex = null;
- if (link instanceof UILink) {
- tabIndex = ((UILink) link).getTabIndex();
- } else {
- Deprecation.LOG.warn("LinkRenderer should only render UILink but got " + link.getClass().getName()
- + " id=" + link.getClientId(facesContext));
- }
+ Integer tabIndex = link.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
@@ -129,8 +117,7 @@ public class LinkRenderer extends Comman
}
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
-
- UILink link = (UILink) component;
+ AbstractUILink link = (AbstractUILink) component;
ResponseWriter writer = facesContext.getResponseWriter();
if (link.isDisabled()) {
writer.endElement(HtmlElements.SPAN);
@@ -141,7 +128,7 @@ public class LinkRenderer extends Comman
@Override
public Measure getPreferredWidth(FacesContext facesContext, Configurable component) {
- UILink link = (UILink) component;
+ AbstractUILink link = (AbstractUILink) component;
LabelWithAccessKey label = new LabelWithAccessKey(link);
return RenderUtils.calculateStringWidth(facesContext, link, label.getText());
}