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 2017/01/26 10:13:21 UTC
svn commit: r1780346 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/
tobago-example/tobago-example-demo/src/main/webapp/cont...
Author: lofwyr
Date: Thu Jan 26 10:13:20 2017
New Revision: 1780346
URL: http://svn.apache.org/viewvc?rev=1780346&view=rev
Log:
TOBAGO-1671: Implement rendered attribute for <tc:event>
TOBAGO-1672: Implement disabled attribute for <f:ajax>
[developed by sub_ft1]
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RenderUtils.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/60000-manual/4000-button+link/button+link.xhtml
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java?rev=1780346&r1=1780345&r2=1780346&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java Thu Jan 26 10:13:20 2017
@@ -49,6 +49,11 @@ public class TobagoClientBehaviorRendere
private static final Logger LOG = LoggerFactory.getLogger(TobagoClientBehaviorRenderer.class);
+ /**
+ * In standard JSF this method returns a JavaScript string. Because of CSP, Tobago doesn't render JavaScript
+ * into the HTML content. It transports the return value a bit hacky by {@link CommandMap#storeCommandMap}.
+ * @return "dummy" string or null, if nothing to do.
+ */
@Override
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior) {
@@ -67,6 +72,9 @@ public class TobagoClientBehaviorRendere
boolean omit = false;
if (behavior instanceof AjaxBehavior) {
AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
+ if (ajaxBehavior.isDisabled()){
+ return null;
+ }
final Collection<String> execute = ajaxBehavior.getExecute();
final Collection<String> render = ajaxBehavior.getRender();
final String clientId = uiComponent.getClientId(facesContext);
@@ -89,6 +97,9 @@ public class TobagoClientBehaviorRendere
actionId = clientId;
} else if (behavior instanceof EventBehavior) { // <tc:event>
AbstractUIEvent event = findEvent(uiComponent, eventName);
+ if (event != null && !event.isRendered()){
+ return null;
+ }
transition = event.isTransition();
target = event.getTarget();
actionId = event.getClientId(facesContext);
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RenderUtils.java?rev=1780346&r1=1780345&r2=1780346&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RenderUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/RenderUtils.java Thu Jan 26 10:13:20 2017
@@ -261,7 +261,9 @@ public final class RenderUtils {
final String type = ((ClientBehaviorBase) clientBehavior).getRendererType();
final ClientBehaviorRenderer renderer = facesContext.getRenderKit().getClientBehaviorRenderer(type);
final String dummy = renderer.getScript(context, clientBehavior);
- map = CommandMap.merge(map, CommandMap.restoreCommandMap(facesContext));
+ if (dummy != null) {
+ map = CommandMap.merge(map, CommandMap.restoreCommandMap(facesContext));
+ }
} else {
LOG.warn("Ignoring: '{}'", clientBehavior);
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/60000-manual/4000-button+link/button+link.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/60000-manual/4000-button%2Blink/button%2Blink.xhtml?rev=1780346&r1=1780345&r2=1780346&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/60000-manual/4000-button+link/button+link.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/60000-manual/4000-button+link/button+link.xhtml Thu Jan 26 10:13:20 2017
@@ -70,4 +70,16 @@
</tc:object>
</tc:section>
+ <tc:section label="Event Test">
+ <p>Opens a blank browser tab on click, because rendered attribute is not set in <code><tc:event></code>.</p>
+ <tc:button id="openTab" label="Open in new Tab">
+ <tc:event target="_blank"/>
+ </tc:button>
+ <p>Simple submit on click because rendered attribute is set to false in
+ <code><tc:event rendered="false"></code>.</p>
+ <tc:button id="simpleSubmit" label="Simple Submit">
+ <tc:event target="_blank" rendered="false"/>
+ </tc:button>
+ </tc:section>
+
</ui:composition>