Author: nbelaevski
Date: 2007-12-11 11:22:51 -0500 (Tue, 11 Dec 2007)
New Revision: 4721
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1583
name for focus keepers removed
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-12-11
16:20:22 UTC (rev 4720)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2007-12-11
16:22:51 UTC (rev 4721)
@@ -29,6 +29,7 @@
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.model.DataComponentState;
@@ -286,6 +287,95 @@
}
/**
+ *
+ * <p>Set the "valid" property according to the below
algorithm.</p>
+ *
+ * <ul>
+ *
+ * <li>If the <code>valid</code> property on this component is still
+ * <code>true</code>, and the <code>required</code> property
is also
+ * true, ensure that the local value is not empty (where "empty" is
+ * defined as <code>null</code> or a zero-length String. If the local
+ * value is empty:
+ * <ul>
+ * <li>Enqueue an appropriate error message by calling the
+ * <code>addMessage()</code> method on the
<code>FacesContext</code>
+ * instance for the current request.</li>
+ * <li>Set the <code>valid</code> property on this component to
+ * <code>false</code>.</li>
+ * </ul></li>
+ * <li>If the <code>valid</code> property on this component is still
+ * <code>true</code>, and the local value is not empty, call the
+ * <code>validate()</code> method of each {@link Validator}
+ * registered for this {@link UIInput}, followed by the method
+ * pointed at by the <code>validatorBinding</code> property (if any).
+ * If any of these validators or the method throws a
+ * {@link ValidatorException}, catch the exception, add
+ * its message (if any) to the {@link FacesContext}, and set
+ * the <code>valid</code> property of this component to
false.</li>
+ *
+ * </ul>
+ *
+ */
+ protected void validateValue(FacesContext context, Object newValue) {
+ // If our value is valid, enforce the required property if present
+ if (isValid() && isRequired() && isEmpty(newValue)) {
+ FacesMessage message =
+ MessageFactory.getMessage(context, UIInput.REQUIRED_MESSAGE_ID);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ setValid(false);
+ }
+
+ // If our value is valid and not empty, call all validators
+ if (isValid() && !isEmpty(newValue)) {
+ Validator[] validators = getValidators();
+ for (int i = 0; i < validators.length; i++) {
+ Validator validator = (Validator) validators[i];
+ try {
+ validator.validate(context, this, newValue);
+ }
+ catch (ValidatorException ve) {
+ // If the validator throws an exception, we're
+ // invalid, and we need to add a message
+ setValid(false);
+ FacesMessage message = ve.getFacesMessage();
+ if (message != null) {
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ }
+ }
+ }
+
+ MethodBinding validator = getValidator();
+ if (validator != null) {
+ try {
+ validator.invoke(context,
+ new Object[] { context, this, newValue});
+ }
+ catch (EvaluationException ee) {
+ if (ee.getCause() instanceof ValidatorException) {
+ ValidatorException ve =
+ (ValidatorException) ee.getCause();
+
+ // If the validator throws an exception, we're
+ // invalid, and we need to add a message
+ setValid(false);
+ FacesMessage message = ve.getFacesMessage();
+ if (message != null) {
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(getClientId(context), message);
+ }
+ } else {
+ // Otherwise, rethrow the EvaluationException
+ throw ee;
+ }
+ }
+ }
+ }
+ }
+
+ /**
* <p>In addition to the standard <code>processUpdates</code>
behavior
* inherited from {@link UIComponentBase}, calls
* <code>updateModel()</code>.
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-12-11
16:20:22 UTC (rev 4720)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-12-11
16:22:51 UTC (rev 4721)
@@ -13,7 +13,6 @@
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
-import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIInput;
@@ -546,10 +545,8 @@
previousValue = Collections.EMPTY_LIST;
}
- OrderingListDataModel dataModel = (OrderingListDataModel) getExtendedDataModel();
-
try {
- final ArrayList list = new ArrayList(dataModel.getRowCount());
+ final ArrayList list = new ArrayList(getRowCount());
walk(context, new DataVisitor() {
public void process(FacesContext context, Object rowKey,
@@ -599,96 +596,6 @@
}
}
- /**
- *
- * <p>Set the "valid" property according to the below
algorithm.</p>
- *
- * <ul>
- *
- * <li>If the <code>valid</code> property on this component is still
- * <code>true</code>, and the <code>required</code> property
is also
- * true, ensure that the local value is not empty (where "empty" is
- * defined as <code>null</code> or a zero-length String. If the local
- * value is empty:
- * <ul>
- * <li>Enqueue an appropriate error message by calling the
- * <code>addMessage()</code> method on the
<code>FacesContext</code>
- * instance for the current request.</li>
- * <li>Set the <code>valid</code> property on this component to
- * <code>false</code>.</li>
- * </ul></li>
- * <li>If the <code>valid</code> property on this component is still
- * <code>true</code>, and the local value is not empty, call the
- * <code>validate()</code> method of each {@link Validator}
- * registered for this {@link UIInput}, followed by the method
- * pointed at by the <code>validatorBinding</code> property (if any).
- * If any of these validators or the method throws a
- * {@link ValidatorException}, catch the exception, add
- * its message (if any) to the {@link FacesContext}, and set
- * the <code>valid</code> property of this component to
false.</li>
- *
- * </ul>
- *
- */
-
- protected void validateValue(FacesContext context, Object newValue) {
- // If our value is valid, enforce the required property if present
- if (isValid() && isRequired() && isEmpty(newValue)) {
- FacesMessage message =
- MessageFactory.getMessage(context, UIInput.REQUIRED_MESSAGE_ID);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- setValid(false);
- }
-
- // If our value is valid and not empty, call all validators
- if (isValid() && !isEmpty(newValue)) {
- Validator[] validators = getValidators();
- for (int i = 0; i < validators.length; i++) {
- Validator validator = (Validator) validators[i];
- try {
- validator.validate(context, this, newValue);
- }
- catch (ValidatorException ve) {
- // If the validator throws an exception, we're
- // invalid, and we need to add a message
- setValid(false);
- FacesMessage message = ve.getFacesMessage();
- if (message != null) {
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- }
- }
- }
-
- MethodBinding validator = getValidator();
- if (validator != null) {
- try {
- validator.invoke(context,
- new Object[] { context, this, newValue});
- }
- catch (EvaluationException ee) {
- if (ee.getCause() instanceof ValidatorException) {
- ValidatorException ve =
- (ValidatorException) ee.getCause();
-
- // If the validator throws an exception, we're
- // invalid, and we need to add a message
- setValid(false);
- FacesMessage message = ve.getFacesMessage();
- if (message != null) {
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(getClientId(context), message);
- }
- } else {
- // Otherwise, rethrow the EvaluationException
- throw ee;
- }
- }
- }
- }
- }
-
public ItemState getItemState() {
if (submittedValueHolder != null && !submittedValueHolder.isNull()) {
return new ModelItemState(submittedValueHolder.selection,
Modified:
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-12-11
16:20:22 UTC (rev 4720)
+++
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-12-11
16:22:51 UTC (rev 4721)
@@ -28,8 +28,7 @@
<f:clientId var="clientId"/>
<div id="#{clientId}" class="rich-ordering-list-ds
#{component.attributes['styleClass']}"
x:passThruWithExclusions="id,class,styleClass">
- <input id="#{clientId}focusKeeper" type="button"
value="" name="focusKeeper"
- style="width: 1px; position: absolute; left: -32767px;" />
+ <input id="#{clientId}focusKeeper" type="button"
value="" style="width: 1px; position: absolute; left: -32767px;"
/>
<table id="#{clientId}table" cellpadding="0"
cellspacing="0" class="rich-ordering-list-body">
<tbody>
@@ -89,14 +88,10 @@
<script type="text/javascript">
var clientId = '#{cId}';
Event.onReady(function() {
- try {
var cotrolsIdPrefix = [['up', 'disup'], ['down',
'disdown'], ['last', 'dislast'],
['first','disfirst']];
var shuttle = new Richfaces.OrderingList('#{cId}',
'#{cId}internal_tab', '#{cId}internal_header_tab',
'#{cId}focusKeeper', cotrolsIdPrefix, '#{cId}sortLabel',
#{this:getAsEventHandler(context, component, "onorderchanged")},
Richfaces.OrderingListSelectItem);
var layoutManager = new LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
layoutManager.widthSynchronization();
- } catch (e) {
- alert(e);
- }
});
//setTimeout(init, 0);
</script>