You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2011/10/07 21:26:27 UTC
svn commit: r1180174 - in
/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag:
MenuBarRenderer.java MenuCommandRenderer.java
Author: bommel
Date: Fri Oct 7 19:26:27 2011
New Revision: 1180174
URL: http://svn.apache.org/viewvc?rev=1180174&view=rev
Log:
reenable images in menubar and writing clientId for menubar and menucommand if available
Modified:
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.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/MenuBarRenderer.java?rev=1180174&r1=1180173&r2=1180174&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Fri Oct 7 19:26:27 2011
@@ -38,6 +38,7 @@ public class MenuBarRenderer extends Lay
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
writer.startElement(HtmlElements.OL, menuBar);
+ writer.writeIdAttribute(menuBar.getClientId(facesContext));
writer.writeClassAttribute(Classes.create(menuBar));
Style style = new Style(facesContext, menuBar);
writer.writeStyleAttribute(style);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.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/MenuCommandRenderer.java?rev=1180174&r1=1180173&r2=1180174&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java Fri Oct 7 19:26:27 2011
@@ -25,6 +25,7 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.internal.util.AccessKeyMap;
+import org.apache.myfaces.tobago.layout.Measure;
import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -108,7 +109,8 @@ public class MenuCommandRenderer extends
// normal menu command
CommandRendererHelper helper = new CommandRendererHelper(facesContext, menu);
String onclick = helper.getOnclick();
- encodeItem(facesContext, writer, menu, label, onclick != null ? onclick : submit, disabled, firstLevel, null);
+ String image = menu.getImage();
+ encodeItem(facesContext, writer, menu, label, onclick != null ? onclick : submit, disabled, firstLevel, image);
}
}
@@ -128,6 +130,9 @@ public class MenuCommandRenderer extends
String onclick, boolean disabled, boolean firstLevel, String image) throws IOException {
writer.startElement(HtmlElements.LI, null);
+ if (component != null) {
+ writer.writeIdAttribute(component.getClientId(facesContext));
+ }
Markup markup = null;
if (component != null) {
markup = component.getCurrentMarkup();
@@ -138,16 +143,42 @@ public class MenuCommandRenderer extends
writer.writeClassAttribute(Classes.createWorkaround("menu", markup)); // todo: solve workaround
writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, true);
+
if (image != null) {
- Style style = new Style();
- style.setBackgroundImage("url("
- + ResourceManagerUtils.getImageWithPath(facesContext, image)
- + ")");
- writer.writeStyleAttribute(style);
+ if (firstLevel) {
+ Style iconStyle = new Style();
+ iconStyle.setLeft(Measure.valueOf(0));
+ iconStyle.setTop(Measure.valueOf(0));
+ iconStyle.setHeight(Measure.valueOf(16));
+ iconStyle.setWidth(Measure.valueOf(16));
+
+ writer.startElement(HtmlElements.IMG, null);
+ String imageWithPath = ResourceManagerUtils.getImageWithPath(facesContext, image, true);
+ writer.writeAttribute(HtmlAttributes.SRC, imageWithPath, false);
+ String imageHover
+ = ResourceManagerUtils.getImageWithPath(facesContext, HtmlRendererUtils.createSrc(image, "Hover"), true);
+ if (imageHover != null) {
+ writer.writeAttribute(HtmlAttributes.SRCDEFAULT, imageWithPath, false);
+ writer.writeAttribute(HtmlAttributes.SRCHOVER, imageHover, false);
+ }
+
+ writer.writeAttribute(HtmlAttributes.ALT, label.getText(), true);
+ writer.writeStyleAttribute(iconStyle);
+ writer.endElement(HtmlElements.IMG);
+ } else {
+ Style style = new Style();
+ style.setBackgroundImage("url("
+ + ResourceManagerUtils.getImageWithPath(facesContext, image)
+ + ")");
+ writer.writeStyleAttribute(style);
+ }
}
writer.startElement(HtmlElements.A, null);
writer.writeAttribute(HtmlAttributes.HREF, "#", false);
+ if (image != null && firstLevel) {
+ writer.writeStyleAttribute("vertical-align:top");
+ }
// writer.writeIdAttribute(clientId);
if (label.getText() != null) {