You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/05/25 22:42:37 UTC
svn commit: r778493 -
/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java
Author: bommel
Date: Mon May 25 20:42:37 2009
New Revision: 778493
URL: http://svn.apache.org/viewvc?rev=778493&view=rev
Log:
(TOBAGO-749) Validation error on submitting a form with selectOneChoice (readOnly=true, required=true)
Modified:
myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java
Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java?rev=778493&r1=778492&r2=778493&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/UISelectOne.java Mon May 25 20:42:37 2009
@@ -18,6 +18,7 @@
*/
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TAB_INDEX;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_READONLY;
import org.apache.myfaces.tobago.util.MessageFactory;
import javax.faces.application.FacesMessage;
@@ -26,7 +27,6 @@
import java.io.IOException;
/*
- * User: weber
* Date: May 31, 2005
* Time: 7:47:11 PM
*/
@@ -37,19 +37,22 @@
private String[] markup;
private Integer tabIndex;
+ private Boolean readonly;
public void restoreState(FacesContext context, Object state) {
Object[] values = (Object[]) state;
super.restoreState(context, values[0]);
markup = (String[]) values[1];
tabIndex = (Integer) values[2];
+ readonly = (Boolean) values[3];
}
public Object saveState(FacesContext context) {
- Object[] values = new Object[3];
+ Object[] values = new Object[4];
values[0] = super.saveState(context);
values[1] = markup;
values[2] = tabIndex;
+ values[3] = readonly;
return values;
}
@@ -60,7 +63,7 @@
}
public void validate(FacesContext facesContext) {
- if (isRequired()) {
+ if (isRequired() && !isReadonly()) {
Object submittedValue = getSubmittedValue();
if (submittedValue == null || "".equals(submittedValue)) {
@@ -102,4 +105,21 @@
this.tabIndex = tabIndex;
}
+ public boolean isReadonly() {
+ if (readonly != null) {
+ return readonly;
+ }
+ javax.faces.el.ValueBinding vb = getValueBinding(ATTR_READONLY);
+ if (vb != null) {
+ Boolean bool = (Boolean) vb.getValue(getFacesContext());
+ if (bool != null) {
+ return bool;
+ }
+ }
+ return false;
+ }
+
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
}