Package org.openbravo.client.kernel
Class BaseComponent
- java.lang.Object
-
- org.openbravo.client.kernel.BaseComponent
-
- All Implemented Interfaces:
Component
- Direct Known Subclasses:
BaseTemplateComponent
,MyOpenbravoWidgetComponent
,SessionDynamicResourceComponent
,StaticResourceComponent
,StyleSheetResourceComponent
,ViewComponent
public abstract class BaseComponent extends Object implements Component
The BaseComponent is the main implementation of theComponent
concept which can be sub-classed to provide custom or specialized behavior. A component can be dependent on another component. This means that in the eventual generated code the dependent components are generated first. The BaseComponent takes care that duplicates in dependent components are handled correctly meaning that a dependency is only included once.- Author:
- mtaal
-
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationDictionaryCachedStructures
adcs
-
Constructor Summary
Constructors Constructor Description BaseComponent()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
bypassAuthentication()
<U extends Component>
UcreateComponent(Class<U> clz)
Return a new component of the correct implementation using Weld.abstract String
generate()
Generates the content of the component which is sent to the client for execution/rendering.ApplicationDictionaryCachedStructures
getADCS()
protected String
getApplicationName()
String
getContentType()
String
getContextUrl()
abstract Object
getData()
List<Component>
getDependencies()
String
getETag()
An ETag is a hash-like string which is used to determine if content has changed since the last request for the content.String
getId()
Date
getLastModified()
Module
getModule()
protected String
getModulePackageName()
Override this method if the component is in a different package than the module.String
getParameter(String key)
List<String>
getParameterNames()
Map<String,Object>
getParameters()
protected String
getSafeValue(Object value)
Translates a null value to a value which can be handled better by a template.boolean
hasParameter(String key)
protected boolean
isClassicMode()
boolean
isInDevelopment()
protected boolean
isInDevelopment(String moduleId)
Returns if a module is set or not to 'in development'boolean
isJavaScriptComponent()
static void
nullifyModuleCache()
void
setDependencies(List<Component> dependencies)
void
setId(String id)
void
setParameters(Map<String,Object> parameters)
protected String
stripHost(String url)
-
-
-
Field Detail
-
adcs
@Inject protected ApplicationDictionaryCachedStructures adcs
-
-
Method Detail
-
generate
public abstract String generate()
Description copied from interface:Component
Generates the content of the component which is sent to the client for execution/rendering.
-
getContextUrl
public String getContextUrl()
-
getId
public String getId()
-
setId
public void setId(String id)
-
getData
public abstract Object getData()
-
hasParameter
public boolean hasParameter(String key)
-
createComponent
public <U extends Component> U createComponent(Class<U> clz)
Return a new component of the correct implementation using Weld.- Parameters:
clz
- an instance of this class will be returned- Returns:
- an instance of clz
-
getETag
public String getETag()
Description copied from interface:Component
An ETag is a hash-like string which is used to determine if content has changed since the last request for the content. See this link for more information. Note for language specific components the etag has to encode the language (id) also! See (OBContext.getLanguage()
) to get the current language.
-
nullifyModuleCache
public static void nullifyModuleCache()
-
getLastModified
public Date getLastModified()
- Specified by:
getLastModified
in interfaceComponent
- Returns:
- the last modified date of any data element used to generate the response, if null is returned then the current date/time is assumed.
-
getModule
public Module getModule()
-
getModulePackageName
protected String getModulePackageName()
Override this method if the component is in a different package than the module.
-
getSafeValue
protected String getSafeValue(Object value)
Translates a null value to a value which can be handled better by a template.
-
getContentType
public String getContentType()
- Specified by:
getContentType
in interfaceComponent
- Returns:
- returns the javascript content type with UTF-8: application/javascript;charset=UTF-8
-
isJavaScriptComponent
public boolean isJavaScriptComponent()
- Specified by:
isJavaScriptComponent
in interfaceComponent
- Returns:
- true if the generated output is javascript
-
isInDevelopment
public boolean isInDevelopment()
- Specified by:
isInDevelopment
in interfaceComponent
- Returns:
- true if the component's module or a module of a subcomponent is in development
- See Also:
Module.isInDevelopment()
-
isInDevelopment
protected boolean isInDevelopment(String moduleId)
Returns if a module is set or not to 'in development'- Parameters:
moduleId
- Id of the module- Returns:
true
if there are modules in "in development" status. Otherwise, returnfalse
- See Also:
ApplicationDictionaryCachedStructures.isInDevelopment(String)
-
getApplicationName
protected String getApplicationName()
-
isClassicMode
protected boolean isClassicMode()
-
bypassAuthentication
public boolean bypassAuthentication()
-
getADCS
public ApplicationDictionaryCachedStructures getADCS()
-
-