You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2009/06/05 13:17:25 UTC
svn commit: r781982 - in
/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm:
jsf/component/ jsf/guiBuilder/ jsf/guiBuilder/impl/jsf/ metadata/
metadata/impl/ metadata/impl/ejb/
Author: skitching
Date: Fri Jun 5 11:17:24 2009
New Revision: 781982
URL: http://svn.apache.org/viewvc?rev=781982&view=rev
Log:
* Allow the MetaField "componentHandler" property to be an EL expression returning a "renderer instance" as well as a String containing
a managed-bean name.
* Make SlipStream class responsible for instantiating componentHandler instance, rather than doing it in both EjbExtractor and DynaConfig
* Make some MetaField classes "boolean" instead of "Boolean" for tidiness
* Remove unused properties MetaField.externalName and MetaFieldImpl.preferredExternalName. Nothing ever sets these properties.
* Add documentation to MetaField properties
Modified:
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/component/DynaConfig.java
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/Slipstream.java
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/impl/jsf/JsfGuiBuilder.java
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaField.java
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaFieldWritable.java
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/MetaFieldImpl.java
myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/component/DynaConfig.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/component/DynaConfig.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/component/DynaConfig.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/component/DynaConfig.java Fri Jun 5 11:17:24 2009
@@ -18,9 +18,7 @@
*/
package org.apache.myfaces.orchestra.dynaForm.jsf.component;
-import org.apache.myfaces.orchestra.dynaForm.jsf.guiBuilder.DynaFormComponentHandler;
import org.apache.myfaces.orchestra.dynaForm.metadata.MetaFieldWritable;
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
@@ -53,7 +51,7 @@
private Boolean displayOnly;
private Boolean readOnly;
private Boolean disabled;
- private String componentHandler;
+ private Object componentHandler;
@Override
public String getFamily()
@@ -146,26 +144,48 @@
}
/**
- * @see #setComponentHandler.
+ * Specifies the "controller bean" used to render this specific field.
+ * <p>
+ * This may return:
+ * <ul>
+ * <li>Null when there is no special component-handler..</li>
+ * <li>A String which is the name of a managed-bean that implements DynaFormComponentHandler</li>
+ * <li>A DynaFormComponentHandler object</li>
+ * </ul>
+ * <p>
+ * The configureMetaData method of this class just copies this setting into a MetaField object
+ * which is later used when building the components necessary to manage this field.
+ * <p>
+ * When the value is null, dynaform will create a default component to manage this field,
+ * depending on its type.
+ * <p>
+ * In the other cases, the DynaFormComponentHandler object is responsible for creating the
+ * necessary UI components to manage this field.
+ * <p>
+ * Normally, the JSP/Facelets framework will set this property to a String when the user
+ * provides a non-EL-expression, and will put a ValueBinding object into this component's
+ * value-binding map when the user provides an EL expression. As the value-binding could
+ * return a DynaFormComponentHandler or a String, this property type must be Object.
*/
- public String getComponentHandler()
+ public Object getComponentHandler()
{
if (componentHandler != null)
{
return componentHandler;
}
ValueBinding vb = getValueBinding("componentHandler");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ return vb != null ? vb.getValue(getFacesContext()) : null;
}
/**
* Specifies the "controller bean" used to render this specific field.
* <p>
- * This should be the name of a managed bean which implements DynaFormComponentHandler.
+ * This should be the name of a managed bean which implements DynaFormComponentHandler,
+ * or an actual DynaFormComponentHandler instance.
*/
- public void setComponentHandler(String beanName)
+ public void setComponentHandler(Object value)
{
- this.componentHandler = beanName;
+ this.componentHandler = value;
}
/**
@@ -217,6 +237,14 @@
};
}
+ /**
+ * Update the specified field with the settings the user has configured from this JSF component.
+ * <p>
+ * This method is called <i>after</i> the user-specified extractor implementation is called. This
+ * means that any settings the user has defined in the JSF can override those auto-detected via
+ * the earlier extractor. However here we must only override earlier settings if they really
+ * have been set in the JSF config.
+ */
public void configureMetaData(MetaFieldWritable field)
{
Integer displaySize = getDisplaySize();
@@ -228,39 +256,27 @@
Boolean displayOnly = getDisplayOnly();
if (displayOnly != null)
{
- field.setDisplayOnly(displayOnly);
+ field.setDisplayOnly(displayOnly.booleanValue());
}
- // field is writable unless readonly is true.
+ // readOnly is a synonym for displayOnly
Boolean readOnly = getReadOnly();
- field.setCanWrite(!Boolean.TRUE.equals(readOnly));
-
- // fields are always readable
- field.setCanRead(true);
+ if (readOnly != null)
+ {
+ field.setDisplayOnly(readOnly.booleanValue());
+ }
Boolean disabled = getDisabled();
if (disabled != null)
{
+ // Note: the disabled property is deprecated
field.setDisabled(disabled.booleanValue());
}
- String chName = getComponentHandler();
- if (chName != null)
+ Object ch = getComponentHandler();
+ if (ch != null)
{
- Object componentHandlerBean = FrameworkAdapter.getCurrentInstance().getBean(chName);
- if (componentHandlerBean == null)
- {
- throw new IllegalArgumentException(
- "No component handler with bean name [" + chName + "] found.");
- }
- if (!(componentHandlerBean instanceof DynaFormComponentHandler))
- {
- throw new IllegalArgumentException(
- "Managed bean with name [" + chName +
- "] doesn't implement interface " + DynaFormComponentHandler.class.getName());
- }
-
- field.setComponentHandler((DynaFormComponentHandler) componentHandlerBean);
+ field.setComponentHandler(ch);
}
if (getChildCount() > 0)
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/Slipstream.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/Slipstream.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/Slipstream.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/Slipstream.java Fri Jun 5 11:17:24 2009
@@ -21,10 +21,14 @@
import org.apache.myfaces.orchestra.dynaForm.jsf.component.DynaForm;
import org.apache.myfaces.orchestra.dynaForm.metadata.MetaData;
import org.apache.myfaces.orchestra.dynaForm.metadata.MetaField;
+import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
import java.util.Iterator;
import java.util.Map;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
/**
* The slipstream will bring the configuration-metaData/gui together
*/
@@ -89,17 +93,65 @@
{
String fieldName = iterFieldNames.next();
MetaField field = modelMetaData.getField(fieldName);
- if (field.getComponentHandler() != null)
+ Object ch = field.getComponentHandler();
+ if (ch == null)
{
- field.getComponentHandler().buildComponent(dynaForm, guiBuilder, field);
+ // No component-handler; let the guiBuilder decide what JSF component to create
+ // for this field.
+ guiBuilder.buildField(field);
}
else
{
- guiBuilder.buildField(field);
+ getComponentHandler(ch).buildComponent(dynaForm, guiBuilder, field);
}
}
}
+ protected DynaFormComponentHandler getComponentHandler(Object ch)
+ {
+ if (ch instanceof ValueBinding)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ValueBinding vb = (ValueBinding) ch;
+ ch = vb.getValue(facesContext);
+
+ if (ch == null)
+ {
+ throw new IllegalArgumentException(
+ "ComponentHandler expression '" + vb.getExpressionString() + "' returned null.");
+ }
+ }
+
+ if (ch instanceof DynaFormComponentHandler)
+ {
+ return (DynaFormComponentHandler) ch;
+ }
+
+ if (ch instanceof String)
+ {
+ String chName = (String) ch;
+ Object bean = FrameworkAdapter.getCurrentInstance().getBean(chName);
+ if (bean == null)
+ {
+ throw new IllegalArgumentException(
+ "No component handler with bean name [" + chName + "] found.");
+ }
+ if (!(bean instanceof DynaFormComponentHandler))
+ {
+ throw new IllegalArgumentException(
+ "Managed bean with name [" + chName +
+ "] doesn't implement interface " + DynaFormComponentHandler.class.getName());
+ }
+
+ return (DynaFormComponentHandler) bean;
+ }
+
+ throw new IllegalArgumentException(
+ "Invalid ComponentHandler of type '" +
+ ch.getClass() +
+ "' found; String or DynaFormComponentHandler expected.");
+ }
+
protected void configureGuiBuilder()
{
guiBuilder.setFormDisplayOnly(dynaForm.isDisplayOnly());
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/impl/jsf/JsfGuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/impl/jsf/JsfGuiBuilder.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/impl/jsf/JsfGuiBuilder.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/jsf/guiBuilder/impl/jsf/JsfGuiBuilder.java Fri Jun 5 11:17:24 2009
@@ -841,11 +841,7 @@
protected String getFieldId(MetaField field)
{
- String idCandidate = field.getExternalName();
- if (idCandidate == null)
- {
- idCandidate = field.getName();
- }
+ String idCandidate = field.getName();
return getCleanedNameForId(idCandidate);
}
@@ -891,7 +887,7 @@
protected String createValueBindingString(MetaField field)
{
- return "#{" + backingEntityPrefix + "." + field.getExternalName() + "}";
+ return "#{" + backingEntityPrefix + "." + field.getName() + "}";
}
/**
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaField.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaField.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaField.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaField.java Fri Jun 5 11:17:24 2009
@@ -18,7 +18,6 @@
*/
package org.apache.myfaces.orchestra.dynaForm.metadata;
-import org.apache.myfaces.orchestra.dynaForm.jsf.guiBuilder.DynaFormComponentHandler;
import org.apache.myfaces.orchestra.dynaForm.lib.SelectionSourceEnum;
import javax.faces.component.UIComponent;
@@ -26,53 +25,132 @@
import javax.persistence.TemporalType;
/**
- * Rad-only representation of meta-data about a single property of an entity.
+ * Read-only representation of meta-data about a single property of an entity.
* <p>
* This is similar to java.beans.PropertyDescriptor, but customised for the
* needs of the DynaForm component.
+ * <p>
+ * An instance of this type is generally configured via one or more implementations
+ * of the Extractor interface. For example an Extractor could introspect java beans,
+ * or introspect a database report definition, or scan the current page template for
+ * configuration for the named field. Any settings found are then used to create
+ * MetaField definitions for fields, or when multiple Extractors are configured
+ * then later ones can override settings from earlier extractors.
+ * <p>
+ * Note that it is very important that all Extractor implementations properly set
+ * the canRead/canWrite properties on MetaFields. These values default to null
+ * (ie false), so if they are not correctly set then UI components can behave
+ * oddly (eg be readonly when not expected).
*/
public interface MetaField
{
+ /**
+ * The "name" of this field.
+ * <p>
+ * The name property can contain dots, eg "foo.bar.lastname".
+ */
public String getName();
+ /**
+ * Returns the part of the "name" property following the last dot.
+ * If "name" has no dots, then this returns name.
+ */
public String getBaseName();
- public String getExternalName();
-
- // The type of the property that this Field instance represents.
+ /**
+ * The type of the property that this Field instance represents.
+ */
public Class<?> getType();
- // Is this field a stand-alone persistent entity, or just a
- // plain property?
+ /**
+ * Returns true if the type of this field is a persistent class.
+ * <p>
+ * This should be set if the type of this field is some kind of class
+ * (ie not a primitive) and that class has the @Entity annotation on it.
+ */
public boolean isEntityType();
- // Is this the key property of this entity?
- // TODO: what about compound keys?
+ /**
+ * Returns true when this field belongs to a persistent entity and this field
+ * is part of the entity key. In this situation, the field is automatically
+ * marked as "readonly" because key fields of persistent entities cannot
+ * be edited.
+ */
public boolean isId();
- public Boolean getDisabled();
+ /**
+ * Specify whether this field should be regarded as "disabled for user input".
+ * <p>
+ * There is logically no difference between "disabled" and "display only", so it is
+ * strongly recommended that extractors set the displayOnly property and ignore this
+ * one (ie leave disabled as effectively "false"), and that UI frameworks always use
+ * displayOnly and ignore this property.
+ * <p>
+ * In HTML there is a difference between a "disabled" and a "readonly" input field.
+ * However as an HTML post does not include data from "disabled" fields, and the JSF
+ * 1.2 framework (at least) really screws up when expected fields are not present,
+ * "disabled" HTML inputs should not be used in JSF.
+ */
+ public boolean getDisabled();
- public Boolean getCanRead();
- public Boolean getCanWrite();
+ /**
+ * Indicates whether the model object has a getter method for this property.
+ * When no, then obviously this property cannot be displayed to the user
+ * <p>
+ * It is expected that one or both of getCanRead/getCanWrite is defined; if
+ * both are false then the property doesn't exist!
+ * <p>
+ * Normally, this would be true; write-only properties are not common. However
+ * they are technically possible. Handling these may be difficult/impossible in
+ * some presentation frameworks though; for example JSF value bindings simply
+ * don't work with write-only fields.
+ */
+ public boolean getCanRead();
- public Boolean getDisplayOnly();
+ /**
+ * Indicates whether the model object has a setter method for this property.
+ * When no, then obviously this property is effectively read-only, as no
+ * user changes can be stored.
+ * <p>
+ * It is expected that one or both of getCanRead/getCanWrite is defined; if
+ * both are false then the property doesn't exist!
+ */
+ public boolean getCanWrite();
- // Can the entity be persisted when this field is null?
+ /**
+ * Indicates whether the user should be allowed to edit this field.
+ * This is equivalent to "getReadOnly".
+ * <p>
+ * Note that when getCanWrite is false, then this should be true. However
+ * even when there is a property setter (getCanWrite is true), a property
+ * may be configured as display-only for the user.
+ */
+ public boolean getDisplayOnly();
+
+ /**
+ * Returns true if this field must have a value defined before the
+ * object is "valid".
+ */
public boolean getRequired();
+ // TODO: document me
public Selection[] getAllowedSelections();
/**
* Indicates whether this property is a <i>relation</i> to some other object.
* <p>
* For primitive fields, this returns NONE.
+ * <p>
+ * Obviously, fields that are relations need special handling in the user interface;
+ * it is generally not a good idea to just display their raw value and allow the
+ * user to enter any other raw value they like.
*/
public RelationType getRelationType();
/**
* In case of hierarchical structures this defines if a child class should be treatened
- * as "embedded".<br />
+ * as "embedded".
* <ul>
* <li>Embedded: like a composite key in hibernate</li>
* <li>Not Embedded: like a relation to another entity (ManyToOne)</li>
@@ -82,8 +160,11 @@
*/
public boolean isEmbedded();
- // Used only for text fields. Limits the number of characters.
- // OR: does this also limit # of chars for numeric and date fields?
+ /**
+ * For text fields, this limits the number of characters that can be entered.
+ * <p>
+ * Question: does this limit #chars for numeric and date fields too?
+ */
public Integer getMaxSize();
/**
@@ -96,9 +177,10 @@
// must be less than maxSize.
public Integer getMinSize();
- // How much space should the input/output component take up on
- // the screen? If this is less than maxSize then the field will
- // usually allow scrolling internally.
+ /**
+ * Specifies how much space should the input/output component take up on the screen. If
+ * this is less than maxSize then the field will usually allow scrolling internally.
+ */
public Integer getDisplaySize();
/**
@@ -109,8 +191,13 @@
// Explicitly allow control over what JSF component is created to
// represent this field.
+ //
+ // TODO: possibly remove this field, and just rely on the componentHandler
+ // functionality instead.
public UIComponent getWantedComponent();
+ // TODO: possibly remove this field and just rely on the componentHandler
+ // functionality instead.
public FieldRepresentation getWantedComponentType();
public TemporalType getTemporalType();
@@ -132,7 +219,27 @@
public String getConverterBean();
- public DynaFormComponentHandler getComponentHandler();
+ /**
+ * Get the custom "renderer" (if any) for this field.
+ * <p>
+ * This method may return:
+ * <ul>
+ * <li>Null when there is no special component-handler.</li>
+ * <li>A String which is the name of a managed-bean that implements an appropriate renderer class</li>
+ * <li>An instance of an appropriate renderer class</li>
+ * <li>A ValueBinding object whose getValue method returns an instance of an appropriate renderer class</li>
+ * </ul>
+ * <p>
+ * When a MetaField is populated by introspecting a java bean, this value could be set by
+ * an annotations on a bean properties. It could also be set via configuration components
+ * in the current page template, or
+ * <p>
+ * The "appropriate renderer class" depends upon the "gui builder" implementation being used.
+ * When the presentation layer is JSF (ie the "gui builder" is "dynaform.jsf.GuiBuilder") then
+ * the "appropriate renderer class" must be a subclass of the "dynaform.jsf.DynaFormComponentHandler"
+ * class.
+ */
+ public Object getComponentHandler();
public Object getAttribute(String name);
}
\ No newline at end of file
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaFieldWritable.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaFieldWritable.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaFieldWritable.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/MetaFieldWritable.java Fri Jun 5 11:17:24 2009
@@ -18,7 +18,6 @@
*/
package org.apache.myfaces.orchestra.dynaForm.metadata;
-import org.apache.myfaces.orchestra.dynaForm.jsf.guiBuilder.DynaFormComponentHandler;
import org.apache.myfaces.orchestra.dynaForm.lib.SelectionSourceEnum;
import javax.faces.component.UIComponent;
@@ -31,9 +30,8 @@
*/
public interface MetaFieldWritable extends MetaField
{
- public void setPreferredExternalName(String preferredExternalName);
public void setType(Class<?> type);
- public void setDisplayOnly(Boolean displayOnly);
+ public void setDisplayOnly(boolean readonly);
public void setCanRead(boolean canRead);
public void setCanWrite(boolean canWrite);
public void setDisabled(boolean disabled);
@@ -59,7 +57,7 @@
public void setConverterId(String converterId);
public void setConverterClass(Class<Converter> converterClass);
public void setConverterBean(String converterBean);
- public void setComponentHandler(DynaFormComponentHandler componentHandler);
+ public void setComponentHandler(Object componentHandler);
public void setAttribute(String name, Object value);
}
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/MetaFieldImpl.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/MetaFieldImpl.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/MetaFieldImpl.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/MetaFieldImpl.java Fri Jun 5 11:17:24 2009
@@ -18,7 +18,6 @@
*/
package org.apache.myfaces.orchestra.dynaForm.metadata.impl;
-import org.apache.myfaces.orchestra.dynaForm.jsf.guiBuilder.DynaFormComponentHandler;
import org.apache.myfaces.orchestra.dynaForm.lib.SelectionSourceEnum;
import org.apache.myfaces.orchestra.dynaForm.metadata.FieldRepresentation;
import org.apache.myfaces.orchestra.dynaForm.metadata.MetaFieldWritable;
@@ -40,14 +39,13 @@
{
private final String name;
private final String baseName;
- private String preferredExternalName;
private Class<?> type;
private boolean entityType;
private boolean id;
- private Boolean canRead;
- private Boolean canWrite;
- private Boolean disabled;
- private Boolean displayOnly;
+ private boolean canRead;
+ private boolean canWrite;
+ private boolean disabled;
+ private boolean displayOnly;
private boolean required;
private RelationType relationType = RelationType.NONE;
private boolean embedded = true;
@@ -65,7 +63,7 @@
// Note: JSF datatype here
private UIComponent wantedComponent;
private FieldRepresentation wantedComponentType = FieldRepresentation.Automatic;
- private DynaFormComponentHandler componentHandler;
+ private Object componentHandler;
private String dataSource;
private String dataSourceDescription;
@@ -91,36 +89,18 @@
}
}
+ // name is immutable
public String getName()
{
return name;
}
+ // basename is immutable
public String getBaseName()
{
return baseName;
}
- public String getExternalName()
- {
- if (getPreferredExternalName() != null)
- {
- return getPreferredExternalName();
- }
-
- return getName();
- }
-
- public String getPreferredExternalName()
- {
- return preferredExternalName;
- }
-
- public void setPreferredExternalName(String preferredExternalName)
- {
- this.preferredExternalName = preferredExternalName;
- }
-
public Class<?> getType()
{
return type;
@@ -137,27 +117,22 @@
this.type = type;
}
- public Boolean getDisplayOnly()
+ public boolean getDisplayOnly()
{
return displayOnly;
}
- public void setDisplayOnly(Boolean displayOnly)
+ public void setDisplayOnly(boolean displayOnly)
{
this.displayOnly = displayOnly;
}
- public boolean isCanRead()
- {
- return getCanRead() != null && getCanRead().booleanValue();
- }
-
public void setCanRead(boolean canRead)
{
this.canRead = canRead;
}
- public Boolean getCanRead()
+ public boolean getCanRead()
{
return this.canRead;
}
@@ -167,7 +142,7 @@
this.canWrite = canWrite;
}
- public Boolean getCanWrite()
+ public boolean getCanWrite()
{
return canWrite;
}
@@ -177,7 +152,7 @@
this.disabled = disabled;
}
- public Boolean getDisabled()
+ public boolean getDisabled()
{
return disabled;
}
@@ -402,12 +377,12 @@
this.converterBean = converterBean;
}
- public DynaFormComponentHandler getComponentHandler()
+ public Object getComponentHandler()
{
return componentHandler;
}
- public void setComponentHandler(DynaFormComponentHandler componentHandler)
+ public void setComponentHandler(Object componentHandler)
{
this.componentHandler = componentHandler;
}
Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java?rev=781982&r1=781981&r2=781982&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java Fri Jun 5 11:17:24 2009
@@ -60,14 +60,11 @@
import org.apache.myfaces.orchestra.dynaForm.annot.ui.Range;
import org.apache.myfaces.orchestra.dynaForm.annot.ui.ReadOnly;
import org.apache.myfaces.orchestra.dynaForm.annot.ui.UIComponent;
-//TODO: fix this import; this non-jsf class should not import jsf-specific stuff
-import org.apache.myfaces.orchestra.dynaForm.jsf.guiBuilder.DynaFormComponentHandler;
import org.apache.myfaces.orchestra.dynaForm.metadata.Extractor;
import org.apache.myfaces.orchestra.dynaForm.metadata.MetaDataWritable;
import org.apache.myfaces.orchestra.dynaForm.metadata.MetaFieldWritable;
import org.apache.myfaces.orchestra.dynaForm.metadata.RelationType;
import org.apache.myfaces.orchestra.dynaForm.metadata.Selection;
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
/**
* Extract metadata from ejb3 beans.
@@ -385,13 +382,13 @@
MetaFieldWritable mdField = metaData.getOrCreateField(createFullName(context, name));
mdField.setType(type);
- if (canRead != null && mdField.getCanRead() == null)
+ if (canRead != null)
{
- mdField.setCanRead(canRead);
+ mdField.setCanRead(canRead.booleanValue());
}
- if (canWrite != null && mdField.getCanWrite() == null)
+ if (canWrite != null)
{
- mdField.setCanWrite(canWrite);
+ mdField.setCanWrite(canWrite.booleanValue());
}
mdField.setEmbedded(context.isEmbedded());
initFromType(context, mdField, type);
@@ -515,20 +512,7 @@
{
ComponentHandler componentHandler = accessibleObject.getAnnotation(ComponentHandler.class);
String componentHandlerBeanName = componentHandler.value();
- Object componentHandlerBean = FrameworkAdapter.getCurrentInstance().getBean(componentHandlerBeanName);
- if (componentHandlerBean == null)
- {
- throw new IllegalArgumentException(
- "no component handler with bean name " + componentHandlerBeanName + " found.");
- }
- if (!(componentHandlerBean instanceof DynaFormComponentHandler))
- {
- throw new IllegalArgumentException(
- "component handler with bean name " + componentHandlerBeanName +
- " doesn't implement the " + DynaFormComponentHandler.class.getName() + " interface.");
- }
-
- mdField.setComponentHandler((DynaFormComponentHandler) componentHandlerBean);
+ mdField.setComponentHandler(componentHandlerBeanName);
}
if (accessibleObject.isAnnotationPresent(Column.class))