Author: Alex.Kolonitsky
Date: 2009-02-23 11:08:24 -0500 (Mon, 23 Feb 2009)
New Revision: 12714
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JCommandTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/Bean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/NavigateBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ObjectNotFoundException.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
trunk/ui/componentControl/src/main/config/component/componentControl.xml
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
trunk/ui/componentControl/src/main/java/org/richfaces/renderkit/ComponentControlRendererBase.java
Log:
set default value for disableDefault attribute true if event="onContextMenu" in
componentControl
https://jira.jboss.org/jira/browse/RF-6275
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JCommandTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JCommandTestBean.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JCommandTestBean.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -20,7 +20,6 @@
*/
package org.ajax4jsf.bean;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/Bean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/Bean.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/Bean.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -20,7 +20,6 @@
*/
package org.ajax4jsf.bean;
-import java.text.DateFormat;
import java.util.Date;
import javax.faces.application.FacesMessage;
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarDataModel.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -22,8 +22,6 @@
import java.util.Calendar;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
import org.richfaces.model.CalendarDataModelItem;
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/NavigateBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/NavigateBean.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/NavigateBean.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -25,9 +25,11 @@
import org.ajax4jsf.component.UIInclude;
public class NavigateBean implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String viewId="/pages/hello.jsp";
- private String viewId="/pages/hello.jsp";
-
transient private UIInclude include;
public String navigateOne() {
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ObjectNotFoundException.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ObjectNotFoundException.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ObjectNotFoundException.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -26,4 +26,6 @@
*/
public class ObjectNotFoundException extends Exception {
+ private static final long serialVersionUID = -7631465346193651806L;
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -25,7 +25,6 @@
import java.util.Map;
import javax.faces.application.FacesMessage;
-import javax.faces.application.FacesMessage.Severity;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -41,8 +41,6 @@
private String nodeTitle;
- private static final String DATA_PATH = "/simple-tree-data.properties";
-
private TreeNode<Object> richRootNode = null;
public synchronized TreeNode<Object> getRichTreeNode() {
Modified: trunk/ui/componentControl/src/main/config/component/componentControl.xml
===================================================================
--- trunk/ui/componentControl/src/main/config/component/componentControl.xml 2009-02-23
15:07:20 UTC (rev 12713)
+++ trunk/ui/componentControl/src/main/config/component/componentControl.xml 2009-02-23
16:08:24 UTC (rev 12714)
@@ -31,12 +31,13 @@
</taghandler>
-->
&ui_component_attributes;
- <property>
+ <property >
<name>disableDefault</name>
<classname>boolean</classname>
<description>
Disable default action for target event ( append "return false;" to
JavaScript )
</description>
+
<defaultvalue><![CDATA[getEvent().equalsIgnoreCase("onContextMenu")]]></defaultvalue>
</property>
<property>
<name>event</name>
Modified:
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
===================================================================
---
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -21,9 +21,9 @@
package org.richfaces.component;
-import java.util.Iterator;
-
+import javax.el.ELException;
import javax.el.ValueExpression;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIParameter;
@@ -42,149 +42,199 @@
/**
* JSF component class
- *
+ *
*/
-public abstract class UIComponentControl extends UIComponentBase implements AjaxSupport
{
+public abstract class UIComponentControl extends UIComponentBase implements
+ AjaxSupport {
+
+ public static final String COMPONENT_TYPE =
"org.richfaces.ComponentControl";
+
+ public static final String COMPONENT_FAMILY =
"org.richfaces.ComponentControl";
+
+ private static final Log log = LogFactory.getLog(UIComponentControl.class);
+
+ /*
+ * Disable default action for target event ( append "return false;" to
+ * JavaScript )
+ */
+ public static final String DISABLE_DEFAULT = "disableDefault";
- public static final String COMPONENT_TYPE = "org.richfaces.ComponentControl";
+ private boolean disableDefault = false;
+
+ private boolean disableDefaultSet = false;
+
+ public static final String ON_CONTEXT_MENU = "onContextMenu";
- public static final String COMPONENT_FAMILY =
"org.richfaces.ComponentControl";
- private static final Log log = LogFactory.getLog(UIComponentControl.class);
+ /**
+ * @return JavaScript eventString. Rebuild on every call, since can be in
+ * loop ( as in dataTable ) with different parameters.
+ */
+ public String getEventString() {
+ String targetId = HtmlUtil.idsToIdSelector(getFor());
+
+ targetId = HtmlUtil.expandIdSelector(targetId, this, FacesContext
+ .getCurrentInstance());
+
+ JSFunction invocation = new
JSFunction("Richfaces.componentControl.performOperation");
+ invocation.addParameter(new JSReference("event"));
+ invocation.addParameter(targetId);
+ invocation.addParameter(getOperation());
+ invocation.addParameter(new JSReference("{" + getEncodedParametersMap()
+ "}"));
+ invocation.addParameter(Boolean.valueOf(isDisableDefault()));
+
+ return invocation.toScript();
+ }
+
+ public String getEncodedParametersMap() {
+ StringBuilder result = new StringBuilder();
+
+ boolean shouldClose = false;
+
+ String params = this.getParams();
+ if (params != null && params.trim().length() != 0) {
+ result.append(params);
+ shouldClose = true;
+ }
+
+ for (UIComponent child : this.getChildren()) {
+ if (!(child instanceof UIParameter)) {
+ continue;
+ }
+
+ String name = ((UIParameter) child).getName();
+ Object value = ((UIParameter) child).getValue();
+ if (null == name) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.UNNAMED_PARAMETER_ERROR, this
+ .getClientId(context)));
+ }
+
+ boolean escape = true;
+ if (child instanceof JavaScriptParameter) {
+ JavaScriptParameter actionParam = (JavaScriptParameter) child;
+ escape = !actionParam.isNoEscape();
+ }
+
+ if (shouldClose) {
+ result.append(", ");
+ }
+
+ ScriptUtils.addEncodedString(result, name);
+ result.append(": ");
+ result.append(ScriptUtils.toScript(escape ? value
+ : new JSReference(value.toString())));
+
+ shouldClose = true;
+ }
+
+ return result.toString();
+ }
+
+ public abstract String getEvent();
+
+ public abstract void setEvent(String event);
+
+ public abstract String getFor();
+
+ public abstract void setFor(String value);
+
+ public abstract String getParams();
+
+ public abstract void setParams(String value);
+
+ public abstract String getOperation();
+
+ public abstract void setOperation(String value);
+
+ public abstract String getAttachTo();
+
+ public abstract void setAttachTo(String value);
+
+ protected String replaceClientIds(FacesContext context,
+ UIComponent component, String selector) {
+ return HtmlUtil.expandIdSelector(selector, component, context);
+ }
+
+ /**
+ * After nornal setting <code>parent</code> property in case of created
+ * component set Ajax properties for parent.
+ *
+ * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
+ */
+ public void setParent(UIComponent parent) {
+ super.setParent(parent);
+ if (parent != null && parent.getFamily() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
+ parent.getClass().getName()));
+ }
+
+ // TODO If this comopnent configured, set properties for parent
+ // component.
+ // NEW created component have parent, restored view - null in My
+ // faces.
+ // and SUN RI not call at restore saved view.
+ // In other case - set in restoreState method.
+ // if (parent.getParent() != null)
+ if (log.isDebugEnabled()) {
+ log.debug(Messages
+ .getMessage(Messages.DETECT_NEW_COMPONENT));
+ }
+ setParentProperties(parent);
+ }
+ }
+
+ public void setParentProperties(UIComponent parent) {
+ String event = getEvent();
+ if (event == null || event.length() == 0) {
+ return;
+ }
+
+ String attachTo = getAttachTo();
+ if (attachTo == null || attachTo.length() == 0) {
+ parent.setValueExpression(event, new EventValueExpression(this));
+ } else {
+ ValueExpression vb = parent.getValueExpression(event);
+ if (vb instanceof EventValueExpression) {
-
- /**
- * @return JavaScript eventString. Rebuild on every call, since
- * can be in loop ( as in dataTable ) with different parameters.
- */
- public String getEventString() {
- String targetId = HtmlUtil.idsToIdSelector(getFor());
-
- targetId = HtmlUtil.expandIdSelector(targetId, this,
FacesContext.getCurrentInstance());
-
- JSFunction invocation = new
JSFunction("Richfaces.componentControl.performOperation");
- invocation.addParameter(new JSReference("event"));
- invocation.addParameter(targetId);
- invocation.addParameter(getOperation());
- invocation.addParameter(new JSReference("{" + getEncodedParametersMap() +
"}"));
- invocation.addParameter(Boolean.valueOf(isDisableDefault()));
-
- return invocation.toScript();
- }
-
- public String getEncodedParametersMap() {
- StringBuilder result = new StringBuilder();
-
- boolean shouldClose = false;
-
- String params = this.getParams();
- if (params != null && params.trim().length() != 0) {
- result.append(params);
- shouldClose = true;
- }
-
- for (Iterator<UIComponent> it = this.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- if (child instanceof UIParameter) {
- String name = ((UIParameter) child).getName();
- Object value = ((UIParameter) child).getValue();
- if (null == name) {
- FacesContext context = FacesContext.getCurrentInstance();
- throw new IllegalArgumentException(Messages.getMessage(
- Messages.UNNAMED_PARAMETER_ERROR, this
- .getClientId(context)));
- }
-
- boolean escape = true;
- if (child instanceof JavaScriptParameter) {
- JavaScriptParameter actionParam = (JavaScriptParameter) child;
- escape = !actionParam.isNoEscape();
- }
-
- if (shouldClose) {
- result.append(", ");
- }
-
- ScriptUtils.addEncodedString(result, name);
- result.append(": ");
- result.append(ScriptUtils.toScript(escape ? value : new
JSReference(value.toString())));
-
- shouldClose = true;
- }
- }
-
- return result.toString();
- }
-
- public abstract String getEvent();
- public abstract void setEvent(String event);
-
- public abstract String getFor();
- public abstract void setFor(String value);
-
- public abstract String getParams();
- public abstract void setParams(String value);
-
- public abstract String getOperation();
- public abstract void setOperation(String value);
-
- public abstract String getAttachTo();
- public abstract void setAttachTo(String value);
-
- protected String replaceClientIds(FacesContext context, UIComponent component, String
selector) {
- return HtmlUtil.expandIdSelector(selector, component, context);
- }
-
-
- /**
- * After nornal setting <code>parent</code> property in case of
- * created component set Ajax properties for parent.
- * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
- */
- public void setParent(UIComponent parent)
- {
- super.setParent(parent);
- if (null != parent && parent.getFamily() != null ) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
parent.getClass().getName()));
- }
- // TODO If this comopnent configured, set properties for parent component.
- // NEW created component have parent, restored view - null in My faces.
- // and SUN RI not call at restore saved view.
- // In other case - set in restoreState method.
- // if (parent.getParent() != null)
- {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
- }
- setParentProperties(parent);
-
- }
- }
- }
-
-
- public void setParentProperties(UIComponent parent){
- String event = getEvent();
- String attachTo = getAttachTo();
-
- if (event != null && event.length() != 0) {
- if (attachTo == null || attachTo.length() == 0) {
- parent.setValueExpression(event, new EventValueExpression(this));
- } else {
- ValueExpression vb = parent.getValueExpression(event);
- if (vb instanceof EventValueExpression) {
- //TODO check if that's EventValueBinding for us
- parent.setValueExpression(event, null);
- }
- }
- }
- }
-
- public abstract void setName(String name);
- public abstract String getName();
-
- public abstract void setAttachTiming( String attachTiming);
- public abstract String getAttachTiming();
-
+ // TODO check if that's EventValueBinding for us
+ parent.setValueExpression(event, null);
+ }
+ }
+ }
+
+ public abstract void setName(String name);
+
+ public abstract String getName();
+
+ public abstract void setAttachTiming(String attachTiming);
+
+ public abstract String getAttachTiming();
+
+ public boolean isDisableDefault() {
+ if (this.disableDefaultSet) {
+ return getEvent().equalsIgnoreCase(ON_CONTEXT_MENU);
+ }
+
+ ValueExpression ve = getValueExpression(DISABLE_DEFAULT);
+ if (ve != null) {
+ try {
+ Boolean value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ if (value != null) {
+ return value;
+ }
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ return this.disableDefault;
+ }
+
+ public void setDisableDefault(boolean disableDefault) {
+ this.disableDefault = disableDefault;
+ this.disableDefaultSet = true;
+ }
}
Modified:
trunk/ui/componentControl/src/main/java/org/richfaces/renderkit/ComponentControlRendererBase.java
===================================================================
---
trunk/ui/componentControl/src/main/java/org/richfaces/renderkit/ComponentControlRendererBase.java 2009-02-23
15:07:20 UTC (rev 12713)
+++
trunk/ui/componentControl/src/main/java/org/richfaces/renderkit/ComponentControlRendererBase.java 2009-02-23
16:08:24 UTC (rev 12714)
@@ -122,7 +122,7 @@
writer.writeText("//", null);
writer.write("<![CDATA[");
- String attachEventBodyStart =
"\n{\n Richfaces.componentControl.attachEvent('";
+ String attachEventBodyStart = "\n{\n
Richfaces.componentControl.attachEvent('";
StringBuilder attachEventBodyEnd = new StringBuilder();
attachEventBodyEnd.append("', '");
attachEventBodyEnd.append(convertToString(variables.getVariable("event")));