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 2014/09/03 13:21:14 UTC
svn commit: r1622223 - in /myfaces/tobago/branches/tobago-3.0.x: ./
tobago-core/src/main/java/org/apache/myfaces/tobago/event/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/
tobago-core/src/main/java/org/apache/myfaces...
Author: lofwyr
Date: Wed Sep 3 11:21:14 2014
New Revision: 1622223
URL: http://svn.apache.org/r1622223
Log:
Merge from trunk: 1621282,1621332,1622222
cleanup
Removed:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/FindComponentUtils.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtilsUnitTest.java
Modified:
myfaces/tobago/branches/tobago-3.0.x/ (props changed)
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasRenderedPartially.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml (contents, props changed)
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/50-partial/partial.xhtml
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/header.xhtml
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-theme-example/src/main/java/org/apache/myfaces/tobago/renderkit/html/example/standard/tag/InRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (contents, props changed)
Propchange: myfaces/tobago/branches/tobago-3.0.x/
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk:r1621282,1621332,1622222
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java Wed Sep 3 11:21:14 2014
@@ -19,7 +19,7 @@
package org.apache.myfaces.tobago.event;
-import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
@@ -44,7 +44,7 @@ public class ResetInputActionListener ex
public void processAction(final ActionEvent event) {
for (final String clientId : clientIds) {
- final UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
+ final UIComponent component = ComponentUtils.findComponent(event.getComponent(), clientId);
if (component != null) {
resetChildren(component);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java Wed Sep 3 11:21:14 2014
@@ -20,7 +20,7 @@
package org.apache.myfaces.tobago.event;
import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
-import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,7 +59,7 @@ public class ValueExpressionPopupActionL
@Override
protected AbstractUIPopup getPopup(final ActionEvent actionEvent) {
final String id = (String) popupIdExpression.getValue(FacesContext.getCurrentInstance().getELContext());
- final UIComponent popup = FindComponentUtils.findComponent(actionEvent.getComponent(), id);
+ final UIComponent popup = ComponentUtils.findComponent(actionEvent.getComponent(), id);
if (popup instanceof AbstractUIPopup) {
return (AbstractUIPopup) popup;
} else {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionResetInputActionListener.java Wed Sep 3 11:21:14 2014
@@ -20,8 +20,8 @@
package org.apache.myfaces.tobago.event;
-import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
import org.apache.myfaces.tobago.internal.util.StringUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ public class ValueExpressionResetInputAc
return;
}
for (final String clientId : clientIds) {
- final UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
+ final UIComponent component = ComponentUtils.findComponent(event.getComponent(), clientId);
if (component != null) {
resetChildren(component);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasRenderedPartially.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasRenderedPartially.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasRenderedPartially.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasRenderedPartially.java Wed Sep 3 11:21:14 2014
@@ -26,21 +26,30 @@ import org.apache.myfaces.tobago.apt.ann
public interface HasRenderedPartially {
/**
* <p>
- * Indicate the partially rendered Components in a case of a submit.
+ * Indicate the partially rendered components in a case of a submit.
* </p>
* <p>
* The search depends on the number of prefixed colons in the relativeId:
* <dl>
- * <dd>colonCount == 0</dd>
+ * <dd>number of prefixed colons == 0</dd>
* <dt>fully relative</dt>
- * <dd>colonCount == 1</dd>
+ * <dd>number of prefixed colons == 1</dd>
* <dt>absolute (still normal findComponent syntax)</dt>
- * <dd>colonCount > 1</dd>
- * <dt>for each extra colon after 1, go up a naming container</dt>
+ * <dd>number of prefixed colons == 2</dd>
+ * <dt>search in the current naming container (same as 0 colons)</dt>
+ * <dd>number of prefixed colons == 3</dd>
+ * <dt>search in the parent naming container of the current naming container</dt>
+ * <dd>number of prefixed colons > 3</dd>
+ * <dt>go to the next parent naming container for each additional colon</dt>
* </dl>
* </p>
* <p>
- * If a literal is specified the identifiers must be space delimited.
+ * If a literal is specified: to use more than one identifier the identifiers must be space delimited.
+ * </p>
+ * <p>
+ * Using this in a UISheet component this list indicates components to update when calling
+ * internal AJAX requests like sort or paging commands.
+ * Don't forget to add the sheets id in that case, if needed.
* </p>
*/
@TagAttribute
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Wed Sep 3 11:21:14 2014
@@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.component.SupportsMarkup;
+import org.apache.myfaces.tobago.component.UISheet;
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.TransientStateHolder;
import org.apache.myfaces.tobago.event.AbstractPopupActionListener;
@@ -31,7 +32,6 @@ import org.apache.myfaces.tobago.interna
import org.apache.myfaces.tobago.internal.component.AbstractUIPage;
import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
import org.apache.myfaces.tobago.internal.util.ArrayUtils;
-import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
import org.apache.myfaces.tobago.internal.util.ObjectUtils;
import org.apache.myfaces.tobago.internal.util.StringUtils;
import org.apache.myfaces.tobago.renderkit.RendererBase;
@@ -47,6 +47,7 @@ import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIGraphic;
import javax.faces.component.UIInput;
+import javax.faces.component.UINamingContainer;
import javax.faces.component.UIOutput;
import javax.faces.component.UIParameter;
import javax.faces.component.UISelectMany;
@@ -773,19 +774,98 @@ public final class ComponentUtils {
}
/**
- * The search depends on the number of colons in the relativeId:
+ * <p>
+ * The search depends on the number of prefixed colons in the relativeId:
* <dl>
- * <dd>colonCount == 0</dd>
+ * <dd>number of prefixed colons == 0</dd>
* <dt>fully relative</dt>
- * <dd>colonCount == 1</dd>
+ * <dd>number of prefixed colons == 1</dd>
* <dt>absolute (still normal findComponent syntax)</dt>
- * <dd>colonCount > 1</dd>
- * <dt>for each extra colon after 1, go up a naming container</dt>
+ * <dd>number of prefixed colons == 2</dd>
+ * <dt>search in the current naming container (same as 0 colons)</dt>
+ * <dd>number of prefixed colons == 3</dd>
+ * <dt>search in the parent naming container of the current naming container</dt>
+ * <dd>number of prefixed colons > 3</dd>
+ * <dt>go to the next parent naming container for each additional colon</dt>
* </dl>
- * (to the view root, if naming containers run out)
+ * </p>
+ * <p>
+ * If a literal is specified: to use more than one identifier the identifiers must be space delimited.
+ * </p>
*/
public static UIComponent findComponent(final UIComponent from, final String relativeId) {
- return FindComponentUtils.findComponent(from, relativeId);
+ UIComponent from1 = from;
+ String relativeId1 = relativeId;
+ final int idLength = relativeId1.length();
+ if (idLength > 0 && relativeId1.charAt(0) == '@') {
+ if (relativeId1.equals("@this")) {
+ return from1;
+ }
+ }
+
+ // Figure out how many colons
+ int colonCount = 0;
+ while (colonCount < idLength) {
+ if (relativeId1.charAt(colonCount) != UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance())) {
+ break;
+ }
+ colonCount++;
+ }
+
+ // colonCount == 0: fully relative
+ // colonCount == 1: absolute (still normal findComponent syntax)
+ // colonCount > 1: for each extra colon after 1, go up a naming container
+ // (to the view root, if naming containers run out)
+ if (colonCount > 1) {
+ relativeId1 = relativeId1.substring(colonCount);
+ for (int j = 1; j < colonCount; j++) {
+ while (from1.getParent() != null) {
+ from1 = from1.getParent();
+ if (from1 instanceof NamingContainer) {
+ break;
+ }
+ }
+ }
+ }
+ return from1.findComponent(relativeId1);
+ }
+
+ /**
+ * Resolves the real clientIds.
+ */
+ public static String[] evaluateClientIds(
+ final FacesContext context, final UIComponent component, final String[] componentId) {
+ final List<String> result = new ArrayList<String>(componentId.length);
+ for (final String id : componentId) {
+ if (!StringUtils.isBlank(id)) {
+ final String clientId = evaluateClientId(context, component, id);
+ if (clientId != null) {
+ result.add(clientId);
+ }
+ }
+ }
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+
+ /**
+ * Resolves the real clientId.
+ */
+ public static String evaluateClientId(
+ final FacesContext context, final UIComponent component, final String componentId) {
+ final UIComponent partiallyComponent = ComponentUtils.findComponent(component, componentId);
+ if (partiallyComponent != null) {
+ final String clientId = partiallyComponent.getClientId(context);
+ if (partiallyComponent instanceof UISheet) {
+ final int rowIndex = ((UISheet) partiallyComponent).getRowIndex();
+ if (rowIndex >= 0 && clientId.endsWith(Integer.toString(rowIndex))) {
+ return clientId.substring(0, clientId.lastIndexOf(UINamingContainer.getSeparatorChar(context)));
+ }
+ }
+ return clientId;
+ }
+ LOG.error("No component found for id='" + componentId + "', "
+ + "search base component is '" + component.getClientId(context) + "'");
+ return null;
}
public static String[] splitList(final String renderers) {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml Wed Sep 3 11:21:14 2014
@@ -139,7 +139,8 @@
directLinkCount="#{overviewController.sheetConfig.sheetDirectLinkCount}"
stateChangeListener="#{demo.stateChangeListener}"
sortActionListener="#{overviewController.sheetSorter}"
- selectable="#{overviewController.sheetConfig.selectable}">
+ selectable="#{overviewController.sheetConfig.selectable}"
+ renderedPartially=":page:header:headerInfo sheet">
<!--
<f:facet name="reload">
<tc:reload frequency="2000" />
Propchange: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml:r1621332
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/50-partial/partial.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/50-partial/partial.xhtml?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/50-partial/partial.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/50-partial/partial.xhtml Wed Sep 3 11:21:14 2014
@@ -87,31 +87,31 @@
</f:facet>
<tc:button label="Reload left" tip="Reload left side box"
- action="#{partialReloadController.reload}" renderedPartially="left"/>
+ action="#{partialReloadController.reload}" renderedPartially="left :page:header:headerInfo"/>
<tc:button label="Reload right" tip="Reload right side box"
- action="#{partialReloadController.reload}" renderedPartially="right"/>
+ action="#{partialReloadController.reload}" renderedPartially="right :page:header:headerInfo"/>
<tc:button label="Reload both" tip="Reload both boxes"
- action="#{partialReloadController.reload}" renderedPartially="left right">
+ action="#{partialReloadController.reload}" renderedPartially="left right :page:header:headerInfo">
<tc:gridLayoutConstraint columnSpan="2"/>
</tc:button>
<tc:button label="Reload full panel"
tip="Reload the full area inside the outer box"
- action="#{partialReloadController.reload}" renderedPartially="parent">
+ action="#{partialReloadController.reload}" renderedPartially="parent :page:header:headerInfo">
<tc:gridLayoutConstraint columnSpan="2"/>
</tc:button>
<tc:button label="Reload both (wait 3 s)"
tip="Reload both boxes, but the server has a delay of 3 seconds"
- action="#{partialReloadController.waitAndReload3}" renderedPartially="left right">
+ action="#{partialReloadController.waitAndReload3}" renderedPartially="left right :page:header:headerInfo">
<tc:gridLayoutConstraint columnSpan="2"/>
</tc:button>
- <tc:button label="Reload both (wait 7 s)"
+ <tc:button label="Reload both (wait 7 s, timeout)"
tip="Reload both boxes, but the server has a delay of 7 seconds, this is more than the default timeout for AJAX"
- action="#{partialReloadController.waitAndReload7}" renderedPartially="left right">
+ action="#{partialReloadController.waitAndReload7}" renderedPartially="left right :page:header:headerInfo">
<tc:gridLayoutConstraint columnSpan="2"/>
</tc:button>
@@ -120,8 +120,7 @@
<tx:selectOneChoice fieldId="navSelect" value="#{partialReloadController.navigateAction}" label="On Change">
<f:facet name="change">
- <!-- XXX value="fixme" should be empty, but it doesn't work with an empty string -->
- <tc:command action="#{partialReloadController.navigateAction}" renderedPartially="navTest"/>
+ <tc:command action="#{partialReloadController.navigateAction}" renderedPartially="navTest :page:header:headerInfo"/>
</f:facet>
<f:selectItem itemLabel="Select action" itemValue=""/>
<f:selectItem itemLabel="Reload left" itemValue="left"/>
@@ -135,10 +134,10 @@
</tc:panel>
<tc:button label="Error left" tip="Reload left side box, but an exception occures"
- action="#{partialReloadController.error}" renderedPartially="left"/>
+ action="#{partialReloadController.error}" renderedPartially="left :page:header:headerInfo"/>
<tc:button label="Error right" tip="Reload right side box, but an exception occures"
- action="#{partialReloadController.error}" renderedPartially="right"/>
+ action="#{partialReloadController.error}" renderedPartially="right :page:header:headerInfo"/>
</tc:panel>
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/header.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/header.xhtml?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/header.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/header.xhtml Wed Sep 3 11:21:14 2014
@@ -22,7 +22,7 @@
xmlns:tc="http://myfaces.apache.org/tobago/component">
<tc:panel>
<f:facet name="layout">
- <tc:gridLayout columns="150px;*;200px"/>
+ <tc:gridLayout columns="150px;*;400px"/>
</f:facet>
<tc:link action="#{navigationState.gotoFirst}" immediate="true" image="image/tobago_head.png"/>
@@ -34,14 +34,15 @@
<tc:out value="The demo is in progress." markup="strong"/>
</tc:panel>
- <tc:panel>
+ <tc:panel id="headerInfo">
<f:facet name="layout">
- <tc:gridLayout rows="auto;auto;auto"/>
+ <tc:gridLayout rows="auto;auto;auto" columns="*;*"/>
</f:facet>
<tc:out value="Theme: #{clientConfigController.localizedTheme}"/>
<tc:out value="Locale: #{clientConfigController.localizedLocale}"/>
<tc:out value="Project Stage: #{tobagoContext.tobagoConfig.projectStage}"/>
<tc:out value="CSP mode: #{tobagoContext.tobagoConfig.contentSecurityPolicy.mode}"/>
+ <tc:out value="Requests: #{activityList.values[0].jsfRequest} / AJAX: #{activityList.values[0].ajaxRequest}"/>
</tc:panel>
</tc:panel>
</f:subview>
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-theme-example/src/main/java/org/apache/myfaces/tobago/renderkit/html/example/standard/tag/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-theme-example/src/main/java/org/apache/myfaces/tobago/renderkit/html/example/standard/tag/InRenderer.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-theme-example/src/main/java/org/apache/myfaces/tobago/renderkit/html/example/standard/tag/InRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-theme-example/src/main/java/org/apache/myfaces/tobago/renderkit/html/example/standard/tag/InRenderer.java Wed Sep 3 11:21:14 2014
@@ -20,7 +20,6 @@
package org.apache.myfaces.tobago.renderkit.html.example.standard.tag;
import org.apache.myfaces.tobago.component.UIIn;
-import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -51,12 +50,14 @@ public class InRenderer extends org.apac
if (markup.equals("changeaware")) {
final String id = in.getClientId(facesContext);
final String[] cmds = {"new Example.ChangeAware('" + id + "');"};
- HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
+ // FIXME: this needed to be refactored, because of CSP
+// HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
}
if (markup.equals("blink")) {
final String id = in.getClientId(facesContext);
final String[] cmds = {"new Example.Blinker('" + id + "');"};
- HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
+ // FIXME: this needed to be refactored, because of CSP
+// HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
}
}
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java Wed Sep 3 11:21:14 2014
@@ -26,7 +26,6 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.internal.util.StringUtils;
-import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -82,7 +81,7 @@ public class Command {
command.isTransition(),
command.getTarget(),
RenderUtils.generateUrl(facesContext, command),
- HtmlRendererUtils.getComponentIdsAsList(facesContext, command, command.getRenderedPartially()),
+ ComponentUtils.evaluateClientIds(facesContext, command, command.getRenderedPartially()),
null,
getConfirmation(command),
null,
@@ -109,7 +108,7 @@ public class Command {
}
if (facetComponent instanceof AbstractUICommand
&& ((AbstractUICommand) facetComponent).getRenderedPartially().length > 0) {
- this.partially = HtmlRendererUtils.getComponentIdsAsList(
+ this.partially = ComponentUtils.evaluateClientIds(
facesContext, facetComponent, ((UICommand) facetComponent).getRenderedPartially());
} else {
String facetAction = (String) facetComponent.getAttributes().get(Attributes.ONCLICK);
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java Wed Sep 3 11:21:14 2014
@@ -31,7 +31,13 @@ public class JsonUtils {
private static void encode(final StringBuilder builder, final String name, final String[] value) {
builder.append("\"");
builder.append(name);
- builder.append("\":[");
+ builder.append("\":");
+ encode(builder, value);
+ builder.append(",");
+ }
+
+ public static void encode(StringBuilder builder, String[] value) {
+ builder.append("[");
boolean colon = false;
for (final String item : value) {
if (colon) {
@@ -42,7 +48,7 @@ public class JsonUtils {
builder.append("\"");
colon = true;
}
- builder.append("],");
+ builder.append("]");
}
static void encode(final StringBuilder builder, final String name, final Boolean value) {
@@ -62,7 +68,7 @@ public class JsonUtils {
}
static void encode(final StringBuilder builder, final String name, String value) {
- value = value.replaceAll("\\\"", "\\\\\\\"");
+ value = value.replaceAll("\\\"", "\\\\\\\""); // todo: optimize
builder.append("\"");
builder.append(name);
builder.append("\":\"");
@@ -200,4 +206,13 @@ public class JsonUtils {
builder.append("}");
return builder.toString();
}
+
+ public static String encode(final String[] strings) {
+ if (strings == null) {
+ return null;
+ }
+ final StringBuilder builder = new StringBuilder();
+ encode(builder, strings);
+ return builder.toString();
+ }
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Wed Sep 3 11:21:14 2014
@@ -159,9 +159,10 @@ public class SheetRenderer extends Layou
final UIReload update = (UIReload) facetReload;
writer.writeAttribute(DataAttributes.RELOAD, update.getFrequency());
}
-
- writer.writeAttribute(DataAttributes.PARTIALLY,
- HtmlRendererUtils.getRenderedPartiallyJavascriptArray(facesContext, sheet, sheet), false);
+ final String[] clientIds = ComponentUtils.evaluateClientIds(facesContext, sheet, sheet.getRenderedPartially());
+ if (clientIds.length > 0) {
+ writer.writeAttribute(DataAttributes.PARTIALLY, JsonUtils.encode(clientIds), true);
+ }
writer.writeAttribute(DataAttributes.SELECTION_MODE, sheet.getSelectable(), false);
writer.writeAttribute(DataAttributes.FIRST, Integer.toString(sheet.getFirst()), false);
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java Wed Sep 3 11:21:14 2014
@@ -21,18 +21,14 @@ package org.apache.myfaces.tobago.render
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.SupportsMarkup;
-import org.apache.myfaces.tobago.component.SupportsRenderedPartially;
import org.apache.myfaces.tobago.component.UIColumnEvent;
import org.apache.myfaces.tobago.component.UICommand;
import org.apache.myfaces.tobago.component.UIForm;
-import org.apache.myfaces.tobago.component.UIPage;
import org.apache.myfaces.tobago.component.UISheet;
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
-import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
-import org.apache.myfaces.tobago.internal.util.StringUtils;
import org.apache.myfaces.tobago.internal.webapp.TobagoResponseWriterWrapper;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -54,15 +50,12 @@ import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
-import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.model.SelectItem;
import javax.faces.model.SelectItemGroup;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -76,22 +69,6 @@ public final class HtmlRendererUtils {
// to prevent instantiation
}
- /** @deprecated since 2.0.0, because of CSP */
- private static boolean renderErrorFocusId(final FacesContext facesContext, final UIInput input) throws IOException {
- if (ComponentUtils.isError(input)) {
- if (!FacesContext.getCurrentInstance().getExternalContext().getRequestMap().containsKey(ERROR_FOCUS_KEY)) {
- FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(ERROR_FOCUS_KEY, Boolean.TRUE);
- final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- final String id = input.getClientId(facesContext);
- writer.writeJavascript("Tobago.errorFocusId = '" + id + "';");
- return true;
- } else {
- return true;
- }
- }
- return FacesContext.getCurrentInstance().getExternalContext().getRequestMap().containsKey(ERROR_FOCUS_KEY);
- }
-
public static void renderFocus(
final String clientId, final boolean focus, final boolean error, final FacesContext facesContext,
final TobagoResponseWriter writer) throws IOException {
@@ -103,41 +80,6 @@ public final class HtmlRendererUtils {
}
}
- /** @deprecated since 2.0.0, because of CSP */
- public static void renderFocusId(final FacesContext facesContext, final UIComponent component)
- throws IOException {
- if (component instanceof UIInput) {
- renderFocusId(facesContext, (UIInput) component);
- }
- }
-
- /** @deprecated since 2.0.0, because of CSP */
- public static void renderFocusId(final FacesContext facesContext, final UIInput component)
- throws IOException {
- if (renderErrorFocusId(facesContext, component)) {
- return;
- }
- if (ComponentUtils.getBooleanAttribute(component, Attributes.FOCUS)) {
- final UIPage page = (UIPage) ComponentUtils.findPage(facesContext, component);
- final String id = component.getClientId(facesContext);
- if (!StringUtils.isBlank(page.getFocusId()) && !page.getFocusId().equals(id)) {
- LOG.warn("page focusId='" + page.getFocusId() + "' ignoring new value '" + id + "'");
- } else {
- final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- writer.writeJavascript("Tobago.focusId='" + id + "';");
- }
- }
- }
-
- /**
- * @deprecated Since Tobago 2.0.0
- */
- @Deprecated
- public static void createCssClass(final FacesContext facesContext, final UIComponent component) {
- final String rendererName = getRendererName(facesContext, component);
- Deprecation.LOG.error("Can't render style class for renderer " + rendererName);
- }
-
public static String getRendererName(final FacesContext facesContext, final UIComponent component) {
final String rendererType = component.getRendererType();
return rendererType.substring(0, 1).toLowerCase(Locale.ENGLISH) + rendererType.substring(1);
@@ -161,107 +103,6 @@ public final class HtmlRendererUtils {
}
}
- /** @deprecated since 1.5.7 and 2.0.0 */
- @Deprecated
- public static void setDefaultTransition(final FacesContext facesContext, final boolean transition)
- throws IOException {
- writeScriptLoader(facesContext, null, new String[]{"Tobago.transition = " + transition + ";"});
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static void addClickAcceleratorKey(
- final FacesContext facesContext, final String clientId, final char key)
- throws IOException {
- //addClickAcceleratorKey(facesContext, clientId, key, null);
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static void addClickAcceleratorKey(
- final FacesContext facesContext, final String clientId, final char key, final String modifier)
- throws IOException {
- //String str
- // = createOnclickAcceleratorKeyJsStatement(clientId, key, modifier);
- //writeScriptLoader(facesContext, null, new String[]{str});
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static void addAcceleratorKey(
- final FacesContext facesContext, final String func, final char key) throws IOException {
- //addAcceleratorKey(facesContext, func, key, null);
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static void addAcceleratorKey(
- final FacesContext facesContext, final String func, final char key, final String modifier)
- throws IOException {
- final String str = createAcceleratorKeyJsStatement(func, key, modifier);
- writeScriptLoader(facesContext, null, new String[]{str});
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static String createOnclickAcceleratorKeyJsStatement(
- final String clientId, final char key, final String modifier) {
- final String func = "Tobago.clickOnElement('" + clientId + "');";
- return createAcceleratorKeyJsStatement(func, key, modifier);
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static String createAcceleratorKeyJsStatement(
- final String func, final char key, final String modifier) {
- final StringBuilder buffer = new StringBuilder("new Tobago.AcceleratorKey(function() {");
- buffer.append(func);
- if (!func.endsWith(";")) {
- buffer.append(';');
- }
- buffer.append("}, \"");
- buffer.append(key);
- if (modifier != null) {
- buffer.append("\", \"");
- buffer.append(modifier);
- }
- buffer.append("\");");
- return buffer.toString();
- }
-
- /**
- * @deprecated since 2.0.0. Please use setter.
- */
- @Deprecated
- public static void removeStyleAttribute(final UIComponent component, final String name) {
- Deprecation.LOG.error("HtmlRendererUtils.removeStyleAttribute() no longer supported. Use setter.");
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static void createHeaderAndBodyStyles(final FacesContext facesContext, final UIComponent component) {
- Deprecation.LOG.error("HtmlRendererUtils.createHeaderAndBodyStyles() no longer supported");
- }
-
- /** @deprecated since 2.0.0 */
- @Deprecated
- public static void createHeaderAndBodyStyles(
- final FacesContext facesContext, final UIComponent component, final boolean width) {
- Deprecation.LOG.error("HtmlRendererUtils.createHeaderAndBodyStyles() no longer supported");
- }
-
- /** @deprecated since 2.0.3 */
- @Deprecated
- public static String createSrc(final String src, final String ext) {
- final int dot = src.lastIndexOf('.');
- if (dot == -1) {
- LOG.warn("Image src without extension: '" + src + "'");
- return src;
- } else {
- return src.substring(0, dot) + ext + src.substring(dot);
- }
- }
-
public static TobagoResponseWriter getTobagoResponseWriter(final FacesContext facesContext) {
final ResponseWriter writer = facesContext.getResponseWriter();
@@ -272,86 +113,6 @@ public final class HtmlRendererUtils {
}
}
- /**
- * @deprecated Since Tobago 2.0.0. Because of CSP.
- */
- @Deprecated
- public static void writeScriptLoader(final FacesContext facesContext, final String script)
- throws IOException {
- writeScriptLoader(facesContext, new String[]{script}, null);
- }
-
- /**
- * @deprecated Since Tobago 2.0.0. Because of CSP.
- */
- @Deprecated
- public static void writeScriptLoader(
- final FacesContext facesContext, final String[] scripts, final String[] afterLoadCmds)
- throws IOException {
- final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- if (scripts != null) {
- LOG.error("Scripts argument for writeScriptLoader not supported anymore!");
- }
- String allScripts = "[]";
- if (scripts != null) {
- allScripts = ResourceManagerUtils.getScriptsAsJSArray(facesContext, scripts);
- }
- final boolean ajax = FacesContextUtils.isAjax(facesContext);
- writer.startJavascript();
- // XXX fix me if scripts != null
- if (ajax || scripts != null) {
- writer.write("new Tobago.ScriptLoader(");
- if (!ajax) {
- writer.write("\n ");
- }
- writer.write(allScripts);
-
- if (afterLoadCmds != null && afterLoadCmds.length > 0) {
- writer.write(", ");
- if (!ajax) {
- writer.write("\n");
- }
- boolean first = true;
- for (final String afterLoadCmd : afterLoadCmds) {
- final String[] splittedStrings = StringUtils.split(afterLoadCmd, '\n'); // split on <CR> to have nicer JS
- for (final String splitted : splittedStrings) {
- writer.write(first ? " " : " + ");
- writer.write("\"");
- String cmd = StringUtils.replace(splitted, "\\", "\\\\");
- cmd = StringUtils.replace(cmd, "\"", "\\\"");
- writer.write(cmd);
- writer.write("\"");
- if (!ajax) {
- writer.write("\n");
- }
- first = false;
- }
- }
- }
- writer.write(");");
- } else {
- for (final String afterLoadCmd : afterLoadCmds) {
- writer.write(afterLoadCmd);
- }
- }
- writer.endJavascript();
- }
-
- /**
- * @deprecated Since Tobago 2.0.0. Because of CSP.
- */
- @Deprecated
- public static void writeStyleLoader(
- final FacesContext facesContext, final String[] styles) throws IOException {
- final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-
- writer.startJavascript();
- writer.write("Tobago.ensureStyleFiles(");
- writer.write(ResourceManagerUtils.getStylesAsJSArray(facesContext, styles));
- writer.write(");");
- writer.endJavascript();
- }
-
public static String getTitleFromTipAndMessages(final FacesContext facesContext, final UIComponent component) {
final String messages = ComponentUtils.getFacesMessageAsString(facesContext, component);
return HtmlRendererUtils.addTip(messages, component.getAttributes().get(Attributes.TIP));
@@ -440,196 +201,6 @@ public final class HtmlRendererUtils {
}
}
- public static String getComponentIds(
- final FacesContext context, final UIComponent component, final String[] componentId) {
- final StringBuilder sb = new StringBuilder();
- for (final String id : componentId) {
- if (!StringUtils.isBlank(id)) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- final String clientId = getComponentId(context, component, id);
- if (clientId != null) {
- sb.append(clientId);
- }
- }
- }
- return sb.toString();
- }
-
- public static String[] getComponentIdsAsList(
- final FacesContext context, final UIComponent component, final String[] componentId) {
- final List<String> result = new ArrayList<String>(componentId.length);
- for (final String id : componentId) {
- if (!StringUtils.isBlank(id)) {
- final String clientId = getComponentId(context, component, id);
- if (clientId != null) {
- result.add(clientId);
- }
- }
- }
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- public static String getComponentId(
- final FacesContext context, final UIComponent component, final String componentId) {
- final UIComponent partiallyComponent = ComponentUtils.findComponent(component, componentId);
- if (partiallyComponent != null) {
- final String clientId = partiallyComponent.getClientId(context);
- if (partiallyComponent instanceof UISheet) {
- final int rowIndex = ((UISheet) partiallyComponent).getRowIndex();
- if (rowIndex >= 0 && clientId.endsWith(Integer.toString(rowIndex))) {
- return clientId.substring(0, clientId.lastIndexOf(UINamingContainer.getSeparatorChar(context)));
- }
- }
- return clientId;
- }
- LOG.error("No component found for id='" + componentId + "', "
- + "search base component is '" + component.getClientId(context) + "'");
- return null;
- }
-
- public static String getJavascriptString(final String str) {
- if (str != null) {
- return "\"" + str + "\"";
- }
- return null;
- }
-
- public static String getRenderedPartiallyJavascriptArray(final FacesContext facesContext, final UICommand command) {
- if (command == null) {
- return null;
- }
- return getRenderedPartiallyJavascriptArray(facesContext, command, command);
- }
-
- public static String getRenderedPartiallyJavascriptArray(
- final FacesContext facesContext, final UIComponent searchBase,
- final SupportsRenderedPartially supportsRenderedPartially) {
- final String[] list = supportsRenderedPartially.getRenderedPartially();
- if (list == null || list.length == 0) {
- return null;
- }
- final StringBuilder strBuilder = new StringBuilder();
- strBuilder.append("[");
- for (int i = 0; i < list.length; i++) {
- if (i != 0) {
- strBuilder.append(",");
- }
- strBuilder.append("\"");
- strBuilder.append(HtmlRendererUtils.getComponentId(facesContext, searchBase, list[i]));
- strBuilder.append("\"");
- }
- strBuilder.append("]");
- return strBuilder.toString();
- }
-
- public static String getJavascriptArray(final String[] list) {
- final StringBuilder strBuilder = new StringBuilder();
- strBuilder.append("[");
- for (int i = 0; i < list.length; i++) {
- if (i != 0) {
- strBuilder.append(",");
- }
- strBuilder.append("\"");
- strBuilder.append(list[i]);
- strBuilder.append("\"");
- }
- strBuilder.append("]");
- return strBuilder.toString();
- }
-
- /**
- * will be removed in later versions
- * @deprecated since 2.0.0
- */
- @Deprecated
- public static void renderDojoDndSource(final FacesContext context, final UIComponent component)
- throws IOException {
- final Object objDojoType = component.getAttributes().get("dojoType");
- if (null != objDojoType && (objDojoType.equals("dojo.dnd.Source") || objDojoType.equals("dojo.dnd.Target"))) {
- FacesContextUtils.addOnloadScript(context, createDojoDndType(component,
- component.getClientId(context), String.valueOf(objDojoType)));
- }
- }
-
- /**
- * will be removed in later versions
- * @deprecated since 2.0.0
- */
- @Deprecated
- public static void renderDojoDndItem(
- final UIComponent component, final TobagoResponseWriter writer, final boolean addStyle)
- throws IOException {
- final Object objDndType = component.getAttributes().get("dndType");
- if (objDndType != null) {
- writer.writeAttribute("dndType", String.valueOf(objDndType), false);
- }
- final Object objDndData = component.getAttributes().get("dndData");
- if (objDndData != null) {
- writer.writeAttribute("dndData", String.valueOf(objDndData), false);
- }
- }
-
- /**
- * will be removed in later versions
- * @deprecated since 2.0.0
- */
- @Deprecated
- public static String createDojoDndType(final UIComponent component, final String clientId, final String dojoType) {
- final StringBuilder strBuilder = new StringBuilder();
- strBuilder.append("new ").append(dojoType).append("('").append(clientId).append("'");
- final StringBuilder parameter = new StringBuilder();
-
- final Object objHorizontal = component.getAttributes().get("horizontal");
- if (objHorizontal != null) {
- parameter.append("horizontal: ").append(String.valueOf(objHorizontal)).append(",");
- }
- final Object objCopyOnly = component.getAttributes().get("copyOnly");
- if (objCopyOnly != null) {
- parameter.append("copyOnly: ").append(String.valueOf(objCopyOnly)).append(",");
- }
- final Object objSkipForm = component.getAttributes().get("skipForm");
- if (objSkipForm != null) {
- parameter.append("skipForm: ").append(String.valueOf(objSkipForm)).append(",");
- }
- final Object objWithHandles = component.getAttributes().get("withHandles");
- if (objWithHandles != null) {
- parameter.append("withHandles: ").append(String.valueOf(objWithHandles)).append(",");
- }
- final Object objAccept = component.getAttributes().get("accept");
- if (objAccept != null) {
- String accept = null;
- if (objAccept instanceof String[]) {
- final String[] allowed = (String[]) objAccept;
- if (allowed.length > 1) {
- // TODO replace this
- accept = "'" + allowed[0] + "'";
- for (int i = 1; i < allowed.length; i++) {
- accept += ",'" + allowed[i] + "'";
- }
- }
- } else {
- accept = (String) objAccept;
- }
- parameter.append("accept: [").append(accept).append("],");
- }
- final Object objSingular = component.getAttributes().get("singular");
- if (objSingular != null) {
- parameter.append("singular: ").append(String.valueOf(objSingular)).append(",");
- }
- final Object objCreator = component.getAttributes().get("creator");
- if (objCreator != null) {
- parameter.append("creator: ").append(String.valueOf(objCreator)).append(",");
- }
- if (parameter.length() > 0) {
- parameter.deleteCharAt(parameter.lastIndexOf(","));
- strBuilder.append(",{").append(parameter).append("}");
- }
- strBuilder.append(");");
- return strBuilder.toString();
- }
-
public static void renderCommandFacet(final UIComponent component, final FacesContext facesContext,
final TobagoResponseWriter writer) throws IOException {
renderCommandFacet(component, component.getClientId(facesContext), facesContext, writer);
@@ -685,121 +256,6 @@ public final class HtmlRendererUtils {
return false;
}
-
- public static void checkForCommandFacet(
- final UIComponent component, final FacesContext facesContext, final TobagoResponseWriter writer)
- throws IOException {
- checkForCommandFacet(component, Arrays.asList(component.getClientId(facesContext)), facesContext, writer);
- }
-
- public static void checkForCommandFacet(
- final UIComponent component, final List<String> clientIds, final FacesContext facesContext,
- final TobagoResponseWriter writer) throws IOException {
- if (ComponentUtils.getBooleanAttribute(component, Attributes.READONLY)
- || ComponentUtils.getBooleanAttribute(component, Attributes.DISABLED)) {
- return;
- }
- final Map<String, UIComponent> facets = component.getFacets();
- for (final Map.Entry<String, UIComponent> entry : facets.entrySet()) {
- if (entry.getValue() instanceof UICommand) {
- addCommandFacet(clientIds, entry, facesContext, writer);
- }
- }
- }
-
- private static void addCommandFacet(
- final List<String> clientIds, final Map.Entry<String, UIComponent> facetEntry,
- final FacesContext facesContext, final TobagoResponseWriter writer)
- throws IOException {
- for (final String clientId : clientIds) {
- writeScriptForClientId(clientId, facetEntry, facesContext, writer);
- }
- }
-
- /**
- * @deprecated Since Tobago 2.0.0. Because of CSP.
- */
- @Deprecated
- private static void writeScriptForClientId(
- final String clientId, final Map.Entry<String, UIComponent> facetEntry,
- final FacesContext facesContext, final TobagoResponseWriter writer) throws IOException {
- if (facetEntry.getValue() instanceof UICommand
- && ((UICommand) facetEntry.getValue()).getRenderedPartially().length > 0) {
- writer.startJavascript();
- writer.write("var element = Tobago.element(\"");
- writer.write(clientId);
- writer.write("\");\n");
- writer.write("if (element) {\n");
- writer.write(" Tobago.addEventListener(element, \"");
- writer.write(facetEntry.getKey());
- writer.write("\", function(){Tobago.reloadComponent(this, '");
- writer.write(HtmlRendererUtils.getComponentIds(facesContext, facetEntry.getValue(),
- ((UICommand) facetEntry.getValue()).getRenderedPartially()));
- writer.write("','");
- writer.write(facetEntry.getValue().getClientId(facesContext));
- writer.write("', {})});\n");
- writer.write("};");
- writer.endJavascript();
- } else {
- final UIComponent facetComponent = facetEntry.getValue();
-
- writer.startJavascript();
- writer.write("var element = Tobago.element(\"");
- writer.write(clientId + "\");\n");
- writer.write("if (element) {\n");
- writer.write(" Tobago.addEventListener(element, \"");
- writer.write(facetEntry.getKey());
- writer.write("\", function(){");
- String facetAction = (String) facetComponent.getAttributes().get(Attributes.ONCLICK);
- if (facetAction != null) {
- // Replace @autoId
- facetAction = StringUtils.replace(facetAction, "@autoId", facetComponent.getClientId(facesContext));
- writer.write(facetAction);
- } else {
- writer.write(createSubmitAction(
- facetComponent.getClientId(facesContext),
- ComponentUtils.getBooleanAttribute(facetComponent, Attributes.TRANSITION),
- null,
- clientId));
- }
- writer.write("});\n};");
- writer.endJavascript();
- }
- }
-
- /**
- * @deprecated since 2.0.0. JavaScript should not be rendered in the page. See CSP.
- */
- @Deprecated
- public static String createSubmitAction(
- final String clientId, final boolean transition, final String target, final String focus) {
- final StringBuilder builder = new StringBuilder();
- builder.append("Tobago.submitAction(this,'");
- builder.append(clientId);
- builder.append("',{");
- if (!transition) { // transition == true is the default
- builder.append("transition:false");
- if (target != null || focus != null) {
- builder.append(',');
- }
- }
- if (target != null) {
- builder.append("target:'");
- builder.append(target);
- builder.append('\'');
- if (focus != null) {
- builder.append(',');
- }
- }
- if (focus != null) {
- builder.append("focus:'");
- builder.append(focus);
- builder.append('\'');
- }
- builder.append("});");
- return builder.toString();
- }
-
public static void encodeContextMenu(
final FacesContext facesContext, final TobagoResponseWriter writer, final UIComponent parent)
throws IOException {
@@ -812,13 +268,6 @@ public final class HtmlRendererUtils {
}
}
- public static void addAcceleratorKey(
- final FacesContext facesContext, final UIComponent component, final Character accessKey) {
- final String clientId = component.getClientId(facesContext);
- final String jsStatement = createOnclickAcceleratorKeyJsStatement(clientId, accessKey, null);
- FacesContextUtils.addMenuAcceleratorScript(facesContext, jsStatement);
- }
-
public static void writeDataAttributes(
final FacesContext context, final TobagoResponseWriter writer, final UIComponent component)
throws IOException {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1622223&r1=1622222&r2=1622223&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Wed Sep 3 11:21:14 2014
@@ -27,8 +27,9 @@ Tobago.Sheets = {
}
};
-Tobago.Sheet = function(sheetId, unused1, unused2, unused3, unused4,
- clickActionId, clickReloadComponentId, dblClickActionId, dblClickReloadComponentId, renderedPartially) {
+Tobago.Sheet = function(
+ sheetId, unused1, unused2, unused3, unused4,
+ clickActionId, clickReloadComponentId, dblClickActionId, dblClickReloadComponentId, renderedPartially) {
console.debug("New Sheet with id " + sheetId); // @DEV_ONLY
console.time("[tobago-sheet] constructor"); // @DEV_ONLY
this.id = sheetId;
@@ -70,8 +71,7 @@ Tobago.Sheet.init = function(elements) {
click != undefined ? click.partially : undefined,
dblclick != undefined ? dblclick.action : undefined,
dblclick != undefined ? dblclick.partially: undefined,
- // todo: use sheet.data("data-tobago-partially"). What is the type? Array? Test it.
- sheet.attr("data-tobago-partially"));
+ sheet.data("tobago-partially")); // type array
});
Tobago.Sheet.setup2(sheets);
Propchange: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js:r1621332