You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/10/30 22:19:42 UTC
svn commit: r709246 -
/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
Author: lu4242
Date: Thu Oct 30 14:19:42 2008
New Revision: 709246
URL: http://svn.apache.org/viewvc?rev=709246&view=rev
Log:
TOMAHAWK-1182 Input calendar does not respect the enabledOnUserRole property when rendering as a popup and TOMAHAWK-1345 inputCalendar still renders popupCalendar button even if set as readonly
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java?rev=709246&r1=709245&r2=709246&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java Thu Oct 30 14:19:42 2008
@@ -21,6 +21,7 @@
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.UserRoleUtils;
import org.apache.myfaces.custom.inputTextHelp.HtmlInputTextHelp;
import org.apache.myfaces.custom.prototype.PrototypeResourceLoader;
import org.apache.myfaces.dateformat.SimpleDateFormatter;
@@ -223,7 +224,7 @@
JSFAttr.ID_ATTR);
writer.endElement(HTML.SPAN_ELEM);
- if (!inputCalendar.isDisabled())
+ if (!isDisabled(facesContext, inputCalendar) && !inputCalendar.isReadonly())
{
writer.startElement(HTML.SCRIPT_ELEM, inputCalendar);
writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR,HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
@@ -635,7 +636,7 @@
{
writer.writeAttribute(HTML.CLASS_ATTR, popupButtonStyleClass, null);
}
-
+
writer.endElement(HTML.INPUT_ELEM);
} else {
// render the image
@@ -846,7 +847,7 @@
text.setTransient(true);
HtmlInputCalendar calendar = (HtmlInputCalendar)component;
- if (calendar.isDisabled() || calendar.isReadonly())
+ if (isDisabled(facesContext, component) || calendar.isReadonly())
{
component.getChildren().add(text);
@@ -1068,6 +1069,25 @@
}
}
+
+ protected static boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
+ {
+ if (!UserRoleUtils.isEnabledOnUserRole(uiComponent))
+ {
+ return true;
+ }
+ else
+ {
+ if (uiComponent instanceof HtmlInputCalendar)
+ {
+ return ((HtmlInputCalendar)uiComponent).isDisabled();
+ }
+ else
+ {
+ return org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false);
+ }
+ }
+ }
public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
{