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 2013/04/29 11:39:33 UTC
svn commit: r1476943 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/
tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/
tobago-theme/tobago-theme-scarborough/src/ma...
Author: lofwyr
Date: Mon Apr 29 09:39:32 2013
New Revision: 1476943
URL: http://svn.apache.org/r1476943
Log:
TOBAGO-1171: Support for the Content Security Policy (CSP)
Added:
myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/
myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
- copied unchanged from r1466554, myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
Removed:
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ScriptHandler.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ScriptHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ScriptHandler.java?rev=1476943&r1=1476942&r2=1476943&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ScriptHandler.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ScriptHandler.java Mon Apr 29 09:39:32 2013
@@ -20,8 +20,6 @@
package org.apache.myfaces.tobago.facelets;
import org.apache.myfaces.tobago.component.UIScript;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.view.facelets.ComponentConfig;
@@ -32,24 +30,15 @@ import javax.faces.view.facelets.TextHan
public class ScriptHandler extends ComponentHandler {
- private static final Logger LOG = LoggerFactory.getLogger(ScriptHandler.class);
-
public ScriptHandler(ComponentConfig config) {
super(config);
}
public void onComponentCreated(FaceletContext context, UIComponent component, UIComponent parent) {
- StringBuilder content = new StringBuilder();
final FaceletHandler next = getComponentConfig().getNextHandler();
if (next instanceof TextHandler) {
- content.append(((TextHandler) next).getText(context));
- } else {
- // TBD: is this okay, or is here something to do?
- // on the other side, Script inside the page is deprecated.
- LOG.warn("Not applied for handler: " + next.getClass().getName());
+ ((UIScript) component).setScript(((TextHandler) next).getText(context));
}
-
- ((UIScript) component).setScript(content.toString());
}
public void applyNextHandler(FaceletContext ctx, UIComponent c) {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.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/TextareaRenderer.java?rev=1476943&r1=1476942&r2=1476943&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextareaRenderer.java Mon Apr 29 09:39:32 2013
@@ -21,10 +21,11 @@ package org.apache.myfaces.tobago.render
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.UITextarea;
-import org.apache.myfaces.tobago.renderkit.HtmlUtils;
import org.apache.myfaces.tobago.renderkit.InputRendererBase;
import org.apache.myfaces.tobago.renderkit.css.Classes;
import org.apache.myfaces.tobago.renderkit.css.Style;
+import org.apache.myfaces.tobago.renderkit.html.Command;
+import org.apache.myfaces.tobago.renderkit.html.CommandMap;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
@@ -51,38 +52,43 @@ public class TextareaRenderer extends In
return;
}
- UITextarea input = (UITextarea) component;
- String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, component);
+ final UITextarea input = (UITextarea) component;
+ final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, component);
+ final String clientId = input.getClientId(facesContext);
+ final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- String clientId = input.getClientId(facesContext);
- String onchange = HtmlUtils.generateOnchange(input, facesContext);
-
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
writer.startElement(HtmlElements.TEXTAREA, input);
writer.writeNameAttribute(clientId);
writer.writeIdAttribute(clientId);
HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
- writer.writeAttribute(HtmlAttributes.ROWS, null, Attributes.ROWS);
+ final Integer rows = input.getRows();
+ if (rows != null) {
+ writer.writeAttribute(HtmlAttributes.ROWS, rows);
+ }
if (title != null) {
writer.writeAttribute(HtmlAttributes.TITLE, title, true);
}
writer.writeAttribute(HtmlAttributes.READONLY, input.isReadonly());
writer.writeAttribute(HtmlAttributes.DISABLED, input.isDisabled());
writer.writeAttribute(HtmlAttributes.REQUIRED, input.isRequired());
- Integer tabIndex = input.getTabIndex();
+ final Integer tabIndex = input.getTabIndex();
if (tabIndex != null) {
writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
}
HtmlRendererUtils.renderDojoDndItem(component, writer, true);
writer.writeClassAttribute(Classes.create(input));
- Style style = new Style(facesContext, input);
+ final Style style = new Style(facesContext, input);
writer.writeStyleAttribute(style);
+ final String onchange = ComponentUtils.getStringAttribute(input, Attributes.ONCHANGE);
if (onchange != null) {
- writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
+ final CommandMap map = new CommandMap();
+ final Command change = new Command();
+ change.setScript(onchange);
+ map.addCommand("change", change);
}
int maxLength = -1;
- String pattern = null;
+ final String pattern = null;
for (Validator validator : input.getValidators()) {
if (validator instanceof LengthValidator) {
LengthValidator lengthValidator = (LengthValidator) validator;
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.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/TreeCommandRenderer.java?rev=1476943&r1=1476942&r2=1476943&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java Mon Apr 29 09:39:32 2013
@@ -19,7 +19,6 @@
package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
-import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.UITreeCommand;
import org.apache.myfaces.tobago.component.UITreeNode;
import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
@@ -28,9 +27,12 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.css.Classes;
import org.apache.myfaces.tobago.renderkit.css.Style;
+import org.apache.myfaces.tobago.renderkit.html.Command;
+import org.apache.myfaces.tobago.renderkit.html.CommandMap;
+import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
-import org.apache.myfaces.tobago.renderkit.html.util.CommandRendererHelper;
+import org.apache.myfaces.tobago.renderkit.html.JsonUtils;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
@@ -58,25 +60,17 @@ public class TreeCommandRenderer extends
@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
- UITreeCommand command = (UITreeCommand) component;
- String clientId = command.getClientId(facesContext);
- CommandRendererHelper helper = new CommandRendererHelper(facesContext, command, CommandRendererHelper.Tag.ANCHOR);
- String href = helper.getHref();
- TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
- LabelWithAccessKey label = new LabelWithAccessKey(command);
+ final UITreeCommand command = (UITreeCommand) component;
+ final String clientId = command.getClientId(facesContext);
+ final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ final LabelWithAccessKey label = new LabelWithAccessKey(command);
- if (helper.isDisabled()) {
+ if (command.isDisabled()) {
writer.startElement(HtmlElements.SPAN, command);
} else {
writer.startElement(HtmlElements.A, command);
- writer.writeAttribute(HtmlAttributes.HREF, href, true);
- if (helper.getOnclick() != null) {
- writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true);
- }
- if (helper.getTarget() != null) {
- writer.writeAttribute(HtmlAttributes.TARGET, helper.getTarget(), true);
- }
+ final CommandMap map = new CommandMap(new Command(facesContext, command));
+ writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
writer.writeNameAttribute(clientId);
}
writer.writeStyleAttribute(createStyle(facesContext, command));
@@ -109,10 +103,10 @@ public class TreeCommandRenderer extends
}
@Override
- public void encodeEnd(FacesContext facesContext, UIComponent component)
- throws IOException {
- ResponseWriter writer = facesContext.getResponseWriter();
- if (ComponentUtils.getBooleanAttribute(component, Attributes.DISABLED)) {
+ public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ final UITreeCommand command = (UITreeCommand) component;
+ final ResponseWriter writer = facesContext.getResponseWriter();
+ if (command.isDisabled()) {
writer.endElement(HtmlElements.SPAN);
} else {
writer.endElement(HtmlElements.A);
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg?rev=1476943&r1=1476942&r2=1476943&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component2.0.stg Mon Apr 29 09:39:32 2013
@@ -383,7 +383,6 @@ NormalProperty(property) ::= <<
<createDescription(property)>
<checkDeprecated(property)>
public <property.type> get<property.upperCamelCaseName>() {
- <logDeprecated(property)>
<if(property.transient)>
if (<property.propertyName> != null) {
return <property.propertyName>;
@@ -405,6 +404,7 @@ public <property.type> get<property.uppe
<checkDeprecated(property)>
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
+ <logDeprecated(property)>
<if(property.transient)>
<else>
getStateHelper().put(PropertyKeys.<property.propertyName>, <property.propertyName>);