Author: alexsmirnov
Date: 2007-06-28 15:49:03 -0400 (Thu, 28 Jun 2007)
New Revision: 1389
Added:
branches/refactor1/framework/api/src/main/java/org/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/Range.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/Cache.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheEntry.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheException.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheFactory.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheListener.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheLoader.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Draggable.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Dropzone.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragListener.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListener.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropSource.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/Skin.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
branches/refactor1/framework/api/src/main/java/org/richfaces/
branches/refactor1/framework/api/src/main/java/org/richfaces/component/
branches/refactor1/framework/api/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModel.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModelItem.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/Column.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/LastElementAware.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/ListRowKey.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/Row.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeDataModel.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNode.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNodeImpl.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeRowKey.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedListener.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedListener.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeRange.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerEvent.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerListener.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerSource.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java
branches/refactor1/framework/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java
branches/refactor1/sandbox/api/src/main/java/org/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Selectable.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Sortable.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/SimpleToggle2Event.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/scroll/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortEvent.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortListener.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortSource.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/DataModelCache.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/ClientSelection.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/Selection.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SelectionRange.java
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
branches/refactor1/ui/core/src/main/java/org/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/ForceRender.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIInclude.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPoll.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPortlet.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPush.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIResource.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
Removed:
branches/refactor1/extensions/seam/src/main/java/org/ajax4jsf/framework/resource/SeamResourceLifecycle.java
branches/refactor1/extensions/trinidad/src/main/java/org/ajax4jsf/framework/ajax/TrinidadAjaxContext.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/ForceRender.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIInclude.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPoll.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPortlet.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPush.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIResource.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/Range.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/Cache.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheEntry.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheException.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheFactory.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheListener.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheLoader.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Draggable.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Dropzone.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragListener.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListener.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropSource.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/Skin.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScript.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScriptBuilder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModel.java
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModelItem.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderListener.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderSource.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderAdapter.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderEvent.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderListener.java
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderSource.java
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Column.java
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Row.java
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/ISimpleToggleListener.java
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/SimpleToggleEvent.java
branches/refactor1/ui/tabPanel/src/main/java/org/richfaces/model/TabModel.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/LastElementAware.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/ListRowKey.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeDataModel.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNode.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNodeImpl.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeRowKey.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedListener.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedListener.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeRange.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlNodeData.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
Log:
Move classes to API projects
Deleted:
branches/refactor1/extensions/seam/src/main/java/org/ajax4jsf/framework/resource/SeamResourceLifecycle.java
===================================================================
---
branches/refactor1/extensions/seam/src/main/java/org/ajax4jsf/framework/resource/SeamResourceLifecycle.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/extensions/seam/src/main/java/org/ajax4jsf/framework/resource/SeamResourceLifecycle.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,73 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.seam.contexts.ContextAdaptor;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.contexts.Lifecycle;
-import org.jboss.seam.core.Manager;
-
-/**
- * @author shura
- *
- */
-public class SeamResourceLifecycle extends ResourceLifecycle {
-
- @Override
- public void send(ResourceContext resourceContext, InternetResource resource) throws
IOException {
- FacesContext facesContext = null;
- if(resource.requireFacesContext()){
- facesContext = FacesContext.getCurrentInstance();
- }
- if(null != facesContext){
- ExternalContext externalContext = facesContext.getExternalContext();
- Object response = externalContext.getResponse();
- HttpSession session = (HttpSession) externalContext.getSession(true);
- Lifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
-// Lifecycle.setServletRequest(request);
- Lifecycle.beginRequest(externalContext);
- Map parameters = externalContext.getRequestParameterMap();
- Manager.instance().restoreConversation( parameters );
- Lifecycle.resumeConversation(externalContext);
- Manager.instance().handleConversationPropagation(parameters);
- super.send(resourceContext, resource);
- if ( Contexts.isConversationContextActive() )
- {
- Lifecycle.flushClientConversation();
- Manager.instance().storeConversation(ContextAdaptor.getSession(session),
response);
- }
- Lifecycle.endRequest();
-
- } else {
- super.send(resourceContext, resource);
- }
- }
-
-}
Deleted:
branches/refactor1/extensions/trinidad/src/main/java/org/ajax4jsf/framework/ajax/TrinidadAjaxContext.java
===================================================================
---
branches/refactor1/extensions/trinidad/src/main/java/org/ajax4jsf/framework/ajax/TrinidadAjaxContext.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/extensions/trinidad/src/main/java/org/ajax4jsf/framework/ajax/TrinidadAjaxContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,73 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
-import org.apache.myfaces.trinidad.util.Service;
-
-/**
- * @author shura
- *
- */
-public class TrinidadAjaxContext extends AjaxContext {
-
- /**
- *
- */
- public TrinidadAjaxContext() {
- super();
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxContext#encodeAjaxBegin(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
-
- public void encodeAjaxBegin(FacesContext context, UIComponent component) throws
IOException {
- // create Trinidad Rendering service
- ExtendedRenderKitService renderKitService =
(ExtendedRenderKitService)Service.getRenderKitService(context,
ExtendedRenderKitService.class);
- if(null != renderKitService){
- renderKitService.encodeBegin(context);
- }
- super.encodeAjaxBegin(context, component);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxContext#encodeAjaxEnd(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
-
- public void encodeAjaxEnd(FacesContext context, UIComponent component) throws
IOException {
- // create Trinidad Rendering service
- ExtendedRenderKitService renderKitService =
(ExtendedRenderKitService)Service.getRenderKitService(context,
ExtendedRenderKitService.class);
- super.encodeAjaxEnd(context, component);
- if(null != renderKitService){
- renderKitService.encodeEnd(context);
- }
- }
-
-
-
-}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/PushEventListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,10 @@
+package org.ajax4jsf.ajax;
+
+import java.util.EventListener;
+import java.util.EventObject;
+
+public interface PushEventListener extends EventListener {
+
+ public void onEvent(EventObject event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.util.Set;
+
+import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
+
+/**
+ * Interface for iterable component, allowed for render given set of rows in ajax
response.
+ * @author shura
+ *
+ */
+public interface AjaxDataEncoder extends AjaxChildrenEncoder {
+
+ /**
+ * @return Set for values of {@link ExtendedDataModel} keys, encoded in ajax response by
this component.
+ */
+ public Set getAjaxKeys();
+
+ public void setAjaxKeys(Set ajaxKeys);
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,42 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import javax.faces.component.StateHolder;
+
+/**
+ * Interface for classes keeped current iterable component state, as :
+ * active data objects range
+ * sorting order
+ * tree nodes expanded state
+ *
+ * @author shura
+ *
+ */
+public interface DataComponentState {
+
+ /**
+ * Build used data objects range for iteration.
+ * @return
+ */
+ public abstract Range getRange();
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Interface for classes, able to receive visitor processing calls from
ExtendedDataModel
+ * @author shura
+ *
+ */
+public interface DataVisitor {
+
+ /**
+ * This method called back ( as visitor ) from {@link
ExtendedDataModel#walk(FacesContext, DataVisitor, Range)} for
+ * each row.
+ * @param context current JSF context.
+ * @param rowKey current row key of DataModel
+ * @param argument Implementation-specific argument
+ * @throws IOException
+ */
+ public void process(FacesContext context,Object rowKey, Object argument) throws
IOException;
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,83 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+
+/**
+ * Extesion for {@link DataModel} , for support complex data structure, like tree,
spreadsheet etc
+ * in iterable components.
+ * @author shura
+ *
+ */
+public abstract class ExtendedDataModel extends DataModel {
+
+ /**
+ * <p>Instead of simple <code>int</code> for current state selection,
this model can use any object for
+ * select current data. Implementation depend on model, with any restrictions
:</p>
+ * <ol>
+ * <li> key must be {@link Serializable}.</li>
+ * <li>{@link Object#toString()} method must return representation compatible with
{@link javax.faces.component.UIComponent#getClientId(javax.faces.context.FacesContext)},
+ * as far as this string will be appended to clientId of iterator component.</li>
+ * </ol>
+ * @param key key for select current data, or null for clear selection.
+ */
+ public abstract void setRowKey(Object key);
+
+ /**
+ * @return key for selected data or <code>null</code>
+ */
+ public abstract Object getRowKey();
+
+ /**
+ * Iteration component can support save data for use at decoding/validation/update
phases to avoid unnessesary calls to original models,
+ * for example - to avoid requests to database until all data is validated.
+ * @return
+ */
+ public SerializableDataModel getSerializableModel(Range range){
+ // By default, model not serializable.
+ return null;
+ }
+
+
+ /**
+ * Iterate over model by "visitor" pattern, for given range
+ * @param context current JSF context.
+ * @param visitor instance of {@link DataVisitor}, for process each row.
+ * @param range Implementation-specific range of data keys.
+ * @param argument Implementation-specific argument
+ * @throws IOException
+ */
+ public abstract void walk(FacesContext context,DataVisitor visitor,Range range, Object
argument) throws IOException;
+
+ /**
+ * Create Iterator on all row keys for given range.
+ * @param range - Implementation-specific range of data keys.
+ * @return
+ */
+// public abstract Iterator dataIterator(Range range);
+
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/Range.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/Range.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/Range.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/Range.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+/**
+ * Marker interface for building iterator over dataModel values. over {@link
ExtendedDataModel} elements.
+ * It can be simple min/max values for data table, but also can provide set of
expanded/collapsed nodes in tree,
+ * can provide sorting order,
+ * @author shura
+ *
+ */
+public interface Range {
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,81 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.Serializable;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author shura
+ *
+ */
+public class RepeatState implements DataComponentState,Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5552520123654180445L;
+
+ private int _rows = -1;
+
+ private int _first = 0;
+
+
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return _first;
+ }
+
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ this._first = first;
+ }
+
+ /**
+ * @return the rows
+ */
+ public int getRows() {
+ return _rows;
+ }
+
+ /**
+ * @param rows the rows to set
+ */
+ public void setRows(int rows) {
+ this._rows = rows;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.DataComponentState#getRange()
+ */
+ public Range getRange() {
+ // TODO Auto-generated method stub
+ return new SequenceRange(getFirst(),getRows());
+ }
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,202 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+
+/**
+ * @author shura
+ *
+ */
+public class SequenceDataModel extends ExtendedDataModel {
+
+ private DataModel wrappedModel;
+
+ /**
+ * @param wrapped
+ */
+ public SequenceDataModel(DataModel wrapped) {
+ super();
+ this.wrappedModel = wrapped;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.ajax.repeat.ExtendedDataModel#dataIterator(org.ajax4jsf.ajax.repeat.Range)
+ */
+/* public Iterator dataIterator(Range range) {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = wrapped.getRowCount();
+ final int firstRow = seqRange.getFirstRow();
+ if(rows > 0){
+ rows += firstRow;
+ if(rowCount >=0){
+ rows = Math.min(rows, rowCount);
+ }
+ } else if(rowCount >=0 ){
+ rows = rowCount;
+ }
+ final int maxRow = rows;
+ return new Iterator(){
+
+ int rowIndex = firstRow;
+
+ public boolean hasNext() {
+ // TODO Auto-generated method stub
+ return maxRow < 0 || rowIndex < maxRow;
+ }
+
+ public Object next() {
+ // TODO Auto-generated method stub
+ return new Integer(rowIndex++);
+ }
+
+ public void remove() {
+ throw new IllegalStateException();
+ }
+
+ };
+ }
+*/
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = wrappedModel.getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if(rows > 0){
+ rows += currentRow;
+ if(rowCount >=0){
+ rows = Math.min(rows, rowCount);
+ }
+ } else if(rowCount >=0 ){
+ rows = rowCount;
+ } else {
+ rows = -1;
+ }
+ while (rows < 0 || currentRow < rows) {
+ wrappedModel.setRowIndex(currentRow);
+ if(wrappedModel.isRowAvailable()){
+ visitor.process(context, new Integer(currentRow), argument);
+ } else {
+ break;
+ }
+ currentRow++;
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ int index = wrappedModel.getRowIndex();
+ if(index<0){
+ return null;
+ }
+ return new Integer(index);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ if(null == key){
+ wrappedModel.setRowIndex(-1);
+ } else {
+ Integer index = (Integer) key;
+ wrappedModel.setRowIndex(index.intValue());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ public int getRowCount() {
+ // TODO Auto-generated method stub
+ return wrappedModel.getRowCount();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ public Object getRowData() {
+ // TODO Auto-generated method stub
+ return wrappedModel.getRowData();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return wrappedModel.getRowIndex();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ // TODO Auto-generated method stub
+ return wrappedModel.getWrappedData();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ // TODO Auto-generated method stub
+ return wrappedModel.isRowAvailable();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ public void setRowIndex(int rowIndex) {
+ wrappedModel.setRowIndex(rowIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ wrappedModel.setWrappedData(data);
+ }
+
+ /**
+ * @return the wrappedModel
+ */
+ protected DataModel getWrappedModel() {
+ return this.wrappedModel;
+ }
+
+ /**
+ * @param wrappedModel the wrappedModel to set
+ */
+ protected void setWrappedModel(DataModel wrappedModel) {
+ this.wrappedModel = wrappedModel;
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+/**
+ * @author shura
+ *
+ */
+public class SequenceRange implements Range {
+
+ private int firstRow = 0;
+
+ private int rows = -1;
+
+ /**
+ * @return the firstRow
+ */
+ public int getFirstRow() {
+ return firstRow;
+ }
+
+ /**
+ * @return the rows
+ */
+ public int getRows() {
+ return rows;
+ }
+
+ /**
+ * @param firstRow
+ * @param rows
+ */
+ public SequenceRange(int firstRow, int rows) {
+ super();
+ this.firstRow = firstRow;
+ this.rows = rows;
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.Serializable;
+
+/**
+ * Serializable version of {@link ExtendedDataModel}, for save lightweight version of
data
+ *
+ * @author shura
+ *
+ */
+public abstract class SerializableDataModel extends ExtendedDataModel implements
Serializable {
+
+ /**
+ * Method called after update all model values. For example, developer can update
+ * database with new values of modified rows.
+ */
+ public abstract void update();
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,1321 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
+
+/**
+ * Base class for iterable components, like dataTable, Tomahawk dataList,
+ * Facelets repeat, tree etc., with support for partial rendering on AJAX
+ * responces for one or more selected iterations.
+ *
+ * @author shura
+ *
+ */
+public abstract class UIDataAdaptor extends UIData implements AjaxDataEncoder {
+
+ /**
+ *
+ */
+ public static final String COMPONENT_STATE_ATTRIBUTE = "componentState";
+
+ public final static DataModel EMPTY_MODEL = new ListDataModel(
+ Collections.EMPTY_LIST);
+
+ /**
+ * Base class for visit data model at phases decode, validation and
+ * update model
+ *
+ * @author shura
+ *
+ */
+ protected abstract class ComponentVisitor implements DataVisitor {
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+ setRowKey(context, rowKey);
+ if (isRowAvailable()) {
+ Iterator childIterator = dataChildren();
+ while (childIterator.hasNext()) {
+ UIComponent component = (UIComponent) childIterator.next();
+ processComponent(context, component, argument);
+ }
+
+ }
+ }
+
+ public abstract void processComponent(FacesContext context,
+ UIComponent c, Object argument) throws IOException;
+
+ }
+
+ /**
+ * Visitor for process decode on children components.
+ */
+ protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
+
+ public void processComponent(FacesContext context, UIComponent c,
+ Object argument) {
+ c.processDecodes(context);
+ }
+
+ };
+
+ /**
+ * Visitor for process validation phase
+ */
+ protected ComponentVisitor validateVisitor = new ComponentVisitor() {
+
+ public void processComponent(FacesContext context, UIComponent c,
+ Object argument) {
+ c.processValidators(context);
+ }
+
+ };
+
+ /**
+ * Visitor for process update model phase.
+ */
+ protected ComponentVisitor updateVisitor = new ComponentVisitor() {
+
+ public void processComponent(FacesContext context, UIComponent c,
+ Object argument) {
+ c.processUpdates(context);
+ }
+
+ };
+
+ /**
+ * Base client id's of this component, for wich invoked encode...
+ * methods. Component will save state and serialisable models for this
+ * keys only.
+ */
+ private Set _encoded;
+
+ /**
+ * Storage for data model instances with different client id's of this
+ * component. In case of child for UIData component, this map will keep
+ * data models for different iterations between phases.
+ */
+ private Map _modelsMap = new HashMap();
+
+ /**
+ * Reference for curent data model
+ */
+ private ExtendedDataModel _currentModel = null;
+
+ /**
+ * States of this component for diferent iterations, same as for models.
+ */
+ private Map _statesMap = new HashMap();
+
+ /**
+ * Reference for current component state.
+ */
+ private DataComponentState _currentState = null;
+
+ /**
+ * Name of EL variable for current component state.
+ */
+ private String _stateVar;
+
+ private String _rowKeyVar;
+
+ /**
+ * Key for current value in model.
+ */
+ private Object _rowKey = null;
+
+ /**
+ * Values of row keys, encoded on ajax response rendering.
+ */
+ private Set _ajaxKeys = null;
+
+ private Object _ajaxRowKey = null;
+
+ private Map _ajaxRowKeysMap = new HashMap();
+
+ /**
+ * Get name of EL variable for component state.
+ *
+ * @return the varState
+ */
+ public String getStateVar() {
+ return _stateVar;
+ }
+
+ /**
+ * @param varStatus
+ * the varStatus to set
+ */
+ public void setStateVar(String varStatus) {
+ this._stateVar = varStatus;
+ }
+
+ /**
+ * @return the rowKeyVar
+ */
+ public String getRowKeyVar() {
+ return this._rowKeyVar;
+ }
+
+ /**
+ * @param rowKeyVar
+ * the rowKeyVar to set
+ */
+ public void setRowKeyVar(String rowKeyVar) {
+ this._rowKeyVar = rowKeyVar;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIData#getRowCount()
+ */
+ public int getRowCount() {
+ return getExtendedDataModel().getRowCount();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIData#getRowData()
+ */
+ public Object getRowData() {
+ return getExtendedDataModel().getRowData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIData#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ return this.getExtendedDataModel().isRowAvailable();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIData#setRowIndex(int)
+ */
+ public void setRowIndex(int index) {
+ FacesContext faces = FacesContext.getCurrentInstance();
+ ExtendedDataModel localModel = getExtendedDataModel();
+ // if(key == localModel.getRowIndex()){
+ // return;
+ // }
+ // save child state
+ this.saveChildState(faces);
+ // Set current model row by int, but immediately get value from model.
+ // for compability, complex models must provide values map between
+ // integer and key value.
+ localModel.setRowIndex(index);
+ this._rowKey = localModel.getRowKey();
+ this._clientId = null;
+ boolean rowSelected = this._rowKey != null;
+
+ setupVariable(faces, localModel, rowSelected);
+ // restore child state
+ this.restoreChildState(faces);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIData#getRowIndex()
+ */
+ public int getRowIndex() {
+ return getExtendedDataModel().getRowIndex();
+ }
+
+ /**
+ * Same as for int index, but for complex model key.
+ *
+ * @return
+ */
+ public Object getRowKey() {
+ return this._rowKey;
+ }
+
+ public void setRowKey(Object key) {
+ setRowKey(FacesContext.getCurrentInstance(), key);
+ }
+
+ /**
+ * Setup current roy by key. Perform same functionality as
+ * {@link UIData#setRowIndex(int)}, but for key object - it may be not
+ * only row number in sequence data, but, for example - path to current
+ * node in tree.
+ *
+ * @param faces -
+ * current FacesContext
+ * @param key
+ * new key value.
+ */
+ public void setRowKey(FacesContext faces, Object key) {
+ ExtendedDataModel localModel = getExtendedDataModel();
+ // save child state
+ this.saveChildState(faces);
+ this._rowKey = key;
+ this._clientId = null;
+ localModel.setRowKey(key);
+
+ boolean rowSelected = key != null;
+
+ setupVariable(faces, localModel, rowSelected);
+ // restore child state
+ this.restoreChildState(faces);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.ajax.repeat.AjaxDataEncoder#getAjaxKeys()
+ */
+ public Set getAjaxKeys() {
+ Set keys = null;
+ if (this._ajaxKeys != null) {
+ keys = (this._ajaxKeys);
+ } else {
+ ValueBinding vb = getValueBinding("ajaxKeys");
+ if (vb != null) {
+ keys = (Set) (vb.getValue(getFacesContext()));
+ } else if(null != _ajaxRowKey){
+ // If none of above exist , use row with submitted AjaxComponent
+ keys = new HashSet(1);
+ keys.add(_ajaxRowKey);
+ }
+ }
+ return keys;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.ajax.repeat.AjaxDataEncoder#setAjaxKeys(java.util.Set)
+ */
+ public void setAjaxKeys(Set ajaxKeys) {
+ this._ajaxKeys = ajaxKeys;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
+ * java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxChild(FacesContext context, String path,
+ final Set ids, final Set renderedAreas) throws IOException {
+ resetDataModel();
+
+ Renderer renderer = getRenderer(context);
+ if (null != renderer && renderer instanceof AjaxChildrenRenderer) {
+ // If renderer support partial encoding - call them.
+ AjaxChildrenRenderer childrenRenderer = (AjaxChildrenRenderer) renderer;
+ childrenRenderer.encodeAjaxChildren(context, this, path, ids,
+ renderedAreas);
+ } else {
+ // Use simple ajax children encoding for iterate other keys.
+ final AjaxChildrenRenderer childrenRenderer = getChildrenRenderer();
+ final String childrenPath = path + getId() + NamingContainer.SEPARATOR_CHAR;
+ ComponentVisitor ajaxVisitor = new ComponentVisitor() {
+
+ public void processComponent(FacesContext context,
+ UIComponent c, Object argument) throws IOException {
+ childrenRenderer.encodeAjaxComponent(context, c, childrenPath,
+ ids, renderedAreas);
+ }
+
+ };
+ Set ajaxKeys = getAjaxKeys();
+ if (null != ajaxKeys) {
+ captureOrigValue();
+ Object savedKey = getRowKey();
+ setRowKey(context, null);
+ Iterator fixedChildren = fixedChildren();
+ while (fixedChildren.hasNext()) {
+ UIComponent component = (UIComponent) fixedChildren.next();
+ ajaxVisitor.processComponent(context, component, null);
+ }
+ for (Iterator iter = ajaxKeys.iterator(); iter.hasNext();) {
+ Object key = (Object) iter.next();
+ ajaxVisitor.process(context, key, null);
+ }
+ setRowKey(savedKey);
+ restoreOrigValue();
+ } else {
+ iterate(context, ajaxVisitor, null);
+ }
+ }
+ }
+
+ /**
+ * Instance of default renderer in ajax responses.
+ */
+ private AjaxChildrenRenderer _childrenRenderer = null;
+
+ /**
+ * getter for simple {@link AjaxChildrenRenderer} instance in case of
+ * ajax responses. If default renderer not support search of children
+ * for encode in ajax response, component will use this instance by
+ * default.
+ *
+ * @return
+ */
+ protected AjaxChildrenRenderer getChildrenRenderer() {
+ if (_childrenRenderer == null) {
+ _childrenRenderer = new AjaxChildrenRenderer() {
+
+ protected Class getComponentClass() {
+ return UIDataAdaptor.class;
+ }
+
+ };
+
+ }
+
+ return _childrenRenderer;
+ }
+
+ /**
+ * @return Set of values for clientId's of this component, for wich was
+ * invoked "encode" methods.
+ */
+ protected Set getEncodedIds() {
+ if (_encoded == null) {
+ _encoded = new HashSet();
+ }
+
+ return _encoded;
+ }
+
+ /**
+ * Setup EL variable for different iteration. Value of row data and
+ * component state will be put into request scope attributes with names
+ * given by "var" and "varState" bean properties.
+ *
+ * @param faces
+ * current faces context
+ * @param localModel
+ * @param rowSelected
+ */
+ protected void setupVariable(FacesContext faces, DataModel localModel,
+ boolean rowSelected) {
+ Map attrs = faces.getExternalContext().getRequestMap();
+ if (rowSelected && isRowAvailable()) {
+ // Current row data.
+ setupVariable(getVar(), attrs, localModel.getRowData());
+ // Component state variable.
+ setupVariable(getStateVar(), attrs, getComponentState());
+ // Row key Data variable.
+ setupVariable(getRowKeyVar(), attrs, getRowKey());
+
+ } else {
+ removeVariable(getVar(), attrs);
+ removeVariable(getStateVar(), attrs);
+ removeVariable(getRowKeyVar(), attrs);
+ }
+ }
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void setupVariable(String var, Map attrs, Object rowData) {
+ if (var != null) {
+ attrs.put(var, rowData);
+ }
+ }
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void removeVariable(String var, Map attrs) {
+ if (var != null) {
+ attrs.remove(var);
+ }
+ }
+
+ /**
+ * Reset data model. this method must be called twice per request -
+ * before decode phase and before component encoding.
+ */
+ protected void resetDataModel() {
+ this.setExtendedDataModel(null);
+ }
+
+ /**
+ * Set data model. Model value will be stored in Map with key as current
+ * clientId for this component, to keep models between phases for same
+ * iteration in case if this component child for other UIData
+ *
+ * @param model
+ */
+ protected void setExtendedDataModel(ExtendedDataModel model) {
+ this._currentModel = model;
+ this._modelsMap.put(getBaseClientId(getFacesContext()), model);
+ }
+
+ /**
+ * Get current data model, or create it by {@link #createDataModel()}
+ * method. For different iterations in ancestor UIData ( if present )
+ * will be returned different models.
+ *
+ * @return current data model.
+ */
+ protected ExtendedDataModel getExtendedDataModel() {
+ if (this._currentModel == null) {
+ String baseClientId = getBaseClientId(getFacesContext());
+ ExtendedDataModel model = (ExtendedDataModel) this._modelsMap
+ .get(baseClientId);
+ if (null == model) {
+ model = createDataModel();
+ this._modelsMap.put(baseClientId, model);
+ }
+ this._currentModel = model;
+ }
+ return this._currentModel;
+ }
+
+ /**
+ * Hook mathod for create data model in concrete implementations.
+ *
+ * @return
+ */
+ protected abstract ExtendedDataModel createDataModel();
+
+ /**
+ * Set current state ( at most cases, visual representation ) of this
+ * component. Same as for DataModel, component will keep states for
+ * different iterations.
+ *
+ * @param state
+ */
+ public void setComponentState(DataComponentState state) {
+ this._currentState = state;
+ this._statesMap.put(getBaseClientId(getFacesContext()),
+ this._currentState);
+ }
+
+ /**
+ * @return current state of this component.
+ */
+ public DataComponentState getComponentState() {
+ DataComponentState state = null;
+ if (this._currentState == null) {
+ // Check for binding state to user bean.
+ ValueBinding valueBinding =
getValueBinding(UIDataAdaptor.COMPONENT_STATE_ATTRIBUTE);
+ FacesContext facesContext = getFacesContext();
+ if (null != valueBinding) {
+ state = (DataComponentState) valueBinding
+ .getValue(facesContext);
+ if (null == state) {
+ // Create default state
+ state = createComponentState();
+ if (!valueBinding.isReadOnly(facesContext)) {
+ // Store created state in user bean.
+ valueBinding.setValue(facesContext, state);
+ }
+ }
+ } else {
+ // Check for stored state in map for parent iterations
+ String baseClientId = getBaseClientId(facesContext);
+ state = (DataComponentState) this._statesMap.get(baseClientId);
+ if (null == state) {
+ // Create default component state
+ state = createComponentState();
+ this._statesMap.put(baseClientId, state);
+ }
+ this._currentState = state;
+ }
+ } else {
+ state = this._currentState;
+ }
+ return state;
+ }
+
+ /**
+ * Hook method for create default state in concrete implementations.
+ *
+ * @return
+ */
+ protected abstract DataComponentState createComponentState();
+
+ private String _clientId = null;
+
+ public String getClientId(FacesContext faces) {
+ if (null == _clientId) {
+ StringBuffer id = new StringBuffer(getBaseClientId(faces));
+ Object rowKey = getRowKey();
+ if (rowKey != null) {
+ id.append(NamingContainer.SEPARATOR_CHAR).append(
+ rowKey.toString());
+ }
+ Renderer renderer;
+ if (null != (renderer = getRenderer(faces))) {
+ _clientId = renderer.convertClientId(faces, id.toString());
+ } else {
+ _clientId = id.toString();
+ }
+
+ }
+ return _clientId;
+ }
+
+ private String _baseClientId = null;
+
+ /**
+ * Get base clietntId of this component ( withowt iteration part )
+ *
+ * @param faces
+ * @return
+ */
+ public String getBaseClientId(FacesContext faces) {
+ // Return any previously cached client identifier
+ if (_baseClientId == null) {
+
+ // Search for an ancestor that is a naming container
+ UIComponent ancestorContainer = this;
+ StringBuffer parentIds = new StringBuffer();
+ while (null != (ancestorContainer = ancestorContainer.getParent())) {
+ if (ancestorContainer instanceof NamingContainer) {
+ parentIds.append(ancestorContainer.getClientId(faces))
+ .append(NamingContainer.SEPARATOR_CHAR);
+ break;
+ }
+ }
+ String id = getId();
+ if (null != id) {
+ _baseClientId = parentIds.append(id).toString();
+ } else {
+ _baseClientId = parentIds.append(
+ faces.getViewRoot().createUniqueId()).toString();
+ }
+ }
+ return (_baseClientId);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#setId(java.lang.String)
+ */
+ public void setId(String id) {
+ // If component created by restoring tree or JSP, initial Id is null.
+ boolean haveId = null != super.getId();
+ super.setId(id);
+ _baseClientId = null;
+ _clientId = null;
+ if (haveId) {
+ // parent UIData ( if present ) will be set same Id at iteration
+ // -
+ // we use it for
+ // switch to different model and state.
+ String baseClientId = getBaseClientId(getFacesContext());
+ this._currentState = (DataComponentState) this._statesMap
+ .get(baseClientId);
+ this._currentModel = (ExtendedDataModel) this._modelsMap
+ .get(baseClientId);
+ if (null != this._currentModel) {
+ this._rowKey = this._currentModel.getRowKey();
+ // restoreChildState();
+ }
+ // Restore value for row with submitted AjaxComponent.
+ this._ajaxRowKey = _ajaxRowKeysMap.get(baseClientId);
+ }
+ }
+
+ private Object origValue;
+
+ /**
+ * Save current state of data variable.
+ */
+ public void captureOrigValue() {
+ captureOrigValue(FacesContext.getCurrentInstance());
+ }
+
+ /**
+ * Save current state of data variable.
+ *
+ * @param faces
+ * current faces context
+ */
+ public void captureOrigValue(FacesContext faces) {
+ String var = getVar();
+ if (var != null) {
+ Map attrs = faces.getExternalContext().getRequestMap();
+ this.origValue = attrs.get(var);
+ }
+ }
+
+ /**
+ * Restore value of data variable after processing phase.
+ */
+ public void restoreOrigValue() {
+ restoreOrigValue(FacesContext.getCurrentInstance());
+ }
+
+ /**
+ * Restore value of data variable after processing phase.
+ *
+ * @param faces
+ * current faces context
+ */
+ public void restoreOrigValue(FacesContext faces) {
+ String var = getVar();
+ if (var != null) {
+ Map attrs = faces.getExternalContext().getRequestMap();
+ if (this.origValue != null) {
+ attrs.put(var, this.origValue);
+ } else {
+ attrs.remove(var);
+ }
+ }
+ }
+
+ /**
+ * Saved values of {@link EditableValueHolder} fields per iterations.
+ */
+ private Map childState;
+
+ /**
+ * @param faces
+ * @return Saved values of {@link EditableValueHolder} fields per
+ * iterations.
+ */
+ protected Map getChildState(FacesContext faces) {
+ if (this.childState == null) {
+ this.childState = new HashMap();
+ }
+ String baseClientId = getBaseClientId(faces);
+ Map currentChildState = (Map) childState.get(baseClientId);
+ if (null == currentChildState) {
+ currentChildState = new HashMap();
+ childState.put(baseClientId, currentChildState);
+ }
+ return currentChildState;
+ }
+
+ /**
+ * Save values of {@link EditableValueHolder} fields before change
+ * current row.
+ *
+ * @param faces
+ */
+ protected void saveChildState(FacesContext faces) {
+
+ Iterator itr = dataChildren();
+ while (itr.hasNext()) {
+ Map childState = this.getChildState(faces);
+ this.saveChildState(faces, (UIComponent) itr.next(), childState);
+ }
+ }
+
+ /**
+ * Recursive method for Iterate on children for save
+ * {@link EditableValueHolder} fields states.
+ *
+ * @param faces
+ * @param c
+ * @param childState
+ */
+ private void saveChildState(FacesContext faces, UIComponent c,
+ Map childState) {
+
+ if (c instanceof EditableValueHolder && !c.isTransient()) {
+ String clientId = c.getClientId(faces);
+ SavedState ss = (SavedState) childState.get(clientId);
+ if (ss == null) {
+ ss = new SavedState();
+ childState.put(clientId, ss);
+ }
+ ss.populate((EditableValueHolder) c);
+ }
+
+ // continue hack
+ Iterator itr = c.getChildren().iterator();
+ while (itr.hasNext()) {
+ saveChildState(faces, (UIComponent) itr.next(), childState);
+ }
+ itr = c.getFacets().values().iterator();
+ while (itr.hasNext()) {
+ saveChildState(faces, (UIComponent) itr.next(), childState);
+ }
+ }
+
+ /**
+ * Restore values of {@link EditableValueHolder} fields after change
+ * current row.
+ *
+ * @param faces
+ */
+ protected void restoreChildState(FacesContext faces) {
+
+ Iterator itr = dataChildren();
+ while (itr.hasNext()) {
+ Map childState = this.getChildState(faces);
+ this.restoreChildState(faces, (UIComponent) itr.next(), childState);
+ }
+ }
+
+ /**
+ * Recursive part of
+ * {@link #restoreChildState(FacesContext, UIComponent, Map)}
+ *
+ * @param faces
+ * @param c
+ * @param childState
+ *
+ */
+ private void restoreChildState(FacesContext faces, UIComponent c,
+ Map childState) {
+ // reset id
+ String id = c.getId();
+ c.setId(id);
+
+ // hack
+ if (c instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) c;
+ String clientId = c.getClientId(faces);
+ SavedState ss = (SavedState) childState.get(clientId);
+ if (ss != null) {
+ ss.apply(evh);
+ } else {
+ NullState.apply(evh);
+ }
+ }
+
+ // continue hack
+ Iterator itr = c.getChildren().iterator();
+ while (itr.hasNext()) {
+ restoreChildState(faces, (UIComponent) itr.next(), childState);
+ }
+ itr = c.getFacets().values().iterator();
+ while (itr.hasNext()) {
+ restoreChildState(faces, (UIComponent) itr.next(), childState);
+ }
+ }
+
+ /**
+ * Check for validation errors on children components. If true, saved
+ * values must be keep on render phase
+ *
+ * @param context
+ * @return
+ */
+ private boolean keepSaved(FacesContext context) {
+
+ Iterator clientIds = this.getChildState(context).keySet().iterator();
+ while (clientIds.hasNext()) {
+ String clientId = (String) clientIds.next();
+ Iterator messages = context.getMessages(clientId);
+ while (messages.hasNext()) {
+ FacesMessage message = (FacesMessage) messages.next();
+ if (message.getSeverity()
+ .compareTo(FacesMessage.SEVERITY_ERROR) >= 0) {
+ return (true);
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Perform iteration on all children components and all data rows with
+ * given visitor.
+ *
+ * @param faces
+ * @param visitor
+ */
+ protected void iterate(FacesContext faces, ComponentVisitor visitor,
+ Object argument) {
+
+ // stop if not rendered
+ if (!this.isRendered()) {
+ return;
+ }
+ // reset rowIndex
+ this.captureOrigValue(faces);
+ this.setRowKey(faces, null);
+ try {
+ Iterator fixedChildren = fixedChildren();
+ while (fixedChildren.hasNext()) {
+ UIComponent component = (UIComponent) fixedChildren.next();
+ visitor.processComponent(faces, component, argument);
+ }
+
+ walk(faces, visitor, argument);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+ this.setRowKey(faces, null);
+ this.restoreOrigValue(faces);
+ }
+ }
+
+ /**
+ * Walk ( visit ) this component on all data-avare children for each
+ * row.
+ *
+ * @param faces
+ * @param visitor
+ * @throws IOException
+ */
+ public void walk(FacesContext faces, DataVisitor visitor, Object argument)
+ throws IOException {
+ getExtendedDataModel().walk(faces, visitor,
+ getComponentState().getRange(), argument);
+ }
+
+ protected void processDecodes(FacesContext faces, Object argument) {
+ if (!this.isRendered())
+ return;
+ this.resetComponent(faces);
+ this.iterate(faces, decodeVisitor, argument);
+ this.decode(faces);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIData#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(FacesContext faces) {
+ processDecodes(faces, null);
+ }
+
+ /**
+ * Reset per-request fields in component.
+ *
+ * @param faces
+ *
+ */
+ protected void resetComponent(FacesContext faces) {
+ // resetDataModel();
+ if (null != this.childState) {
+ childState.remove(getBaseClientId(faces));
+ }
+ this._encoded = null;
+ }
+
+ protected void processUpdates(FacesContext faces, Object argument) {
+ if (!this.isRendered())
+ return;
+ this.iterate(faces, updateVisitor, argument);
+ ExtendedDataModel dataModel = getExtendedDataModel();
+ // If no validation errors, update values for serializable model,
+ // restored from view.
+ if (dataModel instanceof SerializableDataModel && (!keepSaved(faces))) {
+ SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
+ serializableModel.update();
+ }
+ }
+
+ public void processUpdates(FacesContext faces) {
+ processUpdates(faces, null);
+ }
+
+ protected void processValidators(FacesContext faces, Object argument) {
+ if (!this.isRendered())
+ return;
+ this.iterate(faces, validateVisitor, argument);
+ }
+
+ public void processValidators(FacesContext faces) {
+ processValidators(faces, null);
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException {
+ resetDataModel();
+ // if(!keepSaved(context)){
+ // childState.remove(getBaseClientId(context));
+ // }
+ // Mark component as used, if parent UIData change own range states not
+ // accessed at
+ // encode phase must be unsaved.
+ getEncodedIds().add(getBaseClientId(context));
+ // getComponentState().setUsed(true);
+ super.encodeBegin(context);
+ }
+
+ /**
+ * This method must create iterator for all non-data avare children of
+ * this component ( header/footer facets for components and columns in
+ * dataTable, facets for tree etc.
+ *
+ * @return iterator for all components not sensitive for row data.
+ */
+ protected abstract Iterator fixedChildren();
+
+ /**
+ * This method must create iterator for all children components,
+ * processed "per row" It can be children of UIColumn in dataTable,
+ * nodes in tree
+ *
+ * @return iterator for all components processed per row.
+ */
+ protected abstract Iterator dataChildren();
+
+ private final static SavedState NullState = new SavedState();
+
+ // from RI
+ /**
+ * This class keep values of {@link EditableValueHolder} row-sensitive
+ * fields.
+ *
+ * @author shura
+ *
+ */
+ private final static class SavedState implements Serializable {
+
+ private Object submittedValue;
+
+ private static final long serialVersionUID = 2920252657338389849L;
+
+ Object getSubmittedValue() {
+ return (this.submittedValue);
+ }
+
+ void setSubmittedValue(Object submittedValue) {
+ this.submittedValue = submittedValue;
+ }
+
+ private boolean valid = true;
+
+ boolean isValid() {
+ return (this.valid);
+ }
+
+ void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ private Object value;
+
+ Object getValue() {
+ return (this.value);
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ private boolean localValueSet;
+
+ boolean isLocalValueSet() {
+ return (this.localValueSet);
+ }
+
+ public void setLocalValueSet(boolean localValueSet) {
+ this.localValueSet = localValueSet;
+ }
+
+ public String toString() {
+ return ("submittedValue: " + submittedValue + " value: " +
value
+ + " localValueSet: " + localValueSet);
+ }
+
+ public void populate(EditableValueHolder evh) {
+ this.value = evh.getLocalValue();
+ this.valid = evh.isValid();
+ this.submittedValue = evh.getSubmittedValue();
+ this.localValueSet = evh.isLocalValueSet();
+ }
+
+ public void apply(EditableValueHolder evh) {
+ evh.setValue(this.value);
+ evh.setValid(this.valid);
+ evh.setSubmittedValue(this.submittedValue);
+ evh.setLocalValueSet(this.localValueSet);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIData#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ if (event.getComponent() != this) {
+ event = new IndexedEvent(this, event, getRowKey());
+ }
+ // Send event directly to parent, to avoid wrapping in superclass.
+ UIComponent parent = getParent();
+ if (parent == null) {
+ throw new IllegalStateException(
+ "No parent component for queue event");
+ } else {
+ parent.queueEvent(event);
+ }
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+
+ if (!(event instanceof IndexedEvent)) {
+ if (!broadcastLocal(event)) {
+ super.broadcast(event);
+ }
+ return;
+ }
+
+ // Set up the correct context and fire our wrapped event
+ IndexedEvent revent = (IndexedEvent) event;
+ Object oldRowKey = getRowKey();
+ FacesContext faces = FacesContext.getCurrentInstance();
+ captureOrigValue(faces);
+ Object eventRowKey = revent.getKey();
+ setRowKey(faces, eventRowKey);
+ FacesEvent rowEvent = revent.getTarget();
+ rowEvent.getComponent().broadcast(rowEvent);
+ // For Ajax events, keep row value.
+ if (!(rowEvent.getPhaseId() == PhaseId.RENDER_RESPONSE)) {
+ this._ajaxRowKey = eventRowKey;
+ this._ajaxRowKeysMap.put(getBaseClientId(faces), eventRowKey);
+ }
+ setRowKey(faces, oldRowKey);
+ restoreOrigValue(faces);
+ // }
+ return;
+ }
+
+ /**
+ * Process events targetted for concrete implementation. Hook method
+ * called from {@link #broadcast(FacesEvent)}
+ *
+ * @param event -
+ * processed event.
+ * @return true if event processed, false if component must continue
+ * processing.
+ */
+ protected boolean broadcastLocal(FacesEvent event) {
+ return false;
+ }
+
+ /**
+ * Wrapper for event from child component, with value of current row
+ * key.
+ *
+ * @author shura
+ *
+ */
+ protected static final class IndexedEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -8318895390232552385L;
+
+ private final FacesEvent target;
+
+ private final Object key;
+
+ public IndexedEvent(UIDataAdaptor owner, FacesEvent target, Object key) {
+ super(owner);
+ this.target = target;
+ this.key = key;
+ }
+
+ public PhaseId getPhaseId() {
+ return (this.target.getPhaseId());
+ }
+
+ public void setPhaseId(PhaseId phaseId) {
+ this.target.setPhaseId(phaseId);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return this.target.isAppropriateListener(listener);
+ }
+
+ public void processListener(FacesListener listener) {
+ UIDataAdaptor owner = (UIDataAdaptor) this.getComponent();
+ Object prevIndex = owner._rowKey;
+ try {
+ owner.setRowKey(this.key);
+ this.target.processListener(listener);
+ } finally {
+ owner.setRowKey(prevIndex);
+ }
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public FacesEvent getTarget() {
+ return target;
+ }
+
+ }
+
+ /**
+ * "memento" pattern class for state of component.
+ *
+ * @author shura
+ *
+ */
+ private static class DataState implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 17070532L;
+
+ private Object superState;
+
+ private Map componentStates = new HashMap();
+
+ private Set ajaxKeys;
+
+ public String rowKeyVar;
+
+ public String stateVar;
+
+ }
+
+ /**
+ * Serialisable model and component state per iteration of parent
+ * UIData.
+ *
+ * @author shura
+ *
+ */
+ private static class PerIdState implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 9037454770537726418L;
+
+ /**
+ * Flag setted to true if componentState implements StateHolder
+ */
+ private boolean stateInHolder = false;
+
+ /**
+ * Serializable componentState or
+ */
+ private Object componentState;
+
+ private SerializableDataModel model;
+ }
+
+ public void restoreState(FacesContext faces, Object object) {
+ DataState state = (DataState) object;
+ super.restoreState(faces, state.superState);
+ this._ajaxKeys = state.ajaxKeys;
+ this._statesMap = new HashMap();
+ this._rowKeyVar = state.rowKeyVar;
+ this._stateVar = state.stateVar;
+ // Restore serializable models and component states for all rows of
+ // parent UIData ( single if this
+ // component not child of iterable )
+ for (Iterator iter = state.componentStates.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry stateEntry = (Map.Entry) iter.next();
+ PerIdState idState = (PerIdState) stateEntry.getValue();
+ DataComponentState compState;
+ if (idState.stateInHolder) {
+ // TODO - change RichFaces Tree component, for remove reference
+ // to component from state.
+ compState = createComponentState();
+ ((StateHolder) compState).restoreState(faces,
+ idState.componentState);
+ } else {
+ compState = (DataComponentState) idState.componentState;
+ }
+ Object key = stateEntry.getKey();
+ this._statesMap.put(key, compState);
+ this._modelsMap.put(key, idState.model);
+ }
+ }
+
+ public Object saveState(FacesContext faces) {
+ DataState state = new DataState();
+ state.superState = super.saveState(faces);
+ state.ajaxKeys = this._ajaxKeys;
+ state.rowKeyVar = this._rowKeyVar;
+ state.stateVar = this._stateVar;
+ Set encodedIds = getEncodedIds();
+ // Save all states of component and data model for all valies of
+ // clientId, encoded in this request.
+ for (Iterator iter = this._statesMap.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry stateEntry = (Map.Entry) iter.next();
+ DataComponentState dataComponentState = ((DataComponentState) stateEntry
+ .getValue());
+ Object stateKey = stateEntry.getKey();
+ if (encodedIds.isEmpty() || encodedIds.contains(stateKey)) {
+ PerIdState idState = new PerIdState();
+ idState.model = getExtendedDataModel().getSerializableModel(
+ dataComponentState.getRange());
+ // Save component state , depended if implemented interfaces.
+ if (null == dataComponentState) {
+ idState.componentState = null;
+ } else if (dataComponentState instanceof Serializable) {
+ idState.componentState = dataComponentState;
+ } else if (dataComponentState instanceof StateHolder) {
+ // TODO - change RichFaces Tree component, for remove
+ // reference to component from state.
+ // Change this code to reference for saveAttachedState.
+ idState.componentState = ((StateHolder) dataComponentState)
+ .saveState(faces);
+ idState.stateInHolder = true;
+ }
+ if (null != idState.model || null != idState.componentState) {
+ state.componentStates.put(stateKey, idState);
+ }
+ }
+ }
+ return state;
+ }
+
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/Cache.java (from
rev 1388, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/Cache.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/Cache.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/Cache.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,180 @@
+package org.ajax4jsf.cache;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * <p>
+ * A cache, being a mechanism for efficient temporary storage of objects
+ * for the purpose of improving the overall performance of an application
+ * system, should not be necessary for the application to function correctly,
+ * it only improves the performance.
+ * <p>
+ * A cache could be scoped, for examples to a JVM, all JVMs on a node, all
+ * nodes in a cluster, etc. Operations that are scoped to a cache such as put
+ * or load would affect all JVMs in the cache. So the object loaded in 1 JVM
+ * would be equally available to all other JVMs in the cache.
+ * <p>
+ * Objects are identified in the cache by a key. A key can be any Java
+ * object that implements the equals and hashcode methods. If the object is
+ * to be distributed or persisted (if supported) it must implement
+ * serializable.
+ * <p/>
+ * Each object in the cache will have a <code>CacheEntry<code> object
associated with
+ * it. This object will encapsulate the metadata associated with the cached
+ * object. Mainly it represents the object statistics.
+ * <p/>
+ * "CacheStatistics" represents the read-only statistics of the cache,
+ * while "CacheAttributes" represents the user settable attributes of the
+ * cache.
+ */
+public interface Cache
+{
+ /**
+ * Returns true if the cache contains the specified key. The search is
+ * scoped to the cache. Other caches in the system will not be searched
+ * and a CacheLoader will not be called.
+ * @return true, if the cache contains the specified key.
+ */
+ public boolean containsKey(Object key);
+
+ /**
+ * @return true if the cache contains one or more keys to the specified value.
+ */
+ public boolean containsValue(Object value);
+
+ /**
+ * Returns a set view of the objects currently contained in the cache.
+ * A CacheLoader will not be called. The behavior is unspecified for the
+ * case when an object is remove from the cache while the return set is
+ * being traversed.
+ */
+ public Set entrySet();
+
+ /**
+ * Equality is based on the Set returned by entrySet. Equal will return
+ * true if the two objects are referencing the same object or
+ * entrySet.equals(((Map)o).entrySet()) returns true.
+ */
+ public boolean equals(Object o);
+
+ /**
+ * @param ht a hashtable which holds a pointer pointing to the
+ * declarative cache description.
+ * @throws CacheException if any error occurs.
+ */
+
+ /**
+ * @return the hash code value for this the cache.
+ */
+ public int hashCode();
+
+ /**
+ * @return true if entrySet().isEmpty() returns true.
+ */
+ public boolean isEmpty();
+
+ /**
+ * Returns a set view of the keys currently contained in the cache. A
+ * CacheLoader will not be called. The behavior is unspecified for the
+ * case when an object is remove from the cache while the return set is
+ * being traversed.
+ */
+ public Set keySet();
+
+ /**
+ * Copies all of the mappings from the specified map to the cache. This
+ * would be equivalent to t.entrySet() then iterating through the Set and
+ * calling put with each key value pair.
+ */
+ public void putAll(Map t);
+
+ /**
+ * @return the number of objects in the cache. This should be the same
+ * value as entrySet().size();
+ */
+ public int size();
+
+ /**
+ * @return a collection view of the values contained in the cache.
+ */
+ public Collection values();
+
+ /**
+ * The get method will return, from the cache, the object associated with
+ * the argument "key". If the object is not in the cache, the associated
+ * cache loader will be called. If no loader is associated with the object,
+ * a null is returned. If a problem is encountered during the retrieving
+ * or loading of the object, an exception (to be defined) will be thrown.
+ * If the "arg" argument is set, the arg object will be passed to the
+ * CacheLoader.load method. The cache will not dereference the object.
+ * If no "arg" value is provided a null will be passed to the load method.
+ * The storing of null values in the cache is permitted, however, the get
+ * method will not distinguish returning a null stored in the cache and
+ * not finding the object in the cache. In both cases a null is returned.
+ * @throws CacheException
+ */
+ public Object get(Object key, Object context) throws CacheException;
+
+ /**
+ * The load method provides a means to "pre load" the cache. This method
+ * will, asynchronously, load the specified object into the cache using
+ * the associated cacheloader. If the object already exists in the cache,
+ * no action is taken. If no loader is associated with the object, no object
+ * will be loaded into the cache. If a problem is encountered during the
+ * retrieving or loading of the object, an exception should
+ * be logged.
+ * If the "arg" argument is set, the arg object will be passed to the
+ * CacheLoader.load method. The cache will not dereference the object. If
+ * no "arg" value is provided a null will be passed to the load method.
+ * The storing of null values in the cache is permitted, however, the get
+ * method will not distinguish returning a null stored in the cache and not
+ * finding the object in the cache. In both cases a null is returned.
+ */
+ public void load(Object key, Object context) throws CacheException;
+
+ /**
+ * The peek method will return the object associated with "key" if it
+ * currently exists (and is valid) in the cache. If not, a null is
+ * returned. With "peek" the CacheLoader will not be invoked and other
+ * caches in the system will not be searched.
+ */
+ public Object peek(Object key);
+
+ /**
+ * The put method adds the object "value" to the cache identified by the
+ * object "key".
+ */
+ public Object put(Object key, Object value);
+
+ /**
+ * Returns the CacheEntry object associated with the object identified by
+ * "key". If the object is not in the cache a null is returned.
+ */
+ public CacheEntry getCacheEntry(Object key);
+
+ /**
+ * The remove method will delete the object from the cache including the
+ * key, the associated value and the associated CacheStatistics object.
+ */
+ public Object remove(Object key);
+
+ /**
+ * The clear method will remove all objects from the cache including the
+ * key, the associated value and the associated CacheStatistics object.
+ */
+ public void clear();
+
+ /**
+ * The evict method will remove objects from the cache that are no longer
+ * valid. Objects where the specified expiration time has been reached.
+ */
+ public void evict();
+
+ /** Add a listener to the list of cache listeners */
+ public void addListener(CacheListener listener);
+
+ /** Remove a listener from the list of cache listeners */
+ public void removeListener(CacheListener listener);
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.cache;
+
+import java.util.Properties;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 02.05.2007
+ *
+ */
+public interface CacheConfigurationLoader {
+ public Properties loadProperties(String name);
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheEntry.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheEntry.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheEntry.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheEntry.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,29 @@
+package org.ajax4jsf.cache;
+
+import java.util.Map;
+
+/**
+ * CacheEntry
+ *
+ * @author Brian Goetz
+ */
+public interface CacheEntry extends Map.Entry {
+
+ int getHits();
+
+ long getLastAccessTime();
+ long getLastUpdateTime();
+ long getCreationTime();
+ long getExpirationTime();
+
+ /**
+ * Returns a version counter.
+ * An implementation may use timestamps for this or an incrementing
+ * number. Timestamps usually have issues with granularity and are harder
+ * to use across clusteres or threads, so an incrementing counter is often safer.
+ */
+ long getVersion();
+
+ boolean isValid();
+ long getCost();
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheException.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheException.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheException.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheException.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,43 @@
+package org.ajax4jsf.cache;
+
+
+/**
+ * CacheException is a generic exception, which indicates
+ * a cache error has occurred. All the other cache exceptions are the
+ * subclass of this class. All the methods in the cache package only
+ * throw CacheException or the sub class of it.
+ * <P>
+ *
+ */
+public class CacheException extends Exception
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6712594794189413065L;
+
+ /**
+ * Constructs a new CacheException.
+ */
+ public CacheException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new CacheException with a message string.
+ */
+ public CacheException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Constructs a CacheException with a message string, and
+ * a base exception
+ */
+ public CacheException(String s, Throwable ex)
+ {
+ super(s, ex);
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheFactory.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheFactory.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheFactory.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheFactory.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,22 @@
+package org.ajax4jsf.cache;
+
+import java.util.Map;
+
+/**
+ * CacheFactory is a service provider specific interface.
+ * Service provider should implement CacheFactory to provide
+ * the functionality to create a new implementation specific Cache object.
+ */
+public interface CacheFactory
+{
+ /**
+ * creates a new implementation specific Cache object using the env parameters.
+ * @param env implementation specific environment parameters passed to the
+ * CacheFactory.
+ * @param cacheLoader implementation of the {@link CacheLoader} to use
+ * @param cacheConfigurationloader TODO
+ * @return an implementation specific Cache object.
+ * @throws CacheException if any error occurs.
+ */
+ public Cache createCache(Map env, CacheLoader cacheLoader, CacheConfigurationLoader
cacheConfigurationloader) throws CacheException;
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheListener.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheListener.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,20 @@
+package org.ajax4jsf.cache;
+
+/** Interface describing various events that can happen as elements are added to
+ * or removed from a cache
+ */
+public interface CacheListener {
+ /** Triggered when a cache mapping is created due to the cache loader being consulted
*/
+ public void onLoad(Object key);
+
+ /** Triggered when a cache mapping is created due to calling Cache.put() */
+ public void onPut(Object key);
+
+ /** Triggered when a cache mapping is removed due to eviction */
+ public void onEvict(Object key);
+
+ /** Triggered when a cache mapping is removed due to calling Cache.remove() */
+ public void onRemove(Object key);
+
+ public void onClear();
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheLoader.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheLoader.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheLoader.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/cache/CacheLoader.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,24 @@
+package org.ajax4jsf.cache;
+
+
+/**
+ * User should implement this CacheLoader interface to
+ * provide a loader object to load the objects into cache.
+ */
+public interface CacheLoader
+{
+ /**
+ * loads an object. Application writers should implement this
+ * method to customize the loading of cache object. This method is called
+ * by the caching service when the requested object is not in the cache.
+ * <P>
+ *
+ * @param key the key identifying the object being loaded
+ *
+ * @return The object that is to be stored in the cache.
+ * @throws CacheException
+ *
+ */
+ public Object load(Object key, Object context) throws CacheException;
+
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd;
+
+import org.ajax4jsf.framework.resource.ClientScript;
+
+/**
+ * @author shura
+ *
+ */
+public class DnDScript extends ClientScript {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.ClientScript#isUsePrototype()
+ */
+ protected boolean isUsePrototype() {
+ return true;
+ }
+
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Draggable.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Draggable.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Draggable.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Draggable.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd;
+
+import javax.faces.el.MethodBinding;
+
+import org.ajax4jsf.dnd.event.DragListener;
+
+
+/**
+ * Interface for all draggable components. Describe bean properties, implemented by
component.
+ * @author shura
+ *
+ */
+public interface Draggable {
+
+ /**
+ * Getter for value parameter, used as key for draggable component.
+ * @return
+ */
+ public Object getDragValue();
+
+ public void setDragValue(Object value);
+
+ /**
+ * Getter for id of component ( instance of {@link UIDragIndicator} ) used for create
drag cursor.
+ * @return
+ */
+ public String getDragIndicator();
+
+ /**
+ * @param dragIndicator - id of cursor component
+ */
+ public void setDragIndicator(String dragIndicator);
+
+
+ /**
+ * Getter for type of this draggable ( file, mail etc ).
+ * @return
+ */
+ public String getDragType();
+
+ /**
+ * @param dragType
+ */
+ public void setDragType(String dragType);
+
+ /**
+ * Getter for JavaScript event handler, called before start drag operation.
+ * If this handler return false, drag operation is cancelled.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragstart();
+
+ /**
+ * @param dragType
+ */
+ public void setOndragstart(String ondrag);
+
+ /**
+ *
+ * @return
+ */
+ public String getOndragend();
+ public void setOndragend(String ondrag);
+
+
+ /**
+ * Append drag listener to component listeners collection
+ * @param listener
+ */
+ public void addDragListener(DragListener listener);
+
+ /**
+ * Get array of all Drop Listeners
+ * @return
+ */
+ public DragListener[] getDragListeners();
+
+ /**
+ * Remove drop listener from component listeners array.
+ * @param listener
+ */
+ public void removeDragListener(DragListener listener);
+
+ public void setDragListener(MethodBinding binding);
+ public MethodBinding getDragListener();
+
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Dropzone.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Dropzone.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Dropzone.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/Dropzone.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,101 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd;
+
+import org.ajax4jsf.dnd.event.DropSource;
+
+/**
+ * Base interface for all components, accesible as drop zone.
+ * @author shura
+ *
+ */
+public interface Dropzone extends DropSource {
+
+ /**
+ * Getter for dropType's , accepted by this zone.
+ * @return
+ */
+ public Object getAcceptedTypes();
+
+ public void setAcceptedTypes(Object types);
+
+ /**
+ * Getter for mapping between drop types and indicator states.
+ * @return
+ */
+ public Object getTypeMapping();
+
+ public void setTypeMapping(Object types);
+ /**
+ * Getter for JavaScript event handler, called then drag curcor enter in component
area.
+ * If this handler return false, or "declined", drop operation on this
component not allowed.
+ * If handler return true or "allowed" , or any other supported indicator
states, drop operation
+ * is allowed and corresponding indicator state will be displayed.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragenter();
+
+ /**
+ * @param dragType
+ */
+ public void setOndragenter(String ondrag);
+
+ /**
+ * Getter for JavaScript event handler, called before drag cursor leave component
area.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragexit();
+
+ /**
+ * @param dragType
+ */
+ public void setOndragexit(String ondrag);
+
+ public Object getDropValue();
+
+ public void setDropValue(Object o);
+
+ /**
+ * Javascript code called before drop event.
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getOndrop();
+
+ /**
+ * @param newOndrop the value to set
+ */
+ public abstract void setOndrop(String newOndrop);
+
+ /**
+ * Javascript handler for event fired on drop even the drop for given type is not
available
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getOndropend();
+
+ /**
+ * @param newname the value to set
+ */
+ public abstract void setOndropend(String ondropend);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,103 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.ajax4jsf.dnd.Draggable;
+import org.ajax4jsf.dnd.Dropzone;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.12.2006
+ *
+ */
+public class DragEvent extends FacesEvent {
+
+ private Dropzone dropTarget;
+ private Object acceptedTypes;
+ private Object dropValue;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6179268394391836905L;
+
+ public DragEvent(UIComponent uiComponent) {
+ super(uiComponent);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener faceslistener) {
+ return faceslistener instanceof DragListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener faceslistener) {
+ ((DragListener) faceslistener).processDrag(this);
+ }
+
+ public Object getDragValue() {
+ return ((Draggable) this.getSource()).getDragValue();
+ }
+
+ public Dropzone getDropTarget() {
+ return dropTarget;
+ }
+
+ /**
+ * @see java.util.EventObject#toString()
+ */
+/* public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
+ append("component", getComponent()).append("source",
getSource()).append("phaseId", getPhaseId()).
+ append("dragValue", getDragValue()).
+ append("dropTarget", getDropTarget()).
+ append("dropValue", getDropValue()).
+ toString();
+ }
+*/
+ public void setDropTarget(Dropzone dropTarget) {
+ this.dropTarget = dropTarget;
+ }
+
+ public Object getAcceptedTypes() {
+ return acceptedTypes;
+ }
+
+ public void setAcceptedTypes(Object acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
+
+ public Object getDropValue() {
+ return dropValue;
+ }
+
+ public void setDropValue(Object dropValue) {
+ this.dropValue = dropValue;
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragListener.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DragListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.12.2006
+ *
+ */
+public interface DragListener extends FacesListener {
+ public void processDrag(DragEvent event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,113 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.ajax4jsf.dnd.Draggable;
+import org.ajax4jsf.dnd.Dropzone;
+
+/**
+ * @author shura
+ *
+ */
+public class DropEvent extends FacesEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1660545054556302746L;
+
+ private Draggable draggableSource;
+ private String dragType;
+ private Object dragValue;
+
+ public DropEvent(UIComponent component) {
+ super(component);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+
+ return listener instanceof DropListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ if (listener instanceof DropListener) {
+ DropListener dropListener = (DropListener) listener;
+ dropListener.processDrop(this);
+ }
+
+ }
+
+ /**
+ * @return the dropValue
+ */
+ public Object getDropValue() {
+ return ((Dropzone) this.getSource()).getDropValue();
+ }
+
+ public Draggable getDraggableSource() {
+ return draggableSource;
+ }
+
+ /**
+ * @see java.util.EventObject#toString()
+ */
+/* public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
+ append("component", getComponent()).
+ append("source", getSource()).
+ append("phaseId", getPhaseId()).
+ append("dropValue", getDropValue()).
+ append("draggableSource", getDraggableSource()).
+ append("dragValue", getDragValue()).
+ toString();
+ }
+*/
+ public void setDraggableSource(Draggable draggableSource) {
+ this.draggableSource = draggableSource;
+ }
+
+ public String getDragType() {
+ return dragType;
+ }
+
+ public void setDragType(String dragType) {
+ this.dragType = dragType;
+ }
+
+ public Object getDragValue() {
+ return dragValue;
+ }
+
+ public void setDragValue(Object dragValue) {
+ this.dragValue = dragValue;
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListener.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * Listener for process Drop events
+ * @author shura
+ *
+ */
+public interface DropListener extends FacesListener {
+
+ /**
+ * Process event on Drop for this component.
+ * @param event
+ */
+ public void processDrop(DropEvent event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,104 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd.event;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+/**
+ * Wrapper for bind DrolListener to EL expression.
+ * @author shura
+ *
+ */
+public class DropListenerBinding implements DropListener, StateHolder {
+
+ private ValueBinding _binding;
+
+ private String _dragType;
+
+ private ValueBinding _dragTypeBinding;
+
+ private boolean _transient = false;
+
+ public DropListenerBinding() {
+ }
+
+ /**
+ * @param binding
+ */
+ public DropListenerBinding(ValueBinding binding) {
+ super();
+ _binding = binding;
+ }
+
+ private DropListener getHandler(FacesContext context) {
+ return (DropListener) _binding.getValue(context);
+ }
+
+ public void processDrop(DropEvent event) {
+ DropListener handler = getHandler(FacesContext.getCurrentInstance());
+ handler.processDrop(event);
+ }
+
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return _transient;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ _binding = (ValueBinding) UIComponentBase.restoreAttachedState(context, state);
+
+ }
+
+ public Object saveState(FacesContext context) {
+ return UIComponentBase.saveAttachedState(context, _binding);
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ _transient = newTransientValue;
+
+ }
+
+ /**
+ * @return the dragType
+ */
+ public String getDragType() {
+ return _dragType;
+ }
+
+ /**
+ * @param dragType the dragType to set
+ */
+ public void setDragType(String dragType) {
+ _dragType = dragType;
+ }
+
+ /**
+ * @param dragTypeBinding the dragTypeBinding to set
+ */
+ public void setDragTypeBinding(ValueBinding dragTypeBinding) {
+ _dragTypeBinding = dragTypeBinding;
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropSource.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropSource.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropSource.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/event/DropSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd.event;
+
+import javax.faces.el.MethodBinding;
+
+/**
+ * Interface for component applicable to process drag/drop events.
+ * @author shura
+ *
+ */
+public interface DropSource {
+
+ /**
+ * Append drop listener to component listeners collection
+ * @param listener
+ */
+ public void addDropListener(DropListener listener);
+
+ /**
+ * Get array of all Drop Listeners
+ * @return
+ */
+ public DropListener[] getDropListeners();
+
+ /**
+ * Remove drop listener from component listeners array.
+ * @param listener
+ */
+ public void removeDropListener(DropListener listener);
+
+ public void setDropListener(MethodBinding binding);
+ public MethodBinding getDropListener();
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,172 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Locale;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base wrapper for {@link javax.faces.application.ViewHandler} . By default, delegate
all
+ * method calls to wrapped handler.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:12 $
+ *
+ */
+public class ViewHandlerWrapper extends ViewHandler {
+ private static final String HANDLERS = "org.ajax4jsf.VIEW_HANDLERS";
+
+ private static final Log _log = LogFactory.getLog(ViewHandlerWrapper.class);
+
+ /**
+ * Wrapped ViewHandler
+ */
+ protected ViewHandler _handler;
+
+ private boolean _initialized = false;
+
+ /**
+ * @param handler - to wrap.
+ */
+ public ViewHandlerWrapper(ViewHandler handler) {
+ _handler = handler;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.application.ViewHandler#calculateLocale(javax.faces.context.FacesContext)
+ */
+ public Locale calculateLocale(FacesContext context) {
+ fillChain(context);
+ return _handler.calculateLocale(context);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.application.ViewHandler#calculateRenderKitId(javax.faces.context.FacesContext)
+ */
+ public String calculateRenderKitId(FacesContext context) {
+ fillChain(context);
+ return _handler.calculateRenderKitId(context);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.application.ViewHandler#createView(javax.faces.context.FacesContext,
java.lang.String)
+ */
+ public UIViewRoot createView(FacesContext context, String viewId) {
+ fillChain(context);
+ return _handler.createView(context, viewId);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.application.ViewHandler#getActionURL(javax.faces.context.FacesContext,
java.lang.String)
+ */
+ public String getActionURL(FacesContext context, String url) {
+ fillChain(context);
+ return _handler.getActionURL(context, url);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.application.ViewHandler#getResourceURL(javax.faces.context.FacesContext,
java.lang.String)
+ */
+ public String getResourceURL(FacesContext context, String url) {
+ fillChain(context);
+ return _handler.getResourceURL(context, url);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.application.ViewHandler#renderView(javax.faces.context.FacesContext,
javax.faces.component.UIViewRoot)
+ */
+ public void renderView(FacesContext context, UIViewRoot root) throws IOException,
FacesException {
+ fillChain(context);
+ _handler.renderView(context, root);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.application.ViewHandler#restoreView(javax.faces.context.FacesContext,
java.lang.String)
+ */
+ public UIViewRoot restoreView(FacesContext context, String viewId) {
+ fillChain(context);
+ return _handler.restoreView(context, viewId);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.application.ViewHandler#writeState(javax.faces.context.FacesContext)
+ */
+ public void writeState(FacesContext context) throws IOException {
+ fillChain(context);
+ _handler.writeState(context);
+ }
+
+ /**
+ * @return Returns the handler.
+ */
+ protected ViewHandler getHandler() {
+ return _handler;
+ }
+
+ /**
+ * Fill view-handlers chain for alternate handlers.
+ * @param context
+ */
+ synchronized protected void fillChain( FacesContext context){
+ if(!_initialized){
+ _initialized = true;
+ String handlers = context.getExternalContext().getInitParameter(HANDLERS);
+ if(null != handlers){
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ String[] classes = handlers.split(",");
+ for (int i = 0; i < classes.length; i++) {
+ String handlerClass = classes[i];
+ if (_log.isDebugEnabled()) {
+ _log.debug(Messages.getMessage(Messages.CREATE_ALTERNATE_HANDLER, handlerClass));
+ }
+ try {
+ Class clazz = classLoader.loadClass(handlerClass);
+ try {
+ Constructor constructor = clazz
+ .getConstructor(new Class[] { ViewHandler.class });
+ _handler = (ViewHandler) constructor
+ .newInstance(new Object[] { _handler });
+ } catch (NoSuchMethodException e) {
+ // No constructor with parent class - create simple instance
+ if (_log.isWarnEnabled()) {
+ _log.warn(Messages.getMessage(Messages.ALTERNATE_HANDLER_CONSTRUCTOR_WARNING));
+ }
+ _handler = (ViewHandler) clazz.newInstance();
+ }
+ } catch (Exception e) {
+ _log.error(Messages.getMessage(Messages.VIEW_HANDLER_INSTANTIATION_ERROR), e);
+ }
+ }
+ }
+ }
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,155 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:21 $
+ *
+ */
+public abstract class AjaxActionComponent extends UICommand implements
+ AjaxComponent, AjaxSource {
+
+ public static final String FOCUS_DATA_ID = "_A4J.AJAX.focus";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // Hack - throw exception to AjaxViewRoot, to fix state of all iterable components.
+ if (event instanceof AjaxSingleEvent) {
+ throw new AjaxSingleException(getSingleComponent());
+ }
+ // perform default
+ super.broadcast(event);
+ if (event instanceof AjaxEvent) {
+ FacesContext context = getFacesContext();
+ // complete re-Render fields. AjaxEvent deliver before render
+ // response.
+ setupReRender(context);
+ // Put data for send in response
+ Object data = getData();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (null != data) {
+ ajaxContext.setResponseData(data);
+ }
+ String focus = getFocus();
+ if (null != focus) {
+ // search for component in tree.
+ // TODO - use more pourful search, as in h:outputLabel component.
+ UIComponent focusComponent = findComponent(focus);
+ if(null != focusComponent){
+ focus = focusComponent.getClientId(context);
+ }
+ ajaxContext.getResponseDataMap().put(FOCUS_DATA_ID, focus);
+ }
+ }
+ }
+
+ /**
+ * Template method with old signature, for backward compability.
+ */
+ protected void setupReRender() {
+ }
+
+ /**
+ * Template methods for fill set of resions to render in subclasses.
+ *
+ * @param facesContext
+ * TODO
+ */
+ protected void setupReRender(FacesContext facesContext) {
+ AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(
+ this);
+ setupReRender();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ if (event instanceof ActionEvent && event.getComponent() == this) {
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else if (isBypassUpdates()) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ getParent().queueEvent(event);
+ if(isAjaxSingle()){
+ super.queueEvent(new AjaxSingleEvent(this));
+ }
+ } else {
+ super.queueEvent(event);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
+ */
+ public AjaxListener[] getAjaxListeners() {
+ AjaxListener al[] = (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ return (al);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ protected UIComponent getSingleComponent(){
+ return this;
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:34 $
+ *
+ */
+public class AjaxActionEvent extends ActionEvent {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5406101936114574903L;
+
+ /**
+ * @param component
+ */
+ public AjaxActionEvent(UIComponent component) {
+ super(component);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Marker interface for components, have ability to manipulate rendering in case of Ajax
responses.
+ * Such as ajax-enabled iterator, menus etc
+ * @author shura
+ *
+ */
+public interface AjaxChildrenEncoder {
+
+ /**
+ * Iterate over all childs of components. If component id contains in list ,
+ * or, if list is empty, compotents is submitted form - render it.
+ * TODO - Instead of calculate full path for every component, build current Path
+ * for componet and send as parameter.
+ *
+ * @param context -
+ * current context
+ * @param component -
+ * curent faces component.
+ * @param ids -
+ * list of Id to render.
+ * @throws IOException
+ */
+ public void encodeAjaxChild(FacesContext context,
+ String path,Set ids,Set renderedAreas) throws IOException ;
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,194 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+
+/**
+ * Base Interface for Ajax-enabled acting components.
+ * TODO - extend <code>ActionSource</code>???
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:01 $
+ *
+ */
+public interface AjaxComponent
+{
+
+ public static final String AJAX_COMPONETT_PARAMETER =
AjaxComponent.class.getName()+".parameter";
+
+ /**
+ * setter method for property
+ * @param new value of String, <code>Collection</code> or array of
component's Id , updated in case of Ajax request by parent component. to set
+ */
+ public abstract void setReRender(Object targetId);
+
+ /**
+ * @return value or result of valueBinding of String,
<code>Collection</code> or array of component's Id , updated in case of
Ajax request by parent component.
+ */
+ public abstract Object getReRender();
+
+ /**
+ * setter method for property
+ * @param new value of ajaxType of control component - link or input to set
+ */
+// public abstract void setAjaxType(String ajaxType);
+
+ /**
+ * @return value or result of valueBinding of ajaxType of control component - link or
input
+ */
+// public abstract String getAjaxType();
+
+ /**
+ * setter method for property
+ * @param new value of Id ( in format of UIComponent.findComponent() call ) of
request status indicator to set
+ */
+ public abstract void setStatus(String status);
+
+ /**
+ * @return value or result of valueBinding of Id ( in format of
UIComponent.findComponent() call ) of request status indicator
+ */
+ public abstract String getStatus();
+
+ /**
+ * setter method for property
+ * @param new value of Name of JavaScript function, called on complete Ajax request
to set
+ */
+ public abstract void setOncomplete(String oncomplete);
+
+ /**
+ * @return value or result of valueBinding of Name of JavaScript function, called on
complete Ajax request
+ */
+ public abstract String getOncomplete();
+
+ /**
+ * setter method for property
+ * @param new value of custom data translated to oncomplete function by AJAX
+ */
+ public abstract void setData(Object data);
+
+ /**
+ * @return value of custom data for translate to oncomplete function by AJAX
+ */
+ public abstract Object getData();
+
+ /**
+ * setter method for property
+ * @param new value of Submit ( or not ) full form on Ajax action. to set
+ */
+ public abstract void setLimitToList(boolean submitForm);
+
+ /**
+ * @return value or result of valueBinding of Submit ( or not ) full form on Ajax
action.
+ */
+ public abstract boolean isLimitToList();
+
+ /**
+ * setter method for property
+ * @param new value of Submit ( or not ) full form on Ajax action. to set
+ */
+ public abstract void setAjaxSingle(boolean single);
+
+ /**
+ * @return value or result of valueBinding of Submit ( or not ) full form on Ajax
action.
+ */
+ public abstract boolean isAjaxSingle();
+
+ /**
+ * Getter for bypassUpdates bean property. Indicate that component must invoke
listeners after Process Validators phase
+ * and force render response after it - since no values of components will be
updated. Can be used to perform validation of client input
+ * using server-side validators.
+ * @return true if component must force render after validation phase.
+ */
+ public abstract boolean isBypassUpdates();
+
+ /**
+ * Setter for bypassUpdates bean property.
+ * @param bypass true if component must force render after validation phase.
+ */
+ public abstract void setBypassUpdates(boolean bypass);
+
+ /**
+ * Getter for property name of events queue on client side - for avoid to send requests
too frequnly ( on key events, for example ), implementation will be generated by
+ * componnents-generator
+ * @return property value
+ */
+ public abstract String getEventsQueue();
+
+ /**
+ * Setter for flag indicated aborting unfinished ajax requests in queue.
+ * @param newvalue - new property value. If true, unfinished request in queue will be
aborted on new events.
+ */
+ public abstract void setIgnoreDupResponses(boolean newvalue);
+
+
+ /**
+ * Getter for property flag indicated aborting unfinished ajax requests in queue.
+ * componnents-generator
+ * @return property value
+ */
+ public abstract boolean isIgnoreDupResponses();
+
+ /**
+ * Setter for property name of events queue on client side - for avoid to send requests
too frequnly ( on key events, for example ), implementation will be generated by
+ * componnents-generator
+ * @param newvalue - new property value
+ */
+ public abstract void setEventsQueue(String newvalue);
+
+ /**
+ * Getter for property Delay ( in ms. ) for send ajax request on JavaScript event. In
conjunction with events queue can reduce number of requests on keyboard or mouse move
events., implementation will be generated by
+ * componnents-generator
+ * @return property value
+ */
+ public abstract int getRequestDelay();
+
+ /**
+ * Setter for property Delay ( in ms. ) for send ajax request on JavaScript event. In
conjunction with events queue can reduce number of requests on keyboard or mouse move
events., implementation will be generated by
+ * componnents-generator
+ * @param newvalue - new property value
+ */
+ public abstract void setRequestDelay(int newvalue);
+
+ /**
+ * Getter for request timeout
+ * @return timeout in ms.
+ */
+ public abstract int getTimeout();
+
+ /**
+ * Setter for request timeout
+ * @param timeout new value in ms.
+ */
+ public abstract void setTimeout(int timeout);
+
+
+ /**
+ * Setter for a 'focus' bean property - id of component( or of DOM element ), to
set focus after AJAX request.
+ * @param focus
+ */
+ public abstract void setFocus(String focus);
+
+ /**
+ * @return
+ */
+ public abstract String getFocus();
+
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+
+/**
+ * Extend Ajax-enabled region to support event listeners on Ajax requests.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:39 $
+ *
+ */
+public interface AjaxContainer extends AjaxContainerBase, AjaxSource
+{
+
+ /**
+ * Is ajax container must re-render all output from page or only it's children ?
+ * @return true if all ajax-enabled to re-render araes on page must be checked for
output.
+ */
+ public abstract boolean isRenderRegionOnly();
+
+ public abstract void setRenderRegionOnly(boolean reRenderPage);
+
+ /**
+ * Encode AJAX response from this container ( call encode methods for selected
components only )
+ * @param context
+ * @throws IOException
+ */
+ public void encodeAjax(FacesContext context) throws IOException ;
+
+
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,94 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.util.Collection;
+import java.util.Set;
+
+import javax.faces.el.MethodBinding;
+
+/**
+ * Base interface for controller component, managed AJAX Requests.
+ * Component, implemented this interface, must always return
<code>true</code> for
+ * <code>javax.faces.component.UIComponent#getRendersChildren()</code>
method.
+ * in common, set of components, rendered of current request, maintain by it.
+ * TODO - add capabilites for components, rendered in
<code>PhaseListener</code>
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/06 16:23:20 $
+ *
+ */
+public interface AjaxContainerBase {
+ /**
+ * getter for AjaxListener method. Same as for <code>ActionSource</code>
+ *
+ * @see javax.faces.component.ActionSource#getActionListener()
+ */
+ public MethodBinding getAjaxListener();
+
+ /**
+ * setter for AjaxListener <code>MethodBinding</code>
+ * in case on AjaxRequest, component must call this method in
+ * <code>PhaseId.APPLY_REQUEST_VALUES</code> or
+ * <code>PhaseId.INVOKE_APPLICATION</code> phases, depend on immediate
flag.
+ *
+ * @see
javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setAjaxListener(MethodBinding AjaxListener);
+
+ /**
+ * getter for flag immediate call Listener's on PhaseId.APPLY_REQUEST_VALUES
phase.
+ *
+ * @see javax.faces.component.ActionSource#isImmediate()
+ */
+ public boolean isImmediate();
+
+ /**
+ * getter for render method flag of subview. If true, on AJAX-request component
render it children
+ * after {@link com.sun.faces.lifecycle.Phase.INVOKE_APPLICATION }
+ * @return value of selfRendered flag
+ */
+ public boolean isSelfRendered();
+
+ /**
+ * setter for self-render flag.
+ * @param selfRendered
+ */
+ public void setSelfRendered(boolean selfRendered);
+ /**
+ * setter for immediate flag.
+ *
+ * @see javax.faces.component.ActionSource#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate);
+
+ public boolean isSubmitted();
+
+ public void setSubmitted(boolean submitted);
+
+ /**
+ * Render AJAX response for this container from stored View.
+ * @param context
+ * @throws FacesException
+ */
+// public void renderAjaxRegion(FacesContext context) throws FacesException ;
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,806 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.skin.SkinFactory;
+import org.ajax4jsf.framework.skin.SkinNotFoundException;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class incapsulated
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+public class AjaxContext {
+ /**
+ * Key for keep request state information in request-scope attributes.
+ */
+ public static final String AJAX_CONTEXT_KEY = "ajaxContext";
+
+ public static final String SCRIPTS_PARAMETER =
"org.ajax4jsf.framework.HEADER_SCRIPTS";
+
+ public static final String STYLES_PARAMETER =
"org.ajax4jsf.framework.HEADER_STYLES";
+
+ public static final String RESOURCES_PROCESSED =
"org.ajax4jsf.framework.HEADER_PROCESSED";
+
+ public static final String RESPONSE_DATA_KEY = "_ajax:data";
+
+ private static final Log log = LogFactory.getLog(AjaxContext.class);
+
+ private static ComponentInvoker invoker;
+
+ private static Map contextClasses = new HashMap();
+
+ Set ajaxAreasToRender = new HashSet();
+
+ Set ajaxRenderedAreas = new HashSet();
+
+ boolean ajaxRequest = false;
+
+ boolean ajaxRequestSet = false;
+
+ boolean selfRender = false;
+
+ Integer viewSequence = new Integer(1);
+
+ String submittedRegionClientId = null;
+
+ boolean submittedRegionSet = false;
+
+ ViewIdHolder viewIdHolder = null;
+
+ Map responseDataMap = new HashMap();
+
+ Map commonAjaxParameters = new HashMap();
+
+ static {
+ try {
+ // Attempt to create JSF1.2 specific invoker.
+ invoker = new JsfOneOneInvoker();
+ } catch (Exception e) {
+ invoker = new JsfOneOneInvoker();
+ }
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @return memento instance for current request
+ */
+ public static AjaxContext getCurrentInstance() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ return getCurrentInstance(context);
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @param context
+ * current FacesContext
+ * @return instance of AjaxContext.
+ */
+ public static AjaxContext getCurrentInstance(FacesContext context) {
+ if (null == context) {
+ throw new NullPointerException("FacesContext is null");
+ }
+ AjaxContext ajaxContext = (AjaxContext) context.getApplication()
+ .getVariableResolver().resolveVariable(context,
+ AJAX_CONTEXT_KEY);
+ if (null == ajaxContext) {
+ // Create default implementation.
+ ajaxContext = new AjaxContext();
+ context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
+ ajaxContext);
+ }
+ return ajaxContext;
+ }
+
+ /**
+ * @param root
+ * @param context
+ * @param callback
+ * @param regionId
+ * @return
+ * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
+ */
+ public static boolean invokeOnComponent(UIComponent root,
+ FacesContext context, InvokerCallback callback, String regionId) {
+ return invoker.invokeOnComponent(root, context, callback, regionId);
+ }
+
+ /**
+ * @param viewRoot
+ * @param context
+ * @param callback
+ * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback)
+ */
+ public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
+ FacesContext context, InvokerCallback callback) {
+ invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
+ }
+
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ renderAjaxRegion(context, component, true);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+
+ };
+
+ public void renderSubmittedAjaxRegion(FacesContext context) {
+ renderSubmittedAjaxRegion(context, true);
+ }
+
+ public void renderSubmittedAjaxRegion(FacesContext context,
+ final boolean useFilterWriter) {
+ InvokerCallback ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ renderAjaxRegion(context, component, useFilterWriter);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+
+ };
+ if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
+ getSubmittedRegionClientId(context))) {
+ renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
+ }
+
+ }
+
+ /**
+ * @param context
+ * @param useFilterWriter
+ * TODO
+ * @throws AbortProcessingException
+ */
+ public void renderAjaxRegion(FacesContext context, UIComponent component,
+ boolean useFilterWriter) throws FacesException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
+ component.getId()));
+ }
+ try {
+ setSelfRender(true);
+ // create response writer.
+ ExternalContext extContext = context.getExternalContext();
+ RenderKit renderKit = context.getRenderKit();
+ String encoding;
+ // Depends if we talk about servlets, portlets, ...
+ if (extContext.getRequest() instanceof ServletRequest) {
+ ServletRequest request = (ServletRequest) extContext
+ .getRequest();
+ ServletResponse response = (ServletResponse) extContext
+ .getResponse();
+ // HACK - bypass MyFaces ( and other ) extensions filter.
+
+ // Setup encoding and content type
+ String contentType = "text/xml";
+ // get the encoding - must be setup by faces context or filter.
+ encoding = request.getCharacterEncoding();
+ if (encoding == null) {
+ encoding = "UTF-8";
+ }
+ response.setContentType(contentType + ";charset=" + encoding);
+ } else
+ encoding = "UTF-8";
+
+ PrintWriter servletWriter;
+ if (useFilterWriter
+ && extContext.getRequestMap().containsKey(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ // HACK - Special case for MyFaces, since <f:view don't call
+ // encode methods,
+ // encode response as for self-rendered region directly to
+ // filter response wrpper.
+ // to avoid exceptions, inform wrapper to ignore illegal states
+ // for getWriter/Stream.
+ ServletResponse servletResponse = (ServletResponse) extContext
+ .getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
+ servletResponse.resetBuffer();
+ servletWriter = servletResponse.getWriter();
+ ((FilterServletResponseWrapper) servletResponse)
+ .setUseNullStream(true);
+ } else {
+ servletWriter = getWriter(extContext);
+ }
+ ResponseWriter writer = renderKit.createResponseWriter(
+ servletWriter, null, encoding);
+ context.setResponseWriter(writer);
+ // make response
+ writer.startDocument();
+ encodeAjaxBegin(context, component);
+ component.encodeBegin(context);
+ ((AjaxContainer) component).encodeAjax(context);
+ component.encodeEnd(context);
+ saveViewState(context);
+ encodeAjaxEnd(context, component);
+ writer.endDocument();
+ writer.flush();
+ writer.close();
+ servletWriter.close();
+ // Save tree state.
+ } catch (IOException e) {
+ throw new FacesException(Messages.getMessage(
+ Messages.RENDERING_AJAX_REGION_ERROR, component
+ .getClientId(context)), e);
+ } finally {
+ context.responseComplete();
+ // component.setRendererType(defaultRenderer);
+ }
+ }
+
+ /**
+ * Encode declaration for AJAX response. Render
<html><body>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.startElement(HTML.HTML_ELEMENT, component);
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ out.startElement(HTML.BODY_ELEMENT, component);
+ }
+
+ /**
+ * End encoding of AJAX response. Render tag with included areas and
+ * close </body></html>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.endElement(HTML.BODY_ELEMENT);
+ out.endElement(HTML.HTML_ELEMENT);
+ }
+
+ /**
+ * @param context
+ * @param root
+ * @throws FacesException
+ */
+ public void processHeadResources(FacesContext context)
+ throws FacesException {
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
+ if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Process component tree for collect used scripts and styles");
+ }
+ UIViewRoot root = context.getViewRoot();
+ Set scripts = new LinkedHashSet();
+ Set styles = new LinkedHashSet();
+ RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = rkFactory.getRenderKit(context, context
+ .getViewRoot().getRenderKitId());
+ processHeadResources(context, root, scripts, styles, renderKit);
+ if (scripts.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Scripts for insert into head : \n");
+ for (Iterator iter = scripts.iterator(); iter.hasNext();) {
+ String script = (String) iter.next();
+ buff.append(script).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(SCRIPTS_PARAMETER, scripts);
+ }
+ // Set default style sheet for current skin.
+ String styleSheetUri = null;
+ try {
+ styleSheetUri = (String) SkinFactory.getInstance().getSkin(
+ context).getParameter(context,
+ Skin.generalStyleSheet);
+ } catch (SkinNotFoundException e) {
+ log.warn("Current Skin is not found", e);
+ }
+ if (null != styleSheetUri) {
+ String resourceURL = context.getApplication()
+ .getViewHandler().getResourceURL(context,
+ styleSheetUri);
+ // TODO - some resources can be non-session aware, we
+ // must
+ // skip encoding for this case ?
+ // But, in common case - static links not need session
+ // info,
+ // and dynamic resources perform encodings if nessesary
+ // resourceURL =
+ // context.getExternalContext().encodeResourceURL(resourceURL);
+ styles.add(resourceURL);
+ }
+ if (styles.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Styles for insert into head : \n");
+ for (Iterator iter = styles.iterator(); iter.hasNext();) {
+ String style = (String) iter.next();
+ buff.append(style).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(STYLES_PARAMETER, styles);
+ }
+ // Mark as processed.
+ requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
+ }
+
+ }
+ }
+
+ /**
+ * Append nessesary scripts and styles from component ( if renderer
+ * implements {@link HeaderResourceProducer}) and recursive process all
+ * facets and childrens.
+ *
+ * @param context
+ * TODO
+ * @param root
+ * @param scripts
+ * @param styles
+ * @param renderKit
+ * TODO
+ */
+ private void processHeadResources(FacesContext context, UIComponent root,
+ Set scripts, Set styles, RenderKit renderKit) {
+ Renderer renderer = getRenderer(context, root, renderKit);
+ if (null != renderer) {
+ if (renderer instanceof HeaderResourceProducer) {
+ HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
+ Set set = producer.getHeaderScripts(context, root);
+ if (null != set) {
+ scripts.addAll(set);
+ }
+ set = producer.getHeaderStyles(context, root);
+ if (null != set) {
+ styles.addAll(set);
+ }
+ }
+ }
+ for (Iterator iter = root.getFacets().values().iterator(); iter
+ .hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ }
+
+ /**
+ * Find renderer for given component.
+ *
+ * @param context
+ * @param comp
+ * @param renderKit
+ * @return
+ */
+ private Renderer getRenderer(FacesContext context, UIComponent comp,
+ RenderKit renderKit) {
+
+ String rendererType = comp.getRendererType();
+ if (rendererType != null) {
+ return (renderKit.getRenderer(comp.getFamily(), rendererType));
+ } else {
+ return (null);
+ }
+
+ }
+
+ public void saveViewState(FacesContext context) throws IOException {
+ // TODO - for facelets environment, we need to remove transient
+ // components.
+ try {
+ Application.class.getMethod("getExpressionFactory", null);
+ } catch (NoSuchMethodException e) {
+ // JSF 1.1 !
+ }
+ ResponseWriter writer = context.getResponseWriter();
+ StateManager stateManager = context.getApplication().getStateManager();
+ SerializedView serializedView = stateManager
+ .saveSerializedView(context);
+ if (null != serializedView) {
+ StringWriter bufWriter = new StringWriter();
+ ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
+ context.setResponseWriter(cloneWithWriter);
+ stateManager.writeState(context, serializedView);
+ cloneWithWriter.flush();
+ if (bufWriter.getBuffer().length() > 0) {
+ context.getExternalContext().getRequestMap().put(
+ AjaxViewHandler.SERIALIZED_STATE_KEY,
+ bufWriter.toString());
+ }
+ // Restore original writer.
+ context.setResponseWriter(writer);
+ }
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest() {
+ return isAjaxRequest(FacesContext.getCurrentInstance());
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest(FacesContext context) {
+ if (!this.ajaxRequestSet) {
+ ajaxRequest = null != getSubmittedRegionClientId(context);
+ ajaxRequestSet = true;
+ }
+ return ajaxRequest;
+ }
+
+ /**
+ * @param ajaxRequest
+ * The ajaxRequest to set.
+ */
+ public void setAjaxRequest(boolean ajaxRequest) {
+ this.ajaxRequest = ajaxRequest;
+ this.ajaxRequestSet = true;
+ }
+
+ /**
+ * @return Returns the ajaxAreasToRender.
+ */
+ public Set getAjaxAreasToRender() {
+ return this.ajaxAreasToRender;
+ }
+
+ /**
+ * Add affected regions's ID to ajaxView component.
+ *
+ * @param component
+ */
+ public void addRegionsFromComponent(UIComponent component) {
+ // First step - find parent ajax view
+ Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
+ // if (ajaxRegions == null){
+ // FacesContext context = FacesContext.getCurrentInstance();
+ // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
+ // }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
+ component.getId()));
+ }
+ if (ajaxRegions != null) {
+ for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
+ String id = iter.next().toString();
+ ajaxAreasToRender.add(convertId(component, id));
+ }
+ }
+ }
+
+ public void addComponentToAjaxRender(UIComponent component) {
+ this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
+ }
+
+ public void addComponentToAjaxRender(UIComponent base, String id) {
+ this.ajaxAreasToRender.add(convertId(base, id));
+ }
+
+ /**
+ * Test for relative id of target components. Attempt convert to
+ * absolute. For use as argument for
+ * {@link UIComponent#findComponent(java.lang.String)}
+ *
+ * @param component
+ * @param id
+ * @return
+ */
+ private String convertId(UIComponent component, String id) {
+ if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
+ return id;
+ }
+ if (null == component) {
+ throw new NullPointerException(
+ "Base component for search re-rendered compnnent is null");
+ }
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+ while (null == target && null != parent) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+ if (null != target) {
+ return AjaxRendererUtils.getAbsoluteId(target);
+ }
+ log.warn("Target component for id "+id+" not found");
+ return id;
+ }
+
+ private UIComponent findUIComponentBelow(UIComponent root,
+ String id) {
+
+ UIComponent target = null;
+ for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof NamingContainer) {
+ try {
+ target = child.findComponent(id);
+ } catch (IllegalArgumentException iae) {
+ continue;
+ }
+ }
+ if (target == null) {
+ if (child.getChildCount() > 0) {
+ target = findUIComponentBelow(child, id);
+ }
+ }
+
+ if (target != null) {
+ break;
+ }
+
+ }
+ return target;
+ }
+
+ /**
+ * @return Returns the ajaxRenderedAreas.
+ */
+ public Set getAjaxRenderedAreas() {
+ return ajaxRenderedAreas;
+ }
+
+ public void addRenderedArea(String id) {
+ ajaxRenderedAreas.add(id);
+ }
+
+ public boolean removeRenderedArea(String id) {
+ return ajaxRenderedAreas.remove(id);
+ }
+
+ /**
+ * @return Returns the submittedClientId.
+ */
+ public String getSubmittedRegionClientId(FacesContext context) {
+ if (!this.submittedRegionSet) {
+ this.submittedRegionClientId = (String) context
+ .getExternalContext().getRequestParameterMap().get(
+ AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ this.submittedRegionSet = true;
+ if (!this.ajaxRequestSet) {
+ setAjaxRequest(this.submittedRegionClientId != null);
+ }
+ }
+ return this.submittedRegionClientId;
+ }
+
+ /**
+ * @param submittedClientId
+ * The submittedClientId to set.
+ */
+ public void setSubmittedRegionClientId(String submittedClientId) {
+ this.submittedRegionClientId = submittedClientId;
+ this.submittedRegionSet = true;
+ }
+
+ /**
+ * @return Returns the selfRender.
+ */
+ public boolean isSelfRender() {
+ return selfRender;
+ }
+
+ /**
+ * @param selfRender
+ * The selfRender to set.
+ */
+ public void setSelfRender(boolean selfRender) {
+ this.selfRender = selfRender;
+ }
+
+ /**
+ * @return the vievIdHolder
+ */
+ public ViewIdHolder getViewIdHolder() {
+ return viewIdHolder;
+ }
+
+ /**
+ * @param viewIdHolder
+ * the vievIdHolder to set
+ */
+ public void setViewIdHolder(ViewIdHolder viewIdHolder) {
+ this.viewIdHolder = viewIdHolder;
+ }
+
+ /**
+ * @return the responseData
+ */
+ public Object getResponseData() {
+ return responseDataMap.get(RESPONSE_DATA_KEY);
+ }
+
+ /**
+ * @param responseData
+ * the responseData to set
+ */
+ public void setResponseData(Object responseData) {
+ this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
+ }
+
+ /**
+ * @return the responseDataMap
+ */
+ public Map getResponseDataMap() {
+ return responseDataMap;
+ }
+
+ /**
+ * Gives back the writer of a Response object.
+ *
+ * @param extContext
+ * The external context.
+ * @return The writer of the response.
+ * @throws FacesException
+ * If the response object has no getWriter() method.
+ */
+ protected PrintWriter getWriter(ExternalContext extContext)
+ throws FacesException {
+ PrintWriter writer = null;
+ Object response = extContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getWriter", new Class[0]);
+ writer = (PrintWriter) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return writer;
+ }
+
+ public String getAjaxActionURL() {
+ return getAjaxActionURL(FacesContext.getCurrentInstance());
+ }
+
+ public String getAjaxActionURL(FacesContext context) {
+ // Check arguments
+ if (null == context) {
+ throw new NullPointerException(
+ "Faces context for build AJAX Action URL is null");
+ }
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (null == viewRoot) {
+ throw new NullPointerException(
+ "Faces view tree for build AJAX Action URL is null");
+ }
+ String viewId = viewRoot.getViewId();
+ if (null == viewId) {
+ throw new NullPointerException(
+ "View id for build AJAX Action URL is null");
+ }
+ if (!viewId.startsWith("/")) {
+ throw new IllegalArgumentException(
+ "Illegal view Id for build AJAX Action URL: " + viewId);
+ }
+ ViewHandler viewHandler = context.getApplication().getViewHandler();
+ return context.getExternalContext().encodeActionURL(
+ viewHandler.getActionURL(context, viewId));
+ }
+
+ /**
+ * @return the commonAjaxParameters
+ */
+ public Map getCommonAjaxParameters() {
+ return commonAjaxParameters;
+ }
+
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
+ *
+ * Event for send by <code>AjaxContainer</code> in case of Ajax Request.
+ * Used for build set of id's to render at current request, perform special render
etc.
+ */
+public class AjaxEvent extends FacesEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5624716710738446159L;
+
+ /**
+ * @param component
+ */
+ public AjaxEvent(UIComponent component) {
+ super(component);
+ setPhaseId(PhaseId.RENDER_RESPONSE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof AjaxListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((AjaxListener) listener).processAjax(this);
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,40 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * Base interface for all listeners, capable for receive
<code>AjaxEvent</code>
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:36 $
+ */
+public interface AjaxListener extends FacesListener {
+
+ public static final Class[] AJAX_LISTENER_ARGS = { AjaxEvent.class };
+
+ /**
+ * @param event - to process
+ */
+ void processAjax(AjaxEvent event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+/**
+ * Marker interface for all JSF components, encoded ( or not ) on rendering
+ * Ajax request , depend on it self properties ( such as messages, help or like
components )
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:39 $
+ *
+ */
+public interface AjaxOutput {
+ /**
+ * getter for ajax-rendered flag property.
+ * @return
+ */
+ public boolean isAjaxRendered();
+ /**
+ * Setter for ajax rendered property.
+ * @param ajaxRendered
+ */
+ public void setAjaxRendered(boolean ajaxRendered);
+
+ /**
+ * getter for ajax-rendered flag property.
+ * @return
+ */
+ public boolean isKeepTransient();
+ /**
+ * Setter for ajax rendered property.
+ * @param ajaxRendered
+ */
+ public void setKeepTransient(boolean ajaxRendered);
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,65 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:41 $
+ *
+ */
+public class AjaxRenderEvent extends FacesEvent {
+
+ /**
+ * @param component
+ */
+ public AjaxRenderEvent(UIComponent component) {
+ super(component);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ // TODO Auto-generated method stub
+ return listener instanceof AjaxRenderListener;
+ }
+
+ public void processListener(FacesListener listener) {
+ if (listener instanceof AjaxRenderListener) {
+ AjaxRenderListener renderListener = (AjaxRenderListener) listener;
+ renderListener.processAjaxRender(this);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#getPhaseId()
+ */
+// public PhaseId getPhaseId() {
+// // TODO Auto-generated method stub
+// return PhaseId.INVOKE_APPLICATION;
+// }
+
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author shura
+ *
+ */
+public interface AjaxRenderListener extends FacesListener {
+
+ public void processAjaxRender(AjaxRenderEvent event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+/**
+ * Interface for all components capable to process {@link
org.ajax4jsf.framework.ajax.AjaxEvent}'s
+ * @author shura
+ *
+ */
+public interface AjaxSource {
+ /**
+ * same as for ActionSource, but for AjaxListener
+ *
+ * @see
javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addAjaxListener(AjaxListener listener);
+
+ /**
+ * same as for ActionSource, but for AjaxListener
+ *
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public AjaxListener[] getAjaxListeners();
+
+ /**
+ * same as for ActionSource, but for AjaxListener
+ * @see
javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeAjaxListener(AjaxListener listener);
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,71 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Version of {@link org.ajax4jsf.framework.ajax.AjaxComponent} for append
+ * Ajax functions for non-ajax components
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:34 $
+ *
+ */
+public interface AjaxSupport extends AjaxComponent {
+
+ /**
+ * @return JavaScript eventString. Rebuild on every call, since
+ * can be in loop ( as in dataTable ) with different parameters.
+ */
+ public String getEventString();
+ /**
+ * setter method for property
+ * @param new value of Name of event property of parent component for build
JavaScript AJAX.Submit call to set
+ */
+ public abstract void setEvent(String event);
+
+ /**
+ * @return value or result of valueBinding of Name of event property of parent
component for build JavaScript AJAX.Submit call
+ */
+ public abstract String getEvent();
+
+
+ /**
+ * Getter for property If true, disable default action for target event ( encode
'return false' to JavaScript ), implementation will be generated by
+ * componnents-generator
+ * @return property value
+ */
+ public abstract boolean isDisableDefault();
+
+ /**
+ * Setter for property If true, disable default action for target event ( encode
'return false' to JavaScript ), implementation will be generated by
+ * componnents-generator
+ * @param newvalue - new property value
+ */
+ public abstract void setDisableDefault(boolean newvalue);
+
+ /**
+ * Set property for JavaScrept event generated by this component.
+ * @param parent
+ */
+ public void setParentProperties(UIComponent parent);
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.renderer;
+
+import java.util.LinkedHashSet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * Interface for renderers, for wich nessesary insert script or style resource in
header.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
+ *
+ */
+public interface HeaderResourceProducer {
+
+ /**
+ * Return set of strings with URI's of nessesary scripts.
+ * Use linked set to preserve insertion order
+ * @param context - current faces context.
+ * @param component TODO
+ * @return - set of URI's or null
+ */
+ public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component);
+
+ /**
+ * Return set of strings with URI's of nessesary CSS styles.
+ * Use linked set to preserve insertion order.
+ * @param context - current faces context.
+ * @param component TODO
+ * @return - set of URI's or null
+ */
+ public LinkedHashSet getHeaderStyles(FacesContext context, UIComponent component);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,98 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
+ *
+ */
+public abstract class ImageRenderer extends BaseResourceRenderer {
+
+ private static final String _tag = "img";
+ private static final String _hrefAttr = "src";
+ private static final String[][] _commonAttrs = {
+
+ };
+ /**
+ * @return Returns the commonAttrs.
+ */
+ protected String[][] getCommonAttrs() {
+ return null ; //_commonAttrs;
+ }
+
+ /**
+ * @return Returns the hrefAttr.
+ */
+ protected String getHrefAttr() {
+ return _hrefAttr;
+ }
+
+ /**
+ * @return Returns the tag.
+ */
+ protected String getTag() {
+ return _tag;
+ }
+
+ /**
+ * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
+ * @param context - current faces context.
+ * @param image - imaje to send
+ */
+ public abstract void sendImage(ResourceContext context,RenderedImage image) throws
IOException;
+
+ /**
+ * @return type of image for create {@link BufferedImage}
+ */
+ public abstract int getImageType();
+
+ /**
+ * Create blank {@link BufferedImage} for paint.
+ * Type of image determined by current renderer.
+ * @param width
+ * @param height
+ * @return new image
+ */
+ public BufferedImage createImage(int width,int height){
+ return new BufferedImage(width,height,getImageType());
+ }
+
+ protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
+ if (resource instanceof Java2Dresource) {
+ Java2Dresource j2d = (Java2Dresource) resource;
+ Dimension dim = j2d.getDimensions(context, data);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeAttribute("width", String.valueOf(dim.width),
"width");
+ writer.writeAttribute("height", String.valueOf(dim.height),
"height");
+ }
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,192 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Interface for work with off-page internet resources ( images, scripts, styles etc. )
+ * All instances must work in two phases - render page ( application set HTML code and
attributes to reference resource )
+ * and in concrete request to resource body.
+ * For best performance, preffer to realise it as "lightweght" pattern.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:15 $
+ *
+ */
+public interface InternetResource {
+
+ public static final String ENCODE_URI_PARAMETER =
"org.ajax4jsf.ENCRYPT_RESOURCE_DATA";
+ public static final String ENCODE_PASS_PARAMETER =
"org.ajax4jsf.ENCRYPT_PASSWORD";
+ public static final String CODEC_ATTR =
"org.ajax4jsf.framework.resource.CODEC";
+
+ public static final String RESOURCE_PROTOCOL = "resource";
+ public static final String RESOURCE_URI_PREFIX = "resource://";
+ public static final int RESOURCE_URI_PREFIX_LENGTH = RESOURCE_URI_PREFIX.length();
+ public static final String DATA_SEPARATOR = "/DATA/";
+ static public final long DEFAULT_EXPIRE = 1000L * 60L * 60L * 24L;// 1 day
+
+ /**
+ * @param resourceContext current {@link ResourceContext}
+ * @return Returns the contentLength.
+ */
+ public int getContentLength(ResourceContext resourceContext);
+
+ /**
+ * @param resourceContext current {@link ResourceContext}
+ * @return Returns the expired.
+ */
+ public Date getExpired(ResourceContext resourceContext);
+
+ /**
+ * @param resourceContext current {@link ResourceContext}
+ * @return Returns the lastModified.
+ */
+ public Date getLastModified(ResourceContext resourceContext);
+
+ /**
+ * @param resourceContext current {@link ResourceContext}
+ * @return Returns the cacheable.
+ */
+ public boolean isCacheable(ResourceContext resourceContext);
+
+ /**
+ * @param resourceContext current {@link ResourceContext}
+ * @return Returns the mimeType.
+ */
+ public String getContentType(ResourceContext resourceContext);
+
+ /**
+ * @param context TODO
+ * @return input stream with resource
+ */
+ public InputStream getResourceAsStream(ResourceContext context);
+
+ /**
+ * @return string with URI for get resource from page.
+ */
+ public String getUri(FacesContext context, Object data);
+
+
+
+ /**
+ * Encode resource as Markup .
+ * @param context
+ * @param data
+ * @throws IOException
+ */
+ public void encode(FacesContext context, Object data) throws IOException;
+
+ /**
+ * Encode resource as Markup with custom attributes .
+ * @param context
+ * @param data
+ * @param attributes
+ * @throws IOException
+ */
+ public void encode(FacesContext context, Object data,Map attributes) throws
IOException;
+
+ /**
+ * Encode start tag, attributes and body ( for inline script or style )
+ * @param context
+ * @param component
+ * @param attrs
+ * @throws IOException
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs) throws
IOException;
+
+ /**
+ * Encode closed tag.
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeEnd(FacesContext context, Object component) throws IOException;
+
+ /**
+ * Send incapsulated resource to client by {@link ResourceContext} .
+ * @param context
+ */
+ public void send(ResourceContext context) throws IOException;
+
+ /**
+ * Set response headers based on resource properties ( mime type etc )
+ * TODO - send via {@link FacesContext } ???
+ * @param response
+ */
+ public void sendHeaders(ResourceContext response);
+
+ /**
+ * Custom properties for resource ( image size etc. )
+ * @param key
+ * @return property value, or null if not set.
+ */
+ public Object getProperty(Object key);
+
+ /**
+ * Set new value for custom property.
+ * @param key
+ * @param value
+ */
+ void setProperty(Object key,Object value);
+
+
+ /**
+ * Set concrete renderer ( for brige pattern ). In renderer, incapsulate encoding
functions,
+ * content type, resource encoding.
+ * @param renderer
+ */
+ public void setRenderer(ResourceRenderer renderer);
+
+ /**
+ * @return true, if resource must be rendered in faces request cicle.
+ */
+ public boolean requireFacesContext();
+
+ /**
+ * Flag for check session-dependencies for resource. In application-wide case,
+ * resource URL not prepared by
context.getExternalContext().encodeResourceURL(resourceURL)
+ * and used application-wide cache for store.
+ * @return
+ */
+ public boolean isSessionAware();
+
+ void setKey(String key);
+
+ String getKey();
+
+ public abstract ResourceRenderer getRenderer(ResourceContext resourceContext);
+
+ public abstract void setSessionAware(boolean sessionAware);
+
+ public abstract void setCacheable(boolean cacheable);
+
+ public abstract void setLastModified(Date lastModified);
+
+ public abstract void setExpired(Date expired);
+
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,175 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class InternetResourceBuilder {
+
+ private static final Log log = LogFactory.getLog(InternetResourceBuilder.class);
+
+ /**
+ * Get application start time for check resources modification time.
+ *
+ * @return application start time in msec's
+ */
+ public abstract long getStartTime();
+
+ /**
+ * @param cacheable
+ * @param session
+ * @param mime
+ * @return
+ * @throws FacesException
+ */
+ public abstract InternetResource createUserResource(boolean cacheable,
+ boolean session, String mime) throws FacesException;
+
+ /**
+ * @param key
+ * @param resource
+ */
+ public abstract void addResource(String key, InternetResource resource);
+
+ /**
+ * @param path
+ * @return
+ * @throws ResourceNotFoundException
+ */
+ public abstract InternetResource getResource(String path)
+ throws ResourceNotFoundException;
+
+ /**
+ * @param key
+ * @return
+ */
+ public abstract Object getResourceDataForKey(String key);
+
+ /**
+ * @param key
+ * @return
+ * @throws ResourceNotFoundException
+ */
+ public abstract InternetResource getResourceForKey(String key)
+ throws ResourceNotFoundException;
+
+ /**
+ * @param resource
+ * @param context
+ * @param storeData
+ * @return
+ */
+ public abstract String getUri(InternetResource resource,
+ FacesContext context, Object storeData);
+
+ /**
+ * @param base
+ * @param path
+ * @return
+ * @throws FacesException
+ */
+ public abstract InternetResource createResource(Object base, String path)
+ throws FacesException;
+
+ /**
+ * @throws ServletException
+ */
+ public abstract void init()
+ throws FacesException;
+
+ /**
+ * static instance variable.
+ */
+ private static Map instances = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * Get ( or create if nessesary ) instance of builder for current
+ * loader. check content of file
+ * META-INF/services/org.ajax4jsf.framework.resource.InternetResourceBuilder
+ * for name of class to instantiate, othrthise create
+ * {@link ResourceBuilderImpl} instance.
+ *
+ * @return current builder instance.
+ */
+ public static InternetResourceBuilder getInstance() {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InternetResourceBuilder instance = (InternetResourceBuilder) instances
+ .get(loader);
+ if (null == instance) {
+ try {
+ String resource = "META-INF/services/"
+ + InternetResourceBuilder.class.getName();
+ InputStream in = loader.getResourceAsStream(resource);
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(in));
+ String serviceClassName = reader.readLine();
+ reader.close();
+ Class builderClass = loader.loadClass(serviceClassName);
+ instance = (InternetResourceBuilder) builderClass.newInstance();
+ if (log.isDebugEnabled()) {
+ log.debug("Create instance of InternetBuilder from class "
+ + serviceClassName);
+ }
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Create default implementation instance of InternetBuilder");
+ }
+ instance = new ResourceBuilderImpl();
+ }
+ instances.put(loader, instance);
+ }
+ if(log.isDebugEnabled()){
+ log.debug("Return instance of internet resource builder
"+instance.toString());
+ }
+ return instance;
+ }
+
+ /**
+ * Package-wide method for reset instance in Junit tests.
+ *
+ * @param instance
+ */
+ public static void setInstance(InternetResourceBuilder instance) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ instances.put(loader, instance);
+ }
+
+ public InternetResourceBuilder() {
+ super();
+ }
+
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,145 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+/**
+ * Abstraction context class for rendering resource ( image, script, style )
+ * can be work in 2 variants - for simple ServletRequest and as JSF context
encapsulation.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:57 $
+ *
+ */
+public abstract class ResourceContext {
+
+ private boolean cacheEnabled = false;
+ private Object resourceData;
+ // response headers
+ /**
+ * Delegate to {@link javax.servlet.ServletResponse} setHeader
+ * @param name name of header
+ * @param value new value
+ */
+ public abstract void setHeader(String name, String value);
+
+ /**
+ * Delegate to {@link javax.servlet.ServletResponse} setHeader
+ * @param name name of header
+ * @param value new value
+ */
+ public abstract void setIntHeader(String name, int value);
+
+ /**
+ * Delegate to {@link javax.servlet.ServletResponse} setHeader
+ * @param name name of header
+ * @param value new value
+ */
+ public abstract void setDateHeader(String name, long value);
+
+ /**
+ * @return
+ * @throws IOException
+ */
+ public abstract OutputStream getOutputStream() throws IOException;
+
+ /**
+ * @return
+ */
+ public abstract String getQueryString();
+
+ /**
+ * @return
+ */
+ public abstract String getPathInfo();
+
+ /**
+ * @return
+ */
+ public abstract String getServletPath();
+
+ /**
+ * Get session attribute for given name. session not created
+ * @param name attribute name
+ * @return value for attribute, or null.
+ */
+ public abstract Object getSessionAttribute(String name);
+
+ public abstract InputStream getResourceAsStream(String path);
+
+ /**
+ * Get request parameter for given name.
+ * @param data_parameter
+ * @return
+ */
+ public abstract String getRequestParameter(String data_parameter);
+
+ /**
+ * @return Returns the cacheEnabled.
+ */
+ public boolean isCacheEnabled() {
+ return this.cacheEnabled;
+ }
+
+ /**
+ * @param cacheEnabled The cacheEnabled to set.
+ */
+ public void setCacheEnabled(boolean cacheEnabled) {
+ this.cacheEnabled = cacheEnabled;
+ }
+
+ /**
+ * get output writer for send response.
+ * @return
+ */
+ public abstract PrintWriter getWriter() throws IOException;
+
+ /**
+ * Setup response content type as {@see
javax.servlet.ServletResponse#setContentType(java.lang.String)}
+ * @param contentType
+ */
+ public abstract void setContentType(String contentType);
+
+ public abstract String getInitParameter(String name);
+
+ public Object getResourceData() {
+ // TODO Auto-generated method stub
+ return resourceData;
+ }
+
+ public void setResourceData(Object data) {
+ resourceData = data;
+
+ }
+
+ /**
+ * Release any data used by this context.
+ * Close buffers used by cached context, release FacesContext, if exist.
+ */
+ public void release() {
+
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,67 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import javax.faces.FacesException;
+
+/**
+ * Exception for throw in case of illegal creation of resource ( not existed file etc. )
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:08 $
+ *
+ */
+public class ResourceNotFoundException extends FacesException {
+
+ /**
+ *
+ */
+ public ResourceNotFoundException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param arg0
+ */
+ public ResourceNotFoundException(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param arg0
+ */
+ public ResourceNotFoundException(Throwable arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public ResourceNotFoundException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+
+/**
+ * Interface for all Renderers ( or other classes ? ) for
+ * generate internet resources.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
+ *
+ */
+public interface ResourceProduser {
+ /**
+ * @param path - local path to internet resource.
+ * @return resource instance
+ */
+ public InternetResource getResource( String path) throws ResourceNotFoundException;
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * "Brige" for concrete resource types - images, scripts, styles.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:07 $
+ *
+ */
+public interface ResourceRenderer {
+
+ /**
+ * @return content type ( image/jpeg , text/javascript etc. ) for given type.
+ */
+ String getContentType();
+
+ /**
+ * Encode concrete HTML element for resource.
+ * @param context
+ * @param data
+ * @throws IOException
+ */
+ void encode(InternetResource resource, FacesContext context, Object data) throws
IOException;
+
+ /**
+ * Encode concrete HTML element for resource.
+ * @param context
+ * @param data
+ * @throws IOException
+ */
+ void encode(InternetResource resource, FacesContext context, Object data, Map
attributes) throws IOException;
+
+ void encodeBegin(InternetResource base, FacesContext context, Object data, Map
attributes) throws IOException;
+
+ void encodeEnd(InternetResource base, FacesContext context, Object data) throws
IOException;
+
+ /**
+ * @return true, if resource must be rendered in faces request cicle.
+ */
+ public boolean requireFacesContext();
+
+ /**
+ * Send incapsulated resource to client by {@link ResourceContext} .
+ * Perform any conversions, nessesary for this resources ( template interpretations,
JavaScript conversions etc )
+ * @param context
+ * @return TODO
+ */
+ public int send(InternetResource base,ResourceContext context) throws IOException;
+
+ /**
+ * Get data to build URI for given resource. Can be any Serialisable object,
+ * @param base TODO
+ * @return data for Store in URI/ Cache key.
+ */
+ public Object getData(InternetResource base, FacesContext context, Object data);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/Skin.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/Skin.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/Skin.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/Skin.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,324 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.skin;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Main interface for configurable parameters.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
+ *
+ */
+public interface Skin {
+ // parameters names constants
+
+// parameters names constants
+
+ /**
+ * used for define url with general CSS file for current skin.
+ */
+ public static final String generalStyleSheet = "generalStyleSheet";
+
+ /**
+ * used for defining a header background color in the panel, a tabpanel active tab
+ * background color, a bar background color for ddmenu, tables background color,
+ * buttons background color. Default value #1D7DB3.
+ */
+ public static final String headerBackgroundColor = "headerBackgroundColor";
+
+ /**
+ * used for defining color of the titles of the top level of the menu, the panel header
+ * color, the table header color, color of the title of the active tab in the tabpanel,
+ * color of the title on the buttons. Default value #FFFFFF.
+ */
+ public static final String headTextColor = "headTextColor";
+
+ /**
+ * used for defining the background color of the bar under the header in the panel and
+ * the tabpanel, color of the border for the top level of the ddmenu, background
+ * highlight color of the selected item in the dropdown list boxes of the ddmenu,
+ * background color of the footer in the tables, color of the text for the inactive and
+ * disabled tab in the tabpanel, color of the border of the buttons. Default value
+ * #BFD7E4.
+ */
+ public static final String selectBackgroundColor = "selectBackgroundColor";
+
+ /**
+ * used for defining the background color of the basic area of the panel and tabpanels,
+ * background color of the dropdown list boxes of ddmenu. Default value #BFD7E4.
+ */
+ public static final String generalBackgroundColor = "generalBackgroundColor";
+
+ /**
+ * used for defining color of the basic text, color of the text in the dropdown list
+ * boxes of ddmenu, color of the right and top borders for the controls like text,
+ * textArea, secret. Default value #000000.
+ */
+ public static final String generalTextColor = "generalTextColor";
+
+ /**
+ * used for defining shadow background color of the panels, color of the bottom and
right
+ * borders for the dropdown list box in ddmenu. Default value #AFB1B2.
+ */
+ public static final String shadowBackgroundColor = "shadowBackgroundColor";
+
+ /**
+ * used for defining the seamlessness of the tip shadow. Default value 2.
+ */
+ public static final String shadowOpacity = "shadowOpacity";
+
+ /**
+ * used for defining tables border color, color of the bottom and left controls like
+ * text, textArea, secret, color of the top and left borders for the dropdown list box
in
+ * the ddmenu. Default value #CCCCCC.
+ */
+ public static final String tableBorderColor = "tableBorderColor";
+
+ /**
+ * used for defining tables and controls background color. Default value #FFFFFF.
+ */
+ public static final String tableBackgroundColor = "tableBackgroundColor";
+
+ /**
+ * Font size for the displaying panels headers and top level of the ddmenu. Default
+ * value 12px.
+ */
+ public static final String headerSizeFont = "headerSizeFont";
+
+ /**
+ * Font name for the displaying panels headers and top level of the ddmenu.Default
value
+ * Arial, Verdana.
+ */
+ public static final String headerFamilyFont = "headerFamilyFont";
+
+ /**
+ * Font size for displaying tab titles. Default value 11px.
+ */
+ public static final String tabSizeFont = "tabSizeFont";
+
+ /**
+ * Font name for displaying tab titles. Default value Arial, Verdana.
+ *
+ */
+ public static final String tabFamilyFont = "tabFamilyFont";
+
+ /**
+ * Rounding-off radius of the tabs corners. Default value 5px.
+ */
+ public static final String tabRadiusCorner = "tabRadiusCorner";
+
+ /**
+ * Font size for displaying buttons titles. Default value 11px.
+ */
+ public static final String buttonSizeFont = "buttonSizeFont";
+
+ /**
+ * Font name for displaying buttons titles. Default value Arial, Verdana.
+ */
+ public static final String buttonFamilyFont = "buttonFamilyFont";
+
+ /**
+ * Rounding-off radius of the buttons corners. Default value 13px.
+ *
+ */
+ public static final String buttonRadiusCorner = "buttonRadiusCorner";
+
+ /**
+ * Rounding-off radius of the panels corners. Default value 5px.
+ */
+ public static final String panelRadiusCorner = "panelRadiusCorner";
+
+ /**
+ * Style of the text displaying on the button. Default value normal.
+ *
+ */
+ public static final String buttonStyleFont = "buttonStyleFont";
+
+ /**
+ * Depth of the text displaying on the button. Default value bold.
+ */
+ public static final String buttonWeightFont = "buttonWeightFont";
+
+ /**
+ * Style of the text displaying on the active (selected) tabs.Default value normal.
+ */
+ public static final String activetabStyleFont = "activetabStyleFont";
+
+ /**
+ * Depth of the text displaying on the active (selected) tabs.Default value bold.
+ */
+ public static final String activetabWeightFont = "activetabWeightFont";
+
+ /**
+ * Style of of the text displaying on the inactive (unselected) tabs. Default value
+ * normal.
+ */
+ public static final String tabStyleFont = "tabStyleFont";
+
+ /**
+ * Depth of the text displaying on the inactive (unselected) tabs.Default value normal.
+ */
+ public static final String tabWeightFont = "tabWeightFont";
+
+ /**
+ * Style of the text displaying on the disabled tabs.Default value normal.
+ */
+ public static final String disabledTabStyleFont = "disabledTabStyleFont";
+
+ /**
+ * Depth of the text displaying on the disabled tabs.Default value normal.
+ */
+ public static final String disabledTabWeightFont = "disabledTabWeightFont";
+
+ /**
+ * Color for selected checkbox or selectOneRadio.
+ */
+ public static final String selectControlColor = "selectControlColor";
+
+ /**
+ * Responsible for the borders color of the radiobutton and checkbox and color of light
+ * part of the fields and text area border. Default value #B0B0B0.
+ */
+ public static final String controlBorderColor = "controlBorderColor";
+
+ /**
+ * Parameter responsible for 3D Look of panels and buttons.
+ */
+
+ public static final String interfaceLevel3D = "interfaceLevel3D";
+
+ /**
+ * defines the layout of the tabs in the panel. Possible values Top. Left. Bottom,
Right.
+ * Default value ???.
+ */
+ public static final String preferableTabPosition = "preferableTabPosition";
+
+ /**
+ * defines the variant of text writing. Values - Hor (horisontal position), Vert
+ * (vertical position - letters are arranged into column), VertCW (vertical
+ * position with text rotation anticlockwise). Default value Hor.
+ */
+ public static final String preferableTabTextOrientation =
"preferableTabTextOrientation";
+ /**
+ * text aligning in the tabs with the fixed tab length (hight). Values Left,
Center,Right
+ * for the horizontal oriented tabs, values Top, center, Bottom - for vertical oriented
+ * tabs. Default value center.
+ */
+
+
+ public static final String preferableTabTextDirection =
"preferableTabTextDirection";
+
+
+ /**
+ *
+ */
+ public static final String overAllBackground = "overAllBackground";
+ /**
+ *
+ */
+ public static final String generalLinkColor = "generalLinkColor";
+
+ public static final String panelTextColor = "panelTextColor";
+
+ // Preferable parameters
+ /**
+ * Preferable parameters names for skin ( in common, for Preferable.Name
+ * parameter will PreferableName )
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
+ *
+ */
+
+ public interface Preferable {
+ /**
+ *
+ */
+ public static final String dataSizeFont = "preferableDataSizeFont";
+
+ /**
+ *
+ */
+ public static final String dataFamilyFont = "preferableDataFamilyFont";
+
+ /**
+ *
+ */
+ public static final String panelBodyPadding = "preferablePanelBodyPadding";
+
+ /**
+ *
+ */
+ public static final String headerWeightFont = "preferableHeaderWeightFont";
+
+ }
+
+ /**
+ * Get Rener Kit name for this skin.
+ *
+ * @param context -
+ * {@link FacesContext } for current request. need for
+ * {@link javax.faces.el.ValueBinding} evaluation.
+ * @return RenderKitId for this skin, or <code>null</code> for default.
+ */
+ public String getRenderKitId(FacesContext context);
+
+ /**
+ * Get value for configuration parameter. If parameter set as EL-expression,
+ * calculate it value.
+ *
+ * @param context -
+ * {@link FacesContext } for current request.
+ * @param name
+ * name of paremeter.
+ * @return value of parameter in config, or null
+ */
+ public Object getParameter(FacesContext context, String name);
+
+ /**
+ * Get value for configuration parameter. If parameter set as EL-expression,
+ * calculate it value.
+ *
+ * @param context -
+ * {@link FacesContext } for current request.
+ * @param name
+ * name of paremeter.
+ * @param defaultValue - default value if parameter not present in Skin
+ * @return value of parameter in config, or null
+ */
+ public Object getParameter(FacesContext context, String name, Object defaultValue);
+
+ /**
+ * @param name
+ * @return
+ */
+ public boolean containsProperty(String name);
+
+ /**
+ * Calculate unique ( as possible ) code to identity this skin instance. Used for
generate hash key in skin-depended resources
+ * @param context
+ * @return
+ */
+ public int hashCode(FacesContext context);
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.skin;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Fine tuning parameters for components configuration.
+ * For any skin, calculation of concrete component parameners done by special
"configuration",
+ * pointed as special skin parameter ( or by default configuration ).
+ * Work like "transformation" of limited set Skin parameters to fine-grained
individual component
+ * parameters.
+ * @author shura
+ *
+ */
+public interface SkinConfiguration {
+
+ /**
+ * Get value for configuration parameter. If parameter set as EL-expression,
+ * calculate it value.
+ *
+ * @param context -
+ * {@link FacesContext } for current request.
+ * @param name
+ * name of paremeter.
+ * @return value of parameter in config, or null
+ */
+ public Object getParameter(FacesContext context, String name);
+
+ /**
+ * Get value for skin parameter, for build extensible ( mandatory/fine tuning ) with
three-stage checks :
+ * <ul>
+ * <li>first, check value for parameter with given name. If value not null, return
it</li>
+ * <li>second, got parameter value from skin by skinName key. If not null, return
it.</li>
+ * <li>if both above parameters is null, return default value.</li>
+ * </ul>
+ * @param context - Current JSF context.
+ * @param name - name of parameter.
+ * @param skinName - name of according ( default ) parameter i Skin for same purpose.
may be <code>null</code>.
+ * @param defaultValue - default parameter value.
+ * @return - value of parameter.
+ */
+ public Object getParameter(FacesContext context, String name,String skinName, Object
defaultValue);
+ /**
+ * Test for present parameter for given name.
+ * @param name of parameter to test
+ * @return true if parameter present in configuration.
+ */
+ public boolean containsParameter(String name);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,179 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.skin;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base factory class ( implement Singleton design pattern ). Produce self
+ * instance to build current skin configuration. At present, realised as lazy
+ * creation factory. TODO - select point to initialize.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
+ *
+ */
+public abstract class SkinFactory {
+
+ /**
+ * static instance variable.
+ */
+ private static Map instances = Collections.synchronizedMap(new HashMap());
+
+ private static final Log log = LogFactory.getLog(SkinFactory.class);
+
+
+ public static void reset() {
+ instances = Collections.synchronizedMap(new HashMap());
+ }
+
+ /**
+ * Initialize skin factory. TODO - make call from init() method of any
+ * servlet or custom faces element method ??? If exist resource
+ * META-INF/services/org.ajax4jsf.framework.skin.SkinFactory , create
+ * instance of class by name from first line of this file. If such class
+ * have constructor with {@link SkinFactory} parameter, instantiate it with
+ * instance of default factory ( as usual in JSF ). If any error occurs in
+ * instantiate custom factory, return default.
+ */
+ public static final SkinFactory getInstance() {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ SkinFactory instance = (SkinFactory) instances.get(loader);
+ if (instance == null) {
+ // Pluggable factories.
+ InputStream input = null; // loader.getResourceAsStream(SERVICE_RESOURCE);
+ input = loader.getResourceAsStream(SERVICE_RESOURCE);
+ // have services file.
+ if (input != null) {
+ try {
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(input));
+ String factoryClassName = reader.readLine();
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.SET_SKIN_FACTORY_INFO,
+ factoryClassName));
+ }
+ Class clazz = Class.forName(factoryClassName);
+ try {
+ // try construct factory chain.
+ Constructor factoryConstructor = clazz
+ .getConstructor(new Class[] { SkinFactory.class });
+ instance = (SkinFactory) factoryConstructor
+ .newInstance(new Object[] { instance });
+ } catch (NoSuchMethodException e) {
+ // no chain constructor - attempt default.
+ instance = (SkinFactory) clazz.newInstance();
+ }
+ } catch (Exception e) {
+ log
+ .warn(
+ Messages
+ .getMessage(Messages.CREATING_SKIN_FACTORY_ERROR),
+ e);
+ } finally {
+ try {
+ input.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+
+ }
+ }
+ if (instance == null) {
+ instance = new SkinFactoryImpl();
+ }
+ instances.put(loader, instance);
+ }
+
+ return instance;
+ }
+
+ /**
+ * Get default {@link Skin} implementation.
+ * @param context
+ * @return
+ */
+ public abstract Skin getDefaultSkin(FacesContext context);
+
+ /**
+ * Get current {@link Skin} implementation.
+ * @param context
+ * @return
+ */
+ public abstract Skin getSkin(FacesContext context);
+
+// public abstract SkinConfiguration getSkinConfiguration(FacesContext context);
+
+
+
+ /**
+ * Get EL-enabled value. Return same string, if not el-expression.
+ * Otherthise, return parsed and evaluated expression.
+ *
+ * @param context -
+ * current Faces Context.
+ * @param value -
+ * string to parse.
+ * @return - interpreted el or unmodified value.
+ */
+ protected static boolean isValueReference(String value) {
+ if (value == null)
+ return false;
+
+ int start = value.indexOf("#{");
+ if (start >= 0) {
+ int end = value.lastIndexOf('}');
+ if (end >= 0 && start < end) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
+ * Resource Uri for file with name of class for application-wide SkinFactory same as SPI
definitions for common Java SAX, Jsf etc. factories
+ */
+ public static final String SERVICE_RESOURCE = "META-INF/services/" +
SkinFactory.class.getName();
+
+ /**
+ * Name of web application init parameter for current skin . Can be simple
+ * String for non-modified name, or EL-expression for calculate current
+ * skin. If EL evaluated to <code>String</code> - used as skin name, if to
+ * instance of {@link Skin } - used this instance. by default -
+ * "org.exadel.chameleon.SKIN"
+ */
+ public static final String SKIN_PARAMETER = "org.ajax4jsf.SKIN";
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.skin;
+
+import javax.faces.FacesException;
+
+public class SkinNotFoundException extends FacesException {
+
+ public SkinNotFoundException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public SkinNotFoundException(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ public SkinNotFoundException(Throwable arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+
+ public SkinNotFoundException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,99 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxSubmitFunction extends JSFunction {
+
+ /**
+ * Name Javasript function for submit AJAX request
+ */
+ public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
+
+ /**
+ * Attribute for keep clientId of status component
+ */
+ public static final String STATUS_ATTR_NAME = "status";
+
+ /**
+ * Attribute for keep JavaScript funtion name for call after complete
+ * request.
+ */
+ public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
+
+ /**
+ * Attribute to keep
+ */
+ public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
+
+ private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
+
+ public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
+
+ private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
+
+ private UIComponent component;
+
+ private Map options = new HashMap();
+
+ private Map requestParameters = new HashMap();
+
+ /**
+ *
+ */
+ public AjaxSubmitFunction(UIComponent component) {
+ this(component,AJAX_FUNCTION_NAME);
+ }
+ /**
+ * @param name
+ */
+ public AjaxSubmitFunction(UIComponent component,String name) {
+ super(name);
+ this.component = component;
+ // Fill parameters and options values.
+ }
+ /**
+ * @return the options
+ */
+ public Map getOptions() {
+ return this.options;
+ }
+ /**
+ * @return the requestParameters
+ */
+ public Map getRequestParameters() {
+ return this.requestParameters;
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,119 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+/**
+ * @author shura
+ * Encode chars as JavaScript sequences
+ */
+public class JSEncoder {
+ private char APOSTROPHE[] = { '\\', '\'' };
+
+ private static final char ENCODE_HEX[] = "0123456789ABCDEF".toCharArray();
+
+ private static final char ENCODE_APOS[] = "\\'".toCharArray();
+
+ private static final char ENCODE_QUOT[] = "\\\"".toCharArray();
+
+ private static final char ENCODE_CR[] = "\\r".toCharArray();
+
+ private static final char ENCODE_LF[] = "\\n".toCharArray();
+
+ private static final char ENCODE_FF[] = "\\f".toCharArray();
+
+ private static final char ENCODE_TAB[] = "\\t".toCharArray();
+
+ private static final char ENCODE_BS[] = "\\\\".toCharArray();
+
+ private static final char ENCODE_ESC[] = "\\e".toCharArray();
+
+ /**
+ * Create a new instance of this <code>XMLEncoder</code>.
+ */
+ public JSEncoder() {
+ }
+
+ /**
+ * Return true or false wether this encoding can encode the specified
+ * character or not.
+ * <p>
+ * This method will return true for the following character range: <br />
+ * <code>
+ * <nobr>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]</nobr>
+ * </code>
+ * </p>
+ *
+ * @see <a
href="http://www.w3.org/TR/REC-xml#charsets">W3C XML 1.0
</a>
+ */
+ public boolean compile(char c) {
+
+ if ((c == 0x09) || // [\t]
+ (c == 0x0a) || // [\n]
+ (c == 0x0d) || // [\r](c == 0x22) || // ["]
+ (c == 0x22) || // ["]
+ (c == 0x27) || // [']
+ (c == 0x5c) || // [\]
+ (c == 0x03) || // [esc]
+ (c == ']') || // ] - to avoid conflicts in CDATA
+ (c < 0x20) || // See <
http://www.w3.org/TR/REC-xml#charsets>
+ ((c > 0xd7ff) && (c < 0xe000)) || (c > 0xfffd)|| (c >
0xff)) {
+ return (false);
+ }
+
+ return (true);
+ }
+
+ /**
+ * Return an array of characters representing the encoding for the specified
+ * character.
+ */
+ public char[] encode(char c) {
+ switch (c) {
+ case 0x03:
+ return (ENCODE_FF); // (>) [>]
+ case 0x09:
+ return (ENCODE_TAB); // (>) [>]
+ case 0x0a:
+ return (ENCODE_LF); // (>) [>]
+ case 0x0d:
+ return (ENCODE_CR); // (>) [>]
+ case 0x22:
+ return (ENCODE_QUOT); // (") ["]
+ case 0x27:
+ return (ENCODE_APOS); // (') [']
+ case 0x5c:
+ return (ENCODE_BS); // (<) [<]
+ default: {
+ if (c > 0xff) {
+ char ret[] = { '\\', 'u', ENCODE_HEX[c >> 0xc &
0xf],
+ ENCODE_HEX[c >> 0x8 & 0xf], ENCODE_HEX[c >> 0x4
& 0xf],
+ ENCODE_HEX[c & 0xf] };
+ return (ret);
+ }
+ char ret[] = { '\\', 'x', ENCODE_HEX[c >> 0x4 &
0xf],
+ ENCODE_HEX[c & 0xf] };
+ return (ret);
+ }
+ }
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,104 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:26 $
+ *
+ */
+public class JSFunction extends ScriptStringBase implements ScriptString {
+
+ private String name;
+
+ private List parameters = null;
+
+ /**
+ * @param name
+ */
+ public JSFunction(String name) {
+ // TODO Auto-generated constructor stub
+ this.name = name;
+ }
+
+ /**
+ * @param name
+ * @param parameters
+ */
+ public JSFunction(String name, List parameters) {
+ // TODO Auto-generated constructor stub
+ this.name = name;
+ this.parameters = parameters;
+ }
+
+ /**
+ * @param name
+ * @param parameters
+ */
+ public JSFunction(String name, Object parameter) {
+ // TODO Auto-generated constructor stub
+ this.name = name;
+ this.parameters = new ArrayList(1);
+ this.parameters.add(parameter);
+ }
+
+ public JSFunction addParameter(Object parameter) {
+ getParameters().add(parameter);
+ return this;
+ }
+
+ public void appendScript(StringBuffer functionString) {
+ functionString.append(name).append('(');
+ boolean first = true;
+ List parameters = getParameters();
+ if (null != parameters) {
+ for (Iterator param = parameters.iterator(); param.hasNext();) {
+ Object element = param.next();
+ if (!first) {
+ functionString.append(',');
+ }
+ if (null != element) {
+ functionString.append(ScriptUtils.toScript(element));
+ } else {
+ functionString.append("null");
+ }
+ first = false;
+ }
+
+ }
+ functionString.append(")");
+ }
+
+ /**
+ * @return the parameters
+ */
+ public List getParameters() {
+ if (this.parameters == null) {
+ this.parameters = new ArrayList();
+ }
+ return this.parameters;
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,112 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/24 13:22:31 $
+ *
+ */
+public class JSFunctionDefinition extends ScriptStringBase implements ScriptString
+{
+
+
+
+ private List parameters = new ArrayList();
+
+ private StringBuffer body = new StringBuffer();
+
+ private String name ;
+
+
+ public JSFunctionDefinition(){
+ }
+
+ public JSFunctionDefinition( List parameters)
+ {
+
+ this.parameters = parameters;
+ }
+
+ /**
+ * @param body
+ * @param parameters
+ */
+ public JSFunctionDefinition( Object parameter)
+ {
+ this.parameters.add(parameter);
+ }
+
+
+ public JSFunctionDefinition addParameter(Object parameter)
+ {
+ this.parameters.add(parameter);
+ return this;
+ }
+
+ public JSFunctionDefinition addToBody(Object body)
+ {
+ this.body.append(body);
+ return this;
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.components.renderkit.scriptutils.ScriptString#appendScript(java.lang.StringBuffer)
+ */
+ public void appendScript(StringBuffer functionString)
+ {
+ functionString.append("function");
+ if(null != name){
+ functionString.append(" ").append(name);
+ }
+ functionString.append("(");
+ boolean first = true;
+ for (Iterator param = parameters.iterator(); param.hasNext();)
+ {
+ Object element = param.next();
+ if(!first){
+ functionString.append(',');
+ }
+ functionString.append(element.toString());
+ first = false;
+ }
+ functionString.append("){").append(body).append("}");
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,327 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * JSMin.java 2006-02-13
+ *
+ * Copyright (c) 2006 John Reilly (
www.inconspicuous.org)
+ *
+ * This work is a translation from C to Java of jsmin.c published by
+ * Douglas Crockford. Permission is hereby granted to use the Java
+ * version under the same conditions as the jsmin.c on which it is
+ * based.
+ *
+ *
+ *
+ *
+ * jsmin.c 2003-04-21
+ *
+ * Copyright (c) 2002 Douglas Crockford (
www.crockford.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.ajax4jsf.framework.util.javascript;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
+
+
+
+
+public class JSMin {
+ private static final int EOF = -1;
+
+ private PushbackInputStream in;
+ private OutputStream out;
+
+ private int theA;
+ private int theB;
+
+ public JSMin(InputStream in, OutputStream out) {
+ this.in = new PushbackInputStream(in);
+ this.out = out;
+ }
+
+ /**
+ * isAlphanum -- return true if the character is a letter, digit,
+ * underscore, dollar sign, or non-ASCII character.
+ */
+ static boolean isAlphanum(int c) {
+ return ( (c >= 'a' && c <= 'z') ||
+ (c >= '0' && c <= '9') ||
+ (c >= 'A' && c <= 'Z') ||
+ c == '_' ||
+ c == '$' ||
+ c == '\\' ||
+ c > 126);
+ }
+
+ /**
+ * get -- return the next character from stdin. Watch out for lookahead. If
+ * the character is a control character, translate it to a space or
+ * linefeed.
+ */
+ int get() throws IOException {
+ int c = in.read();
+
+ if (c >= ' ' || c == '\n' || c == EOF) {
+ return c;
+ }
+
+ if (c == '\r') {
+ return '\n';
+ }
+
+ return ' ';
+ }
+
+
+
+ /**
+ * Get the next character without getting it.
+ */
+ int peek() throws IOException {
+ int lookaheadChar = in.read();
+ in.unread(lookaheadChar);
+ return lookaheadChar;
+ }
+
+ /**
+ * next -- get the next character, excluding comments. peek() is used to see
+ * if a '/' is followed by a '/' or '*'.
+ */
+ int next() throws IOException, UnterminatedCommentException {
+ int c = get();
+ if (c == '/') {
+ switch (peek()) {
+ case '/':
+ for (;;) {
+ c = get();
+ if (c <= '\n') {
+ return c;
+ }
+ }
+
+ case '*':
+ get();
+ for (;;) {
+ switch (get()) {
+ case '*':
+ if (peek() == '/') {
+ get();
+ return ' ';
+ }
+ break;
+ case EOF:
+ throw new UnterminatedCommentException();
+ }
+ }
+
+ default:
+ return c;
+ }
+
+ }
+ return c;
+ }
+
+ /**
+ * action -- do something! What you do is determined by the argument: 1
+ * Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B.
+ * (Delete A). 3 Get the next B. (Delete B). action treats a string as a
+ * single character. Wow! action recognizes a regular expression if it is
+ * preceded by ( or , or =.
+ */
+
+ void action(int d) throws IOException, UnterminatedRegExpLiteralException,
+ UnterminatedCommentException, UnterminatedStringLiteralException {
+ switch (d) {
+ case 1:
+ out.write(theA);
+ case 2:
+ theA = theB;
+
+ if (theA == '\'' || theA == '"') {
+ for (;;) {
+ out.write(theA);
+ theA = get();
+ if (theA == theB) {
+ break;
+ }
+ if (theA <= '\n') {
+ throw new UnterminatedStringLiteralException();
+ }
+ if (theA == '\\') {
+ out.write(theA);
+ theA = get();
+ }
+ }
+ }
+
+ case 3:
+ theB = next();
+ if (theB == '/' && (theA == '(' || theA == ',' || theA
== '=')) {
+ out.write(theA);
+ out.write(theB);
+ for (;;) {
+ theA = get();
+ if (theA == '/') {
+ break;
+ } else if (theA == '\\') {
+ out.write(theA);
+ theA = get();
+ } else if (theA <= '\n') {
+ throw new UnterminatedRegExpLiteralException();
+ }
+ out.write(theA);
+ }
+ theB = next();
+ }
+ }
+ }
+
+ /**
+ * jsmin -- Copy the input to the output, deleting the characters which are
+ * insignificant to JavaScript. Comments will be removed. Tabs will be
+ * replaced with spaces. Carriage returns will be replaced with linefeeds.
+ * Most spaces and linefeeds will be removed.
+ */
+ public void jsmin() throws IOException, UnterminatedRegExpLiteralException,
UnterminatedCommentException, UnterminatedStringLiteralException{
+ theA = '\n';
+ action(3);
+ while (theA != EOF) {
+ switch (theA) {
+ case ' ':
+ if (isAlphanum(theB)) {
+ action(1);
+ } else {
+ action(2);
+ }
+ break;
+ case '\n':
+ switch (theB) {
+ case '{':
+ case '[':
+ case '(':
+ case '+':
+ case '-':
+ action(1);
+ break;
+ case ' ':
+ action(3);
+ break;
+ default:
+ if (isAlphanum(theB)) {
+ action(1);
+ } else {
+ action(2);
+ }
+ }
+ break;
+ default:
+ switch (theB) {
+ case ' ':
+ if (isAlphanum(theA)) {
+ action(1);
+ break;
+ }
+ action(3);
+ break;
+ case '\n':
+ switch (theA) {
+ case '}':
+ case ']':
+ case ')':
+ case '+':
+ case '-':
+ case '"':
+ case '\'':
+ action(1);
+ break;
+ default:
+ if (isAlphanum(theA)) {
+ action(1);
+ } else {
+ action(3);
+ }
+ }
+ break;
+ default:
+ action(1);
+ break;
+ }
+ }
+ }
+ out.flush();
+ }
+
+ class UnterminatedCommentException extends Exception {
+ }
+
+ class UnterminatedStringLiteralException extends Exception {
+ }
+
+ class UnterminatedRegExpLiteralException extends Exception {
+ }
+
+ public static void main(String arg[]) {
+ try {
+ JSMin jsmin = new JSMin(new FileInputStream(arg[0]), System.out);
+ jsmin.jsmin();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (UnterminatedRegExpLiteralException e) {
+ e.printStackTrace();
+ } catch (UnterminatedCommentException e) {
+ e.printStackTrace();
+ } catch (UnterminatedStringLiteralException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+import java.util.List;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:30 $
+ *
+ */
+public class JSObject extends JSFunction
+{
+
+ /**
+ * @param name
+ */
+ public JSObject(String name)
+ {
+ super(name);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param name
+ * @param parameters
+ */
+ public JSObject(String name, List parameters)
+ {
+ super(name, parameters);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param name
+ * @param parameter
+ */
+ public JSObject(String name, Object parameter)
+ {
+ super(name, parameter);
+ // TODO Auto-generated constructor stub
+ }
+
+ public void appendScript(StringBuffer functionString)
+ {
+ functionString.append("new ");
+ super.appendScript(functionString);
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+/**
+ * Create reference to JavaScript variable with optional index.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:30 $
+ *
+ */
+public class JSReference extends ScriptStringBase {
+
+ public static final JSReference THIS = new JSReference("this");
+
+ public static final JSReference TRUE = new JSReference("true");
+ public static final JSReference FALSE = new JSReference("false");
+ public static final JSReference NULL = new JSReference("null");
+
+ private String name;
+ private Object index=null;
+
+ /**
+ * @param name
+ */
+ public JSReference(String name) {
+ // TODO Auto-generated constructor stub
+ this.name = name;
+ }
+
+ /**
+ * @param name
+ * @param index
+ */
+ public JSReference(String name, Object index) {
+ // TODO Auto-generated constructor stub
+ this.name = name;
+ this.index = index;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.util.javascript.ScriptString#appendScript(java.lang.StringBuffer)
+ */
+ public void appendScript(StringBuffer functionString) {
+ functionString.append(name);
+ if (null != index) {
+ functionString.append("[").append(ScriptUtils.toScript(index)).append("]");
+ }
+
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:32 $
+ *
+ */
+public interface ScriptString
+{
+
+ /**
+ * Return object content as JavaScript String.
+ * @return
+ */
+ public abstract String toScript();
+
+ /**
+ * Append JavaScript code to @link StringBuffer
+ * @param functionString
+ */
+ public void appendScript(StringBuffer functionString);
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/26 10:38:52 $
+ *
+ */
+public abstract class ScriptStringBase implements ScriptString
+{
+
+
+
+
+
+ public String toScript()
+ {
+ StringBuffer functionString = new StringBuffer();
+ appendScript(functionString);
+ return functionString.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return toScript();
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,156 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.util.javascript;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.apache.commons.beanutils.PropertyUtils;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/01/24 13:22:31 $
+ *
+ */
+public class ScriptUtils {
+
+ /**
+ * This is utility class, don't instantiate.
+ */
+ private ScriptUtils() {
+
+ }
+
+ /**
+ * Convert any Java Object to JavaScript representation ( as possible ).
+ * @param obj
+ * @return
+ */
+ public static String toScript(Object obj) {
+ if (null == obj) {
+ return "null";
+ } else if (obj instanceof ScriptString) {
+ return ((ScriptString) obj).toScript();
+ } else if (obj.getClass().isArray()) {
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+ for (int i = 0; i < Array.getLength(obj); i++) {
+ Object element = Array.get(obj, i);
+ if (!first) {
+ ret.append(',');
+ }
+ ret.append(toScript(element));
+ first = false;
+ }
+ return ret.append("] ").toString();
+ } else if (obj instanceof Collection) {
+ // Collections put as JavaScript array.
+ Collection collection = (Collection) obj;
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+ for (Iterator iter = collection.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (!first) {
+ ret.append(',');
+ }
+ ret.append(toScript(element));
+ first = false;
+ }
+ return ret.append("] ").toString();
+ } else if (obj instanceof Map) {
+ // Maps put as JavaScript hash.
+ Map map = (Map) obj;
+
+ StringBuffer ret = new StringBuffer("{");
+ boolean first = true;
+ for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
+ Object key = (Object) iter.next();
+ if (!first) {
+ ret.append(',');
+ }
+ addEncodedString(ret, key);
+ ret.append(":");
+ ret.append(toScript(map.get(key)));
+ first = false;
+ }
+ return ret.append("} ").toString();
+ } else if (obj instanceof Number || obj instanceof Boolean) {
+ // numbers and boolean put as-is, without conversion
+ return obj.toString();
+ } else if (obj instanceof String) {
+ // all other put as encoded strings.
+ StringBuffer ret = new StringBuffer();
+ addEncodedString(ret, obj);
+ return ret.toString();
+ }
+ // All other objects threaded as Java Beans.
+ try {
+ StringBuffer ret = new StringBuffer("{");
+ PropertyDescriptor[] propertyDescriptors = PropertyUtils
+ .getPropertyDescriptors(obj);
+ boolean first = true;
+ for (int i = 0; i < propertyDescriptors.length; i++) {
+ PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ String key = propertyDescriptor.getName();
+ if ("class".equals(key)) {
+ continue;
+ }
+ if (!first) {
+ ret.append(',');
+ }
+ addEncodedString(ret, key);
+ ret.append(":");
+ ret.append(toScript(PropertyUtils.getProperty(obj, key)));
+ first = false;
+ }
+ return ret.append("} ").toString();
+ } catch (Exception e) {
+ throw new FacesException(
+ "Error in conversion Java Object to JavaScript", e);
+ }
+ }
+
+ public static void addEncodedString(StringBuffer buff, Object obj) {
+ buff.append("'");
+ addEncoded(buff, obj);
+ buff.append("'");
+
+ }
+
+ public static void addEncoded(StringBuffer buff, Object obj) {
+ JSEncoder encoder = new JSEncoder();
+ char chars[] = obj.toString().toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ char c = chars[i];
+ if (!encoder.compile(c)) {
+ buff.append(encoder.encode(c));
+ } else {
+ buff.append(c);
+ }
+ }
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,139 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.io.IOException;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
+import org.richfaces.component.state.TreeRange;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 07.12.2006
+ * Base class for all tree data models
+ */
+public abstract class AbstractTreeDataModel extends ExtendedDataModel {
+ public final static char SEPARATOR = NamingContainer.SEPARATOR_CHAR;
+
+ private TreeNode wrappedData;
+
+ public final int getRowCount() {
+ return -1;
+ }
+
+ public final int getRowIndex() {
+ return -1;
+ }
+
+ public final void setRowIndex(int rowIndex) {
+ if(rowIndex!=-1) {
+ throw new IllegalArgumentException("In AbstractTreeDataModel rowIndex must be
-1.");
+ }
+ }
+
+ public final Object getWrappedData() {
+ return wrappedData;
+ }
+
+ public final void setWrappedData(Object data) {
+ wrappedData = (TreeNode) data;
+ }
+
+ public final void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object argument) throws IOException {
+ walk(context, dataVisitor, range, null, argument, false);
+ }
+
+ /**
+ * walk sub-model having row key argument as its root
+ * @param context faces context
+ * @param dataVisitor {@link UIDataAdaptor.ComponentVisitor}
+ * @param range {@link TreeRange} to constraint the walk
+ * @param rowKey row key to treat as root of sub-model
+ * @param argument implementation specific argument
+ * @param last boolean flag indicating whether we started our walk from last element
+ * @throws IOException
+ *
+ * @see {@link ExtendedDataModel#walk(FacesContext, DataVisitor, Range, Object)}
+ */
+ public abstract void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last) throws IOException;
+
+ /**
+ * returns whether this node is leaf
+ * @return
+ */
+ public abstract boolean isLeaf();
+
+ /**
+ * Walk backing sub-model having row key argument as its root. If there is no backing
model
+ * configured, calling this method is equivalent to calling {@link #walk(FacesContext,
DataVisitor, Range, Object, Object, boolean)}
+ * @param facesContext faces context
+ * @param visitor {@link UIDataAdaptor.ComponentVisitor} instance
+ * @param range {@link Range} to constraint the walk
+ * @param key row key to treat as root of sub-model
+ * @param argument implementation-specific argument
+ * @throws IOException
+ *
+ * @see {@link #walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}
+ */
+ public abstract void walkModel(FacesContext facesContext, DataVisitor visitor, Range
range, Object key, Object argument, boolean last) throws IOException;
+
+ /**
+ * Processes concrete tree node. Knows about {@link LastElementAware} interface and
handles it
+ * properly. Checks if argument is instance of {@link SubTreeChildrenAppender} and if it
is so
+ * does appending current element
+ * @param context
+ * @param dataVisitor
+ * @param argument
+ * @param treeRowKey
+ * @param last
+ * @throws IOException
+ */
+ protected void processElement(FacesContext context, DataVisitor dataVisitor, Object
argument, TreeRowKey treeRowKey, boolean last) throws IOException {
+// if (argument instanceof SubTreeChildrenAppender) {
+// setRowKey(treeRowKey);
+//
+// if (isRowAvailable()) {
+// ((SubTreeChildrenAppender) argument).addChild(treeRowKey, getRowData(), last,
isLeaf(), getTreeNodeType());
+// }
+// }
+
+ if (last && dataVisitor instanceof LastElementAware) {
+ try {
+ ((LastElementAware) dataVisitor).setLastElement();
+ dataVisitor.process(context, treeRowKey, argument);
+ } finally {
+ ((LastElementAware) dataVisitor).resetLastElement();
+ }
+ } else {
+ dataVisitor.process(context, treeRowKey, argument);
+ }
+ }
+
+ public abstract TreeNode getTreeNode();
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModel.java
(from rev 1388,
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModel.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModel.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.component;
+
+import java.util.Date;
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+public interface CalendarDataModel {
+
+ /**
+ * @return array of CalendarDataModelItems for selected dates.
+ * This method will be called every time when components will need next block of
CalendarDataItems.
+ * That may happens when calendar rendered, or when user navigate to next(previous)
month or in any other case when calendar renders.
+ * This method will be called in Ajax mode when Calendar renders new page.
+ * */
+ public CalendarDataModelItem[] getData(Date[] dateArray);
+
+ /**
+ * @return tool tip when it's used in "single" mode
+ * This method used when tool tips are displayed in "single" mode
+ * */
+ public Object getToolTip(Date date);
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModelItem.java
(from rev 1388,
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModelItem.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModelItem.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/CalendarDataModelItem.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,65 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.component;
+
+import java.util.Date;
+
+
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+
+public interface CalendarDataModelItem {
+
+ /**
+ * @return date that this item for, default implementation return Date
+ * */
+ public Date getDate();
+
+ /**
+ *@return true if date is �selectable� on calendar, default implementation return true
+ **/
+ public boolean isEnabled();
+
+ /**
+ * @return String that will be appended to style class for that date span.
+ * For example it may be �relevant holyday� � that mean class will be like �rich-cal-day
relevant holyday�.
+ * Default implementation return empty string.
+ * */
+ public String getStyleClass();
+
+ /**
+ * @return any additional payload that must be JSON-serialazable object.
+ * May be used in custom date representation on calendar (inside custom facet).*/
+ public Object getData();
+
+ /**
+ * @return true if given date has an associated with it tooltip data.
+ * Default implementation return false.*/
+ public boolean hasToolTip();
+
+ /**
+ *@return tool tip data that will be used in �batch� tooltip loading mode.
+ **/
+ public Object getToolTip();
+}
Copied: branches/refactor1/framework/api/src/main/java/org/richfaces/component/Column.java
(from rev 1388,
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Column.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/richfaces/component/Column.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/Column.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+/**
+ * Marker interface for all components used as column in UIDataTable
+ * @author shura
+ *
+ */
+public interface Column {
+
+
+ /**
+ * Out this column on new row
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract boolean isBreakBefore();
+
+ /**
+ * @param newBreakBefore the value to set
+ */
+ public abstract void setBreakBefore(boolean newBreakBefore);
+
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/LastElementAware.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/LastElementAware.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/LastElementAware.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/LastElementAware.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
+
+/**
+ * @author Konstantin Mishin
+ *
+ * {@link UIDataAdaptor.ComponentVisitor} instances can implement this interface in order
to
+ * be notified of last element occurence at the current tree level. {@link
#setLastElement()}
+ * method is invoked before visiting last element and {@link #resetLastElement()} is
called after
+ * visiting last element.
+ */
+public interface LastElementAware {
+
+ /**
+ * The method is invoked to notify that last element occured
+ */
+ public void setLastElement();
+ /**
+ * The method is invoked to notify that we're done with last element
+ */
+ public void resetLastElement();
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/ListRowKey.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/ListRowKey.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/ListRowKey.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/ListRowKey.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,236 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 17.11.2006
+ * Default {@link TreeRowKey} implementation based on {@link ArrayList}
+ */
+public class ListRowKey extends TreeRowKey {
+
+ private ArrayList path;
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7718335783201397177L;
+
+ public String toString() {
+ return getPath();
+ }
+
+ /**
+ * Default constructor
+ */
+ public ListRowKey() {
+ super();
+ this.path = new ArrayList();
+ }
+
+ /**
+ * Copy constructor
+ * @param parentRowKey row key to clone
+ */
+ protected ListRowKey(ListRowKey parentRowKey) {
+ super();
+ this.path = (ArrayList) parentRowKey.path.clone();
+ }
+
+ /**
+ * Appending constructor
+ * @param parentRowKey base row key
+ * @param pathElement path segment to append to base row key
+ */
+ public ListRowKey(ListRowKey parentRowKey, Object pathElement) {
+ this(parentRowKey);
+ this.path.add(pathElement);
+ }
+
+ private static ArrayList parsePath(String path) {
+ ArrayList result = new ArrayList();
+
+ String trimmedPath = path.trim();
+
+ StringBuffer sb = new StringBuffer();
+ boolean escapedState = false;
+ int pathLength = trimmedPath.length();
+
+ //unescape
+ for (int i = 0; i < pathLength; i++) {
+ char c = trimmedPath.charAt(i);
+
+ if (SEPARATOR_ESCAPE_CHAR == c) {
+ if (escapedState) {
+ sb.append(c);
+ }
+ escapedState = !escapedState;
+ } else {
+ if (c == AbstractTreeDataModel.SEPARATOR) {
+ if (escapedState) {
+ sb.append(c);
+ } else {
+ result.add(sb.toString());
+ sb = new StringBuffer();
+ }
+ } else {
+ sb.append(c);
+ }
+
+ escapedState = false;
+ }
+ }
+
+ if (sb.length() != 0) {
+ result.add(sb.toString());
+ }
+
+ return result;
+ }
+
+ /**
+ * List constructor
+ * @param list List of strings to create corresponding row key from
+ */
+ public ListRowKey(List list) {
+ super();
+
+ this.path = new ArrayList(list);
+ }
+
+ /**
+ * Path object constructor
+ * @param path first path segment
+ */
+ public ListRowKey(Object path) {
+ super();
+ this.path = new ArrayList(1);
+ this.path.add(path);
+ }
+
+ /**
+ * Path string constructor
+ * @param path path string to create corresponding row key from
+ */
+ public ListRowKey(String path) {
+ super();
+ this.path = parsePath(path);
+ }
+
+ public int depth() {
+ return path.size();
+ }
+
+ public Iterator iterator() {
+ return path.iterator();
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ListRowKey other = (ListRowKey) obj;
+ if (path == null) {
+ if (other.path != null)
+ return false;
+ } else if (!path.equals(other.path))
+ return false;
+ return true;
+ }
+
+ public Iterator getSubPathIterator(int fromIndex) {
+ return path.listIterator(fromIndex);
+ }
+
+ public boolean isSubKey(TreeRowKey rowKey) {
+ if (rowKey instanceof ListRowKey) {
+ ListRowKey listRowKey = (ListRowKey) rowKey;
+
+ int commonLength = getCommonPathLength(listRowKey);
+ if (commonLength != 0) {
+ return commonLength == depth();
+ } else {
+ return rowKey.depth() == 0;
+ }
+ } else {
+ return super.isSubKey(rowKey);
+ }
+ }
+
+ public String getPath() {
+ StringBuffer result = new StringBuffer();
+ Iterator iterator = path.iterator();
+ boolean hasNext = iterator.hasNext();
+
+ while (hasNext) {
+ String pathSegment = iterator.next().toString();
+
+ StringBuffer escapedSubPath = new StringBuffer();
+ for (int i = 0; i < pathSegment.length(); i++) {
+ char ch = pathSegment.charAt(i);
+
+ //escape
+ if (AbstractTreeDataModel.SEPARATOR == ch || ListRowKey.SEPARATOR_ESCAPE_CHAR == ch)
{
+ escapedSubPath.append(ListRowKey.SEPARATOR_ESCAPE_CHAR);
+ }
+
+ escapedSubPath.append(ch);
+ }
+
+ result.append(escapedSubPath.toString());
+
+ hasNext = iterator.hasNext();
+
+ if (hasNext) {
+ result.append(AbstractTreeDataModel.SEPARATOR);
+ }
+ }
+
+ return result.toString();
+ }
+
+ public int getCommonPathLength(TreeRowKey otherRowKey) {
+ if (otherRowKey == null)
+ return 0;
+ Iterator iterator = this.iterator();
+ Iterator otherIterator = otherRowKey.iterator();
+ int length = 0;
+ while (iterator.hasNext() && otherIterator.hasNext()
+ && iterator.next().equals(otherIterator.next()))
+ length++;
+ return length;
+ }
+}
Copied: branches/refactor1/framework/api/src/main/java/org/richfaces/component/Row.java
(from rev 1388,
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Row.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/richfaces/component/Row.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/Row.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+/**
+ * Marker interface for table columns, rendered as entire row.
+ * @author shura
+ *
+ */
+public interface Row extends Column {
+
+ /**
+ * Get iterator for all columns contained in this row.
+ * @return
+ */
+ public Iterator columns();
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeDataModel.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeDataModel.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeDataModel.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,223 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.richfaces.component.state.TreeRange;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 16.11.2006
+ *
+ */
+public class TreeDataModel extends AbstractTreeDataModel {
+ private TreeRowKey currentRowKey;
+
+ private TreeRowKey oldRowKey;
+
+ private TreeNode rowTreeData;
+
+ public Object getRowKey() {
+ return this.currentRowKey;
+ }
+
+ public void setRowKey(Object rowKey) {
+ if (rowKey != null) {
+ ListRowKey newRowKey = (ListRowKey) rowKey;
+ this.currentRowKey = newRowKey;
+ } else {
+ this.currentRowKey = null;
+ this.oldRowKey = null;
+ this.rowTreeData = null;
+ }
+ }
+
+
+ public void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last) throws IOException {
+
+ ListRowKey listRowKey = (ListRowKey) rowKey;
+
+ TreeNode node = locateTreeNode(listRowKey);
+
+ if (node != null) {
+ TreeRange treeRange = (TreeRange) range;
+
+ if (treeRange == null || treeRange.processNode(listRowKey)) {
+
+ if (node.getParent() != null) {
+ processElement(context, dataVisitor, argument, listRowKey, last);
+ }
+
+ if (treeRange == null || treeRange.processChildren(listRowKey)) {
+ if (!node.isLeaf()) {
+ Iterator children = node.getChildren();
+
+ Map.Entry childEntry = children.hasNext() ? (Map.Entry) children.next() : null;
+ TreeNode childNode;
+ Object identifier;
+
+ if (childEntry != null) {
+ childNode = (TreeNode) childEntry.getValue();
+ identifier = childEntry.getKey();
+ } else {
+ childNode = null;
+ identifier = null;
+ }
+
+ do {
+ Map.Entry nextChildEntry = children.hasNext() ? (Map.Entry) children.next() :
null;
+ TreeNode nextChildNode;
+ Object nextIdentifier;
+
+ if (nextChildEntry != null) {
+ nextChildNode = (TreeNode) nextChildEntry.getValue();
+ nextIdentifier = nextChildEntry.getKey();
+ } else {
+ nextChildNode = null;
+ nextIdentifier = null;
+ }
+
+ if (childNode != null) {
+
+ boolean isLast = nextChildNode == null;
+
+ ListRowKey newRowKey;
+ if (rowKey != null) {
+ newRowKey = new ListRowKey(listRowKey, identifier);
+ } else {
+ newRowKey = new ListRowKey(identifier);
+ }
+
+ this.walk(context, dataVisitor, range, newRowKey, argument, isLast);
+ }
+
+ identifier = nextIdentifier;
+ childNode = nextChildNode;
+ } while (childNode != null);
+ }
+ }
+ }
+ }
+ }
+
+ protected TreeNode locateTreeNode(TreeRowKey rowKey) {
+ return locateTreeNode(rowKey, false);
+ }
+
+ protected TreeNode locateTreeNode(TreeRowKey rowKey, boolean allowCreate) {
+ boolean useCached = (rowTreeData != null && rowKey != null &&
rowKey.equals(this.oldRowKey));
+ if (!useCached) {
+ TreeNode rootNode = (TreeNode) getWrappedData();
+
+ if (rootNode != null) {
+ if (rowKey != null) {
+ int commonPathLength = rowKey.getCommonPathLength(oldRowKey);
+ if (oldRowKey == null) {
+ rowTreeData = rootNode;
+ } else {
+ int rootOpsCount = rowKey.depth();
+ int currentUpOpsCount = oldRowKey.depth() - commonPathLength;
+ int currentOpsCount = currentUpOpsCount + rootOpsCount - commonPathLength;
+
+ if (rootOpsCount > currentOpsCount) {
+ for (int i = 0; i < oldRowKey.depth()
+ - commonPathLength; i++) {
+
+ rowTreeData = rowTreeData.getParent();
+ }
+ } else {
+ commonPathLength = 0;
+ rowTreeData = rootNode;
+ oldRowKey = null;
+ }
+ }
+ oldRowKey = rowKey;
+ Iterator iterator = rowKey.getSubPathIterator(commonPathLength);
+ while (iterator.hasNext()) {
+ Object pathSegment = iterator.next();
+ TreeNode childRowTreeData = rowTreeData.getChild(pathSegment);
+
+ if (childRowTreeData == null) {
+ if (!allowCreate) {
+ return null;
+ } else {
+ childRowTreeData = new TreeNodeImpl();
+ rowTreeData.addChild(pathSegment, childRowTreeData);
+ }
+ }
+
+ rowTreeData = childRowTreeData;
+ }
+ } else {
+ return rootNode;
+ }
+ } else {
+ return null;
+ }
+ }
+ return rowTreeData;
+ }
+
+ public boolean isRowAvailable() {
+ TreeNode data = locateTreeNode(this.currentRowKey);
+
+ if (data != null) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public Object getRowData() {
+ TreeNode treeNode = locateTreeNode(this.currentRowKey);
+ if (treeNode != null) {
+ return treeNode.getData();
+ }
+
+ return null;
+ }
+
+ public boolean isLeaf() {
+ TreeNode treeNode = locateTreeNode(this.currentRowKey);
+ if (treeNode != null) {
+ return treeNode.isLeaf();
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ public void walkModel(FacesContext context, DataVisitor visitor, Range range, Object
key, Object argument, boolean last) throws IOException {
+ walk(context, visitor, range, key, argument, last);
+ }
+
+ public TreeNode getTreeNode() {
+ return locateTreeNode(this.currentRowKey);
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,53 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.el.MethodBinding;
+
+import org.richfaces.component.events.NodeExpandedListener;
+import org.richfaces.component.events.NodeSelectedListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 29.11.2006
+ *
+ * Base tree events interface
+ */
+public interface TreeListenerEventsProducer {
+ public abstract void setChangeExpandListener(MethodBinding binding);
+ public abstract MethodBinding getChangeExpandListener();
+
+ public abstract void setNodeSelectListener(MethodBinding binding);
+ public abstract MethodBinding getNodeSelectListener();
+
+ public abstract void setDropListener(MethodBinding binding);
+ public abstract MethodBinding getDropListener();
+
+ public abstract void setDragListener(MethodBinding binding);
+ public abstract MethodBinding getDragListener();
+
+ public void addNodeSelectListener(NodeSelectedListener listener);
+ public void addChangeExpandListener(NodeExpandedListener listener);
+
+ //TODO - rename this
+ public boolean hasAjaxSubmitSelection();
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNode.java (from
rev 1388, branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNode.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNode.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNode.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,89 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ * Interface representing tree ADT nodes
+ */
+public interface TreeNode extends Serializable{
+
+ /**
+ * getter for node attached data
+ * @return node attached data
+ */
+ public Object getData();
+ /**
+ * setter for node attached data
+ * @param data data to set as attached node data
+ */
+ public void setData(Object data);
+
+ /**
+ * Returns whether this node is leaf
+ * @return <code>true</code> if this node is leaf else returns
<code>false</code>
+ */
+ public boolean isLeaf();
+
+ /**
+ * getter for children
+ * @return {@link Iterator} of {@link Map.Entry} instances containing {@link TreeNode}
as values
+ * and their identifiers as keys
+ */
+ public Iterator getChildren();
+ /**
+ * find child by id
+ * @param id identifier of the child to find
+ * @return designated {@link TreeNode} instance or <code>null</code>
+ */
+ public TreeNode getChild(Object id);
+
+ /**
+ * adds child to children collection
+ * @param identifier child identifier
+ * @param child child
+ */
+ public void addChild(Object identifier, TreeNode child);
+
+ /**
+ * removes child from children collection by child id
+ * @param id id of the child to remove
+ */
+ public void removeChild(Object id);
+
+ /**
+ * getter for parent {@link TreeNode}
+ * @return parent {@link TreeNode} instance or <code>null</code> if this
node is root
+ */
+ public TreeNode getParent();
+ /**
+ * setter for parent {@link TreeNode}
+ * @param parent {@link TreeNode} to set as parent
+ */
+ public void setParent(TreeNode parent);
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNodeImpl.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNodeImpl.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNodeImpl.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeNodeImpl.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ * Default {@link TreeNode} implementation based on {@link LinkedHashMap} to preserve
+ * elements ordering
+ */
+public class TreeNodeImpl implements TreeNode {
+
+ private static final long serialVersionUID = -5498990493803705085L;
+ private Object data;
+ private TreeNode parent;
+
+ private Map childrenMap = new LinkedHashMap();
+
+ public Object getData() {
+ return data;
+ }
+
+ public TreeNode getChild(Object identifier) {
+ return (TreeNode) childrenMap.get(identifier);
+ }
+
+ public void addChild(Object identifier, TreeNode child) {
+ child.setParent(this);
+ childrenMap.put(identifier, child);
+ }
+
+ public void removeChild(Object identifier) {
+ TreeNode treeNode = (TreeNode) childrenMap.remove(identifier);
+ if (treeNode != null) {
+ treeNode.setParent(null);
+ }
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+ public TreeNode getParent() {
+ return parent;
+ }
+
+ public void setParent(TreeNode parent) {
+ this.parent = parent;
+ }
+
+ public Iterator getChildren() {
+ return childrenMap.entrySet().iterator();
+ }
+
+ public boolean isLeaf() {
+ return childrenMap.isEmpty();
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeRowKey.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeRowKey.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeRowKey.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/TreeRowKey.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,85 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 06.12.2006
+ * Base abstract clas for all tree row keys
+ */
+public abstract class TreeRowKey implements Serializable {
+
+ public static final char SEPARATOR_ESCAPE_CHAR = '_';
+
+ /**
+ * getter for key depth
+ * @return key depth
+ */
+ public abstract int depth();
+
+ /**
+ * getter for subpath iterator
+ * @param fromIndex
+ * @return subpath segments iterator
+ */
+ public abstract Iterator getSubPathIterator(int fromIndex);
+
+ /**
+ * getter for path string representation
+ * @return path string
+ */
+ public abstract String getPath();
+
+ public String toString() {
+ return getPath();
+ }
+
+ /**
+ * tests if specified rowKey is sub-key of this row key
+ * @param rowKey
+ * @return
+ */
+ public boolean isSubKey(TreeRowKey rowKey) {
+ if (rowKey == null) {
+ return false;
+ }
+
+ return (rowKey.getPath() + AbstractTreeDataModel.SEPARATOR).startsWith(getPath());
+ }
+
+ /**
+ * getter for path iterator
+ * @return path segments iterator
+ */
+ public abstract Iterator iterator();
+
+ /**
+ * returns this row key and otherRowKey argument row key common path segments count
+ * @param otherRowKey {@link TreeRowKey} to count common path segments for
+ * @return common path segmments count
+ */
+ public abstract int getCommonPathLength(TreeRowKey otherRowKey);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.events;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class AjaxSelectedEvent extends NodeSelectedEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1156974665865521208L;
+
+ public AjaxSelectedEvent(UIComponent component) {
+ super(component);
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.events;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public class NodeExpandedEvent extends FacesEvent {
+
+ public NodeExpandedEvent(UIComponent component) {
+ super(component);
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2620359072575831666L;
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof NodeExpandedListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((NodeExpandedListener) listener).processExpansion(this);
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedListener.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeExpandedListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.events;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public interface NodeExpandedListener extends FacesListener {
+ public void processExpansion(NodeExpandedEvent nodeExpandedEvent) throws
AbortProcessingException;
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.events;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public class NodeSelectedEvent extends FacesEvent {
+
+ public NodeSelectedEvent(UIComponent component) {
+ super(component);
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1292268859927735863L;
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof NodeSelectedListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+
+ public void processListener(FacesListener listener) {
+ ((NodeSelectedListener) listener).processSelection(this);
+ }
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedListener.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/events/NodeSelectedListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.events;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public interface NodeSelectedListener extends FacesListener {
+ public void processSelection(NodeSelectedEvent nodeSelectedEvent) throws
AbortProcessingException;
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeRange.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeRange.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeRange.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,35 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.state;
+
+import org.ajax4jsf.ajax.repeat.Range;
+import org.richfaces.component.TreeRowKey;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 23.11.2006
+ *
+ */
+public interface TreeRange extends Range {
+ public boolean processNode(TreeRowKey rowKey);
+ public boolean processChildren(TreeRowKey rowKey);
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.state;
+
+import org.richfaces.component.UITree;
+
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 19.06.2007
+ *
+ * This interface is intended to "advising" changes to tree state. Tree
component should queue user-provided
+ * instance of the interface for changes during RENDER_RESPONSE phase. Changes advised by
user should be
+ * immediately applied. Advisor methods are provided with {@link UITree} component
instance to queue current
+ * tree state.
+ */
+public interface TreeStateAdvisor {
+ /**
+ * Advises new node opened/closed state
+ * @param tree {@link UITree} component state to queue state
+ * @return
+ * <ul>
+ * <li><code>null</code> if changes are not needed</li>
+ * <li>{@link Boolean#TRUE} to advise node to be opened</li>
+ * <li>{@link Boolean#FALSE} to advise node to be closed</li>
+ * </ul>
+ */
+ public Boolean adviseNodeOpened(UITree tree);
+
+ /**
+ * Advises new node selection
+ * @param tree {@link UITree} component state to queue state
+ * @return
+ * <ul>
+ * <li><code>null</code> if changes are not needed</li>
+ * <li>{@link Boolean#TRUE} to advise current node to be selected</li>
+ * <li>{@link Boolean#FALSE} to advise current node to be
unselected</li>
+ * </ul>
+ */
+ public Boolean adviseNodeSelected(UITree tree);
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlNodeData.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.xml;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ *
+ */
+public class XmlNodeData implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8320619478974873168L;
+
+ private String namespace;
+
+ private String name = "";
+
+ private String text;
+
+ private Map attributes = new HashMap();
+
+ public Map getAttributes() {
+ return attributes;
+ }
+
+ public void setAttribute(String key, Object value) {
+ this.attributes.put(key, value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text != null ? text : "";
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String toString() {
+ return getName() + "{" + attributes.toString() + " <" +
getText().trim() + ">" + "}";
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
(from rev 1388,
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,164 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.xml;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.RulesBase;
+import org.richfaces.component.TreeNode;
+import org.richfaces.component.TreeNodeImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ *
+ */
+public class XmlTreeDataBuilder {
+
+ private final static class Rule extends org.apache.commons.digester.Rule {
+ private int level = -1;
+ private List idsList = new ArrayList();
+ private List treeNodesList = new ArrayList();
+ private List exclusionSets = new ArrayList();
+ private TreeNode treeNode = new TreeNodeImpl(); //add empty node to serve as root
+
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ super.begin(namespace, name, attributes);
+
+ level++;
+
+ XmlNodeData xmlNodeData = new XmlNodeData();
+ xmlNodeData.setName(name);
+ xmlNodeData.setNamespace(namespace);
+
+ String id = null;
+
+ if (attributes != null) {
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++) {
+ xmlNodeData.setAttribute(attributes.getQName(i),
+ attributes.getValue(i));
+
+ }
+
+ id = attributes.getValue("id");
+ }
+
+ if (exclusionSets.size() == level) {
+ exclusionSets.add(null);
+ }
+
+ if (id == null || id.length() == 0) {
+ int currentId = 0;
+
+ if (idsList.size() <= level) {
+ for (int i = idsList.size(); i <= level; i++) {
+ idsList.add(null);
+ }
+ } else {
+ Integer integer = (Integer) idsList.get(level);
+ currentId = integer.intValue() + 1;
+ }
+
+ Set exclusions = (Set) exclusionSets.get(level);
+
+ while (exclusions != null &&
exclusions.contains(Integer.toString(currentId))) {
+ currentId++;
+ }
+
+ idsList.set(level, new Integer(currentId));
+
+ id = Integer.toString(currentId);
+ } else {
+ Set exclusions = (Set) exclusionSets.get(level);
+ if (exclusions == null) {
+ exclusions = new HashSet();
+
+ exclusionSets.set(level, exclusions);
+ }
+
+ exclusions.add(id);
+ }
+
+ TreeNode node = new TreeNodeImpl();
+ node.setData(xmlNodeData);
+
+ this.treeNode.addChild(id, node);
+ this.treeNodesList.add(this.treeNode);
+ this.treeNode = node;
+ }
+
+ public void body(String namespace, String name, String text)
+ throws Exception {
+ super.body(namespace, name, text);
+
+ if (text != null) {
+ ((XmlNodeData) this.treeNode.getData()).setText(text.trim());
+ }
+ }
+
+ public void end(String namespace, String name) throws Exception {
+ super.end(namespace, name);
+
+ level--;
+
+ if (idsList.size() - 1 > level + 1) {
+ //idsList grew larger than we really need
+ idsList.remove(idsList.size() - 1);
+ }
+
+ if (exclusionSets.size() - 1 > level + 1) {
+ //the same condition as above
+ exclusionSets.remove(exclusionSets.size() - 1);
+ }
+
+ this.treeNode = (TreeNode) this.treeNodesList.remove(this.treeNodesList.size() - 1);
+ }
+ }
+
+ public static TreeNode build(InputSource inputSource) throws SAXException, IOException
{
+ Digester digester = new Digester();
+ Rule rule = new Rule();
+ final List rulesList = new ArrayList(1);
+ rulesList.add(rule);
+
+ RulesBase rulesBase = new RulesBase() {
+ protected List lookup(String namespace, String name) {
+ return rulesList;
+ }
+ };
+ digester.setRules(rulesBase);
+ digester.setNamespaceAware(true);
+ digester.parse(inputSource);
+
+ return rule.treeNode;
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
(from rev 1388,
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,71 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.FacesListener;
+import javax.faces.event.FacesEvent;
+
+/**
+ * @author Wesley Hales
+ */
+public class DataFilterSliderEvent extends FacesEvent {
+
+ private Integer oldSliderVal;
+ private Integer newSliderVal;
+
+ /**
+ * Creates a new SliderEvent.
+ *
+ * @param component the source of the event
+ * @param thisOldSliderVal the previously showing item identifier
+ * @param thisNewSliderVal the currently showing item identifier
+ */
+ public DataFilterSliderEvent(UIComponent component, Integer thisOldSliderVal, Integer
thisNewSliderVal) {
+ super(component);
+ setPhaseId(PhaseId.INVOKE_APPLICATION);
+ oldSliderVal = thisOldSliderVal;
+ newSliderVal = thisNewSliderVal;
+ }
+
+ public Integer getOldSliderVal() {
+ return oldSliderVal;
+ }
+
+ public Integer getNewSliderVal() {
+ return newSliderVal;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener){
+ return (listener instanceof DataFilterSliderListener);
+ }
+
+ /**
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener){
+ ((DataFilterSliderListener) listener).processSlider(this);
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java
(from rev 1388,
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Wesley Hales
+ */
+public interface DataFilterSliderListener extends FacesListener {
+
+ public void processSlider(org.richfaces.event.DataFilterSliderEvent event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java
(from rev 1388,
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderSource.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+/**
+ * @author Wesley Hales
+ */
+public interface DataFilterSliderSource {
+
+ /**
+ * Adds a DataFilterSliderListener to this DataFilterSliderSource.
+ *
+ * @param listener the Slider listener to be added
+ */
+ public void addSliderListener(org.richfaces.event.DataFilterSliderListener
listener);
+
+ /**
+ * Removes a DataFilterSliderListener from this DataFilterSliderSource.
+ *
+ * @param listener the Slider listener to be removed
+ */
+ public void removeSliderListener(DataFilterSliderListener listener);
+
+ /**
+ * Returns all SliderListeners for this DataFilterSliderSource.
+ *
+ * @return the Slider listener array
+ */
+ public DataFilterSliderListener[] getSliderListeners();
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerEvent.java
(from rev 1388,
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Wesley Hales
+ */
+public class DataScrollerEvent extends ActionEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2657353903701932561L;
+ private String oldScrolVal;
+ private String newScrolVal;
+
+ /**
+ * Creates a new ScrollerEvent.
+ *
+ * @param component the source of the event
+ * @param thisOldScrolVal the previously showing item identifier
+ * @param thisNewScrolVal the currently showing item identifier
+ */
+ public DataScrollerEvent(UIComponent component, String thisOldScrolVal, String
thisNewScrolVal) {
+ super(component);
+ oldScrolVal = thisOldScrolVal;
+ newScrolVal = thisNewScrolVal;
+ }
+
+ public String getOldScrolVal() {
+ return oldScrolVal;
+ }
+
+ public String getNewScrolVal() {
+ return newScrolVal;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener){
+ return super.isAppropriateListener(listener) || (listener instanceof
DataScrollerListener);
+ }
+
+ /**
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener){
+ if (listener instanceof DataScrollerListener) {
+ DataScrollerListener dataScrollerListener = (DataScrollerListener) listener;
+ dataScrollerListener.processScroller(this);
+ }
+
+ if (super.isAppropriateListener(listener)) {
+ super.processListener(listener);
+ }
+ }
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerListener.java
(from rev 1388,
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,31 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+
+public interface DataScrollerListener extends FacesListener {
+
+ public void processScroller(org.richfaces.event.DataScrollerEvent event);
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerSource.java
(from rev 1388,
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerSource.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/DataScrollerSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,47 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+public interface DataScrollerSource {
+
+ /**
+ * Adds a DataScrollerListener to this DataScrollerSource.
+ *
+ * @param listener the Scroler listener to be added
+ */
+ public void addScrollerListener(org.richfaces.event.DataScrollerListener listener);
+
+ /**
+ * Removes a DataFilterSliderListener from this DataScrollerSourceSource.
+ *
+ * @param listener the Scroler listener to be removed
+ */
+ public void removeScrollerListener(DataScrollerListener listener);
+
+ /**
+ * Returns all ScrollerListeners for this DataScrollerSource.
+ *
+ * @return the Scroler listener array
+ */
+ public DataScrollerListener[] getScrollerListeners();
+
+}
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java
(from rev 1388,
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/ISimpleToggleListener.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+
+//TODO by nick - denis - add addToggleListener method to component
+public interface ISimpleToggleListener extends FacesListener {
+
+ public void processToggle(SimpleToggleEvent event);
+
+}
\ No newline at end of file
Copied:
branches/refactor1/framework/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java
(from rev 1388,
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/SimpleToggleEvent.java)
===================================================================
---
branches/refactor1/framework/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java
(rev 0)
+++
branches/refactor1/framework/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,76 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+public class SimpleToggleEvent extends ActionEvent {
+
+ private static final long serialVersionUID = 5582624805941635421L;
+ private boolean _opened;
+
+ /**
+ * @param source
+ * @param opened
+ */
+ public SimpleToggleEvent(UIComponent source, boolean opened) {
+ super(source);
+ this._opened = opened;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof ISimpleToggleListener;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((ISimpleToggleListener) listener).processToggle(this);
+ }
+
+ /**
+ * @return Returns the _state.
+ */
+ public boolean isIsOpen() {
+ return _opened;
+ }
+
+ /**
+ *
+ * @param opened The state to set
+ */
+ public void setIsOpen(boolean opened) {
+ this._opened = opened;
+ }
+}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/ForceRender.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/ForceRender.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/ForceRender.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,57 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.ajax.AjaxRenderEvent;
-import org.ajax4jsf.framework.ajax.AjaxRenderListener;
-
-/**
- * @author shura
- *
- */
-public class ForceRender implements AjaxListener, AjaxRenderListener {
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxListener#processAjax(org.ajax4jsf.framework.ajax.AjaxEvent)
- */
- public void processAjax(AjaxEvent event) {
- UIComponent component = event.getComponent();
- AjaxRenderEvent renderEvent = new AjaxRenderEvent(component);
- renderEvent.setPhaseId(event.getPhaseId());
- component.queueEvent(renderEvent);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxRenderListener#processAjaxRender(org.ajax4jsf.framework.ajax.AjaxRenderEvent)
- */
- public void processAjaxRender(AjaxRenderEvent event) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- AjaxContext.getCurrentInstance(facesContext).renderSubmittedAjaxRegion(facesContext,false);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,10 +0,0 @@
-package org.ajax4jsf.ajax;
-
-import java.util.EventListener;
-import java.util.EventObject;
-
-public interface PushEventListener extends EventListener {
-
- public void onEvent(EventObject event);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,237 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.ActionListener;
-
-import org.ajax4jsf.framework.ajax.JavaScriptParameter;
-import org.ajax4jsf.framework.util.message.Messages;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/01 15:31:55 $
- *
- */
-public class UIActionParameter extends UIParameter implements ActionListener,
- JavaScriptParameter {
-
- public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.UIActionParameter";
-
- /***************************************************************************
- * Binding for update on ActionEvent
- */
- private ValueBinding _assignToBinding = null;
-
- public void setAssignToBinding(ValueBinding propertyBinding) {
- this._assignToBinding = propertyBinding;
- }
-
- public ValueBinding getAssignToBinding() {
- return _assignToBinding;
- }
-
- /** ********************************************************* */
-
- /***************************************************************************
- * Converter for update value with this parameter
- */
- private Converter _converter = null;
-
- public void setConverter(Converter converter) {
- this._converter = converter;
- }
-
- public Converter getConverter() {
- return _converter;
- }
-
- /** ********************************************************* */
-
- /***************************************************************************
- * Skip quota escaping of parameter value - for substitute JavaScript
- * exspression on submit
- */
- private Boolean _noEscape = null;
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.JavaScriptParameter#setNoEscape(boolean)
- */
- public void setNoEscape(boolean noEscape) {
- this._noEscape = Boolean.valueOf(noEscape);
- }
-
- private static String NO_ESCAPE_ATTR = "noEscape";
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.JavaScriptParameter#isNoEscape()
- */
- public boolean isNoEscape() {
- return isValueOrBinding(_noEscape, NO_ESCAPE_ATTR);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIParameter#getName()
- */
- public String getName() {
- String name = super.getName();
- // If name not set - use clientId. be Careful !
- if (null == name) {
- name = getClientId(FacesContext.getCurrentInstance());
- }
- return name;
- }
-
- public Object getValue() {
- Object value = super.getValue();
- // TODO - perform conversion if converter is present.
- if (null != value) {
- Class type = value.getClass();
- FacesContext context = getFacesContext();
- Converter converter = createConverter(context, type);
- if (null != converter) {
- value = converter.getAsString(context, this, value);
-
- }
-
- }
- return value;
- }
-
- /** ********************************************************* */
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.event.ActionListener#processAction(javax.faces.event.ActionEvent)
- */
- public void processAction(ActionEvent actionEvent)
- throws AbortProcessingException {
- FacesContext context = FacesContext.getCurrentInstance();
- ValueBinding updateBinding = getAssignToBinding();
- if (updateBinding != null && (!updateBinding.isReadOnly(context))) {
- Object requestValue = context.getExternalContext()
- .getRequestParameterMap().get(getName());
- if (requestValue != null && requestValue instanceof String) {
- Class type = updateBinding.getType(context);
- Converter converter = createConverter(context, type);
- if (null != converter) {
- requestValue = converter.getAsObject(context, this,
- (String) requestValue);
-
- }
- }
- if (null != requestValue) {
- updateBinding.setValue(context, requestValue);
-
- }
- }
- }
-
- /**
- * @param context
- * @param type
- * @return
- * @throws FacesException
- */
- private Converter createConverter(FacesContext context, Class type)
- throws FacesException {
- Converter converter = getConverter();
- if (converter == null && type != null && !type.equals(String.class)
- && !type.equals(Object.class)) {
- try {
- converter = context.getApplication().createConverter(type);
- } catch (Exception e) {
- throw new FacesException(Messages.getMessage(
- Messages.NO_CONVERTER_REGISTERED, type.getName()), e);
- }
- }
- return converter;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext)
- */
- public void restoreState(FacesContext context, Object state) {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
- // restore fields values
- _assignToBinding = (ValueBinding) UIComponentBase.restoreAttachedState(
- context, values[1]);
- _noEscape = (Boolean) values[2];
- _converter = (Converter) UIComponentBase.restoreAttachedState(context,
- values[3]);
- ;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- Object values[] = new Object[4];
- values[0] = super.saveState(context);
- // save fields values
- values[1] = UIComponentBase
- .saveAttachedState(context, _assignToBinding);
- values[2] = _noEscape;
- values[3] = UIComponentBase.saveAttachedState(context, _converter);
- return ((Object) (values));
- }
-
- /**
- * @param field -
- * value of field to get.
- * @param name -
- * name of field, to get from ValueBinding
- * @return boolean value, based on field or valuebinding.
- */
- private boolean isValueOrBinding(Boolean field, String name) {
- if (null != field) {
- return field.booleanValue();
- }
- ValueBinding vb = getValueBinding(name);
- if (null != vb) {
- return ((Boolean) vb.getValue(getFacesContext())).booleanValue();
- } else {
- return false;
- }
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:28 $
- *
- */
-public abstract class UIAjaxCommandButton extends AjaxActionComponent {
- public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.CommandButton";
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
- *
- */
-public abstract class UIAjaxCommandLink extends AjaxActionComponent {
-
- public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.CommandLink";
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,176 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.util.Iterator;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-
-import org.ajax4jsf.framework.ajax.AjaxComponent;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.ajax.AjaxSource;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-
-
-/**
- * Quite different from default <code>HtmlForm</code> - process child
components
- * not only for submitted form, but if submitted parent
<code>AjaxContainer</code>
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:22 $
- *
- */
-public abstract class UIAjaxForm extends UIForm implements AjaxComponent, AjaxSource
-{
- public static final String COMPONENT_TYPE = "org.ajax4jsf.Form";
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponent#processDecodes(javax.faces.context.FacesContext)
- */
- public void processDecodes(javax.faces.context.FacesContext context)
- {
- if (context == null) {
- throw new NullPointerException("context");
- }
- decode(context);
- if (mustProcessed(context))
- {
- for (Iterator it = getFacetsAndChildren(); it.hasNext();)
- {
- UIComponent childOrFacet = (UIComponent) it.next();
- childOrFacet.processDecodes(context);
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponent#processValidators(javax.faces.context.FacesContext)
- */
- public void processValidators(javax.faces.context.FacesContext context)
- {
- if (context == null) throw new NullPointerException("context");
- if (mustProcessed(context))
- {
- for (Iterator it = getFacetsAndChildren(); it.hasNext();)
- {
- UIComponent childOrFacet = (UIComponent) it.next();
- childOrFacet.processValidators(context);
- }
- }
- }
-
-
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponent#processUpdates(javax.faces.context.FacesContext)
- */
- public void processUpdates(javax.faces.context.FacesContext context)
- {
- if (context == null) throw new NullPointerException("context");
- if (mustProcessed(context))
- {
- for (Iterator it = getFacetsAndChildren(); it.hasNext();)
- {
- UIComponent childOrFacet = (UIComponent) it.next();
- childOrFacet.processUpdates(context);
- }
- }
- }
-
- /**
- * Test for condition processing decoders/validators/updates
- * @param context current <code>FacesContext</code>
- * @return true if submitted parent AjaxContainer or current form.
- */
- private boolean mustProcessed(FacesContext context)
- {
-// if ( !AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
- if (!isSubmitted() ) {
- return false;
- }
-// }
- return true;
- }
-
-
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- // perform default
- super.broadcast(event);
- if (event instanceof AjaxEvent) {
- // complete re-Render fields. AjaxEvent deliver before render response.
- setupReRender();
- }
- }
-
-
- /**
- * Template methods for fill set of resions to render in subclasses.
- */
- protected void setupReRender() {
- FacesContext context = getFacesContext();
- AjaxContext.getCurrentInstance(context).addRegionsFromComponent(this);
- }
-
-
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
- */
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
- */
- public AjaxListener[] getAjaxListeners() {
- AjaxListener al[] = (AjaxListener [])
- getFacesListeners(AjaxListener.class);
- return (al);
-
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
- */
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
-
- }
-
- public abstract boolean isAjaxSubmit();
-
- public abstract void setAjaxSubmit(boolean ajax);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:04 $
- *
- */
-public abstract class UIAjaxFunction extends AjaxActionComponent {
-
- public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Function";
-
- public abstract String getName();
-
- public abstract void setName(String name);
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import javax.faces.component.UIComponentBase;
-
-/**
- * @author shura
- *
- */
-public abstract class UIAjaxLog extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.Log";
-
- public abstract String getHotkey();
-
- public abstract void setHotkey(String newvalue);
-
- public abstract String getName();
- public abstract void setName(String newvalue);
-
- public abstract String getWidth();
- public abstract void setWidth(String newvalue);
-
- public abstract String getHeight();
- public abstract void setHeight(String newvalue);
-
- public abstract String getLevel();
- public abstract void setLevel(String newvalue);
-
- public abstract boolean isPopup();
- public abstract void setPopup(boolean popup);
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import javax.faces.component.UIPanel;
-
-import org.ajax4jsf.framework.ajax.AjaxOutput;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
- *
- */
-public abstract class UIAjaxOutputPanel extends UIPanel implements AjaxOutput {
-
- public static final String COMPONENT_TYPE =
"org.ajax4jsf.ajax.OutputPanel";
- /**
- * @return
- */
- public abstract String getLayout();
-
- public abstract void setLayout(String layout);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,249 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIPanel;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.ajax.AjaxRegionBrige;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
-import org.ajax4jsf.framework.ajax.InvokerCallback;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:06 $
- *
- */
-public abstract class UIAjaxRegion extends UIPanel implements AjaxContainer {
-
- private AjaxRegionBrige brige;
-
- public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.AjaxRegion";
-
- /**
- *
- */
- public UIAjaxRegion() {
- brige = new AjaxRegionBrige(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
- */
-// public void encodeBegin(FacesContext context) throws IOException {
-// UIViewRoot root = context.getViewRoot();
-// if (root instanceof AjaxViewRoot) {
-// ((AjaxViewRoot) root).addAjaxRegion(this);
-// }
-// super.encodeBegin(context);
-// }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- try {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- ajax.encodeAjax(context);
- } else {
- // Container not found, use Root for encode.
- encodeAjax(context);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- try {
- encodeAjax(context);
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
- };
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
- */
- public void encodeChildren(FacesContext context) throws IOException {
- // If this region is single child of ViewRoot, encode Ajax response for
- // submitted container.
- UIViewRoot viewRoot = context.getViewRoot();
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if ( (getParent() == viewRoot) &&
- (viewRoot instanceof AjaxViewRoot) &&
- ((AjaxViewRoot) viewRoot).isHavePage() &&
- (ajaxContext.isAjaxRequest())) {
- AjaxContext.invokeOnRegionOrRoot((AjaxViewRoot) viewRoot, context, _ajaxInvoker);
- } else {
- super.encodeChildren(context);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
- brige.broadcast(event);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
- */
- public MethodBinding getAjaxListener() {
- return brige.getAjaxListener();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
- */
- public boolean isImmediate() {
- return brige.isImmediate();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
- */
- public boolean isSubmitted() {
- return brige.isSubmitted();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- Object[] mystate = (Object[]) state;
- super.restoreState(context, mystate[0]);
- brige.restoreState(context, mystate[1]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
- state[0] = super.saveState(context);
- state[1] = brige.saveState(context);
- return state;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
- */
- public void setAjaxListener(MethodBinding ajaxListener) {
- brige.setAjaxListener(ajaxListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- brige.setImmediate(immediate);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
- */
- public void setSubmitted(boolean submitted) {
- brige.setSubmitted(submitted);
- }
-
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
- public AjaxListener[] getAjaxListeners() {
- return (AjaxListener[]) getFacesListeners(AjaxListener.class);
- }
-
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
- */
- public boolean isSelfRendered() {
- return brige.isSelfRendered();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
- */
- public void setSelfRendered(boolean selfRendered) {
- brige.setSelfRendered(selfRendered);
- }
-
- public void encodeAjax(FacesContext context) throws IOException {
- String rendererType = getRendererType();
- if (rendererType != null) {
- ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
- this);
- }
-
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,379 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.util.message.Messages;
-
-
-/**
- *
- * Component for create request state status area.
- * can create 2 output text areas ( <span> ) with different text and
styles.
- * if defined "start" or/and "stop" facets, it's use as conttent
- * for different state.
- * By default, "start" text/facet rendered with display = none style.
- * On client side, display style changed for elements on
- * start-stop request.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:25 $
- *
- */
-public class UIAjaxStatus extends UIComponentBase
-{
-
- private static final String COMPONENT_FAMILY = "javax.faces.Output";
- public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.AjaxStatus";
-
-
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- /**
- * id of form for wich status will displayed
- */
- private String _for = null;
-
- /**
- *
- * @param new value of id of form for wich status will displayed to set
- */
- public void setFor(String _for)
- {
- this._for = _for;
- }
-
- /**
- * @return value or result of valueBinding of id of form for wich status will
displayed
- *
- */
- public String getFor()
- {
- return (String) getValueOrBinding(_for, "for");
- }
-
- /**
- * Text to output on start request
- */
- private String _startText = null;
-
- /**
- * setter method for property
- * @param new value of Text to output on start request to set
- */
- public void setStartText(String startText)
- {
- this._startText = startText;
- }
-
- /**
- * @return value or result of valueBinding of Text to output on start request
- */
- public String getStartText()
- {
- return (String) getValueOrBinding(_startText, "startText");
- }
-
- /**
- * Text to display on complete request
- */
- private String _stopText = null;
-
- /**
- * setter method for property
- * @param new value of Text to display on complete request to set
- */
- public void setStopText(String stopText)
- {
- this._stopText = stopText;
- }
-
- /**
- * @return value or result of valueBinding of Text to display on complete request
- */
- public String getStopText()
- {
- return (String) getValueOrBinding(_stopText, "stopText");
- }
- /**
- * Style for display on start request
- */
- private String _startStyle = null;
-
- /**
- * setter method for property
- * @param new value of Style for display on start request to set
- */
- public void setStartStyle(String startStyle)
- {
- this._startStyle = startStyle;
- }
-
- /**
- * @return value or result of valueBinding of Style for display on start request
- */
- public String getStartStyle()
- {
- return (String) getValueOrBinding(_startStyle, "startStyle");
- }
- /**
- * Style for displaying on complete
- */
- private String _stopStyle = null;
-
- /**
- * setter method for property
- * @param new value of Style for displaying on complete to set
- */
- public void setStopStyle(String stopStyle)
- {
- this._stopStyle = stopStyle;
- }
-
- /**
- * @return value or result of valueBinding of Style for displaying on complete
- */
- public String getStopStyle()
- {
- return (String) getValueOrBinding(_stopStyle, "stopStyle");
- }
- /**
- * Style class for display on request
- */
- private String _startStyleClass = null;
-
- /**
- * setter method for property
- * @param new value of Style class for display on request to set
- */
- public void setStartStyleClass(String startStyleClass)
- {
- this._startStyleClass = startStyleClass;
- }
-
- /**
- * @return value or result of valueBinding of Style class for display on request
- */
- public String getStartStyleClass()
- {
- return (String) getValueOrBinding(_startStyleClass,
"startStyleClass");
- }
- /**
- * Style class for display on complete request
- */
- private String _stopStyleClass = null;
-
- /**
- * setter method for property
- * @param new value of Style class for display on complete request to set
- */
- public void setStopStyleClass(String stopStyleClass)
- {
- this._stopStyleClass = stopStyleClass;
- }
-
-
- /**
- * Force id to render in Html as is
- */
- private boolean _forceId = false;
- private boolean _forceIdSet = false;
-
- /**
- * setter method for property
- * @param new value of Force id to render in Html as is to set
- */
- public void setForceId(boolean forceId)
- {
- this._forceId = forceId;
- this._forceIdSet = true;
- }
-
- /**
- * @return value or result of valueBinding of Force id to render in Html as is
- */
- public boolean isForceId()
- {
- return isValueOrBinding(_forceId, _forceIdSet, "forceId");
- }
-
-
-
-
- private String _clientId = null;
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#getClientId(javax.faces.context.FacesContext)
- */
- public String getClientId(FacesContext context) {
- if (null == _clientId) {
- String forValue = getFor();
- UIComponent container;
- if (null != forValue) {
- container = findComponent(forValue);
- // 'for' attribute must be pointed to real container in view tree
- if (null == container || !(container instanceof AjaxContainer)) {
- throw new FacesException(
- Messages.getMessage(Messages.FOR_TARGETS_NO_AJAX_CONTAINER, getId()));
- }
- _clientId = container.getClientId(context) + ":status";
-
- } else if (isForceId()) {
- _clientId = getRenderer(context).convertClientId(context,
- this.getId());
- } else if (null !=(container = (UIComponent)
AjaxRendererUtils.findAjaxContainer(context,this))) {
- _clientId = container.getClientId(context) + ":status";
- } else {
- _clientId = super.getClientId(context);
- }
- }
- return _clientId;
- }
-
-
- /* (non-Javadoc)
- * reset clientId for calculate
- * @see javax.faces.component.UIComponentBase#setId(java.lang.String)
- */
- public void setId(String arg0) {
- super.setId(arg0);
- _clientId = null;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state)
- {
- State myState = (State) state;
- _for = myState._for;
- _startText = myState._startText;
- _stopText = myState._stopText;
- _startStyle = myState._startStyle;
- _stopStyle = myState._stopStyle;
- _startStyleClass = myState._startStyleClass;
- _stopStyleClass = myState._stopStyleClass;
- _forceId = myState._forceId;
- _forceIdSet = myState._forceIdSet;
- super.restoreState(context, myState.superState);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context)
- {
- State state = new State();
- state._for = _for;
- state._startText = _startText;
- state._stopText = _stopText;
- state._startStyle = _startStyle;
- state._stopStyle = _stopStyle;
- state._startStyleClass = _startStyleClass;
- state._stopStyleClass = _stopStyleClass;
- state._forceId = _forceId;
- state._forceIdSet = _forceIdSet;
- state.superState = super.saveState(context);
- return state;
- }
-
- /**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:25 $
- * Memento pattern state class for save-restore component.
- */
- public static class State implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 317266574102385358L;
- Object superState;
- String _for;
- String _startText;
- String _stopText;
- String _startStyle;
- String _stopStyle;
- String _startStyleClass;
- String _stopStyleClass;
- boolean _forceIdSet;
- boolean _forceId;
- }
-
- /**
- * @return value or result of valueBinding of Style class for display on complete
request
- */
- public String getStopStyleClass()
- {
- return (String) getValueOrBinding(_stopStyleClass, "stopStyleClass");
- }
-
- /**
- * @param field - value of field to get.
- * @param name - name of field, to get from ValueBinding
- * @return field or value of binding expression.
- */
- private Object getValueOrBinding(Object field, String name){
- if( null != field){
- return field;
- }
- ValueBinding vb = getValueBinding(name);
- if (null != vb) {
- return vb.getValue(getFacesContext());
- } else {
- return null;
- }
-
- }
-
- /**
- * @param field - value of field to get.
- * @param name - name of field, to get from ValueBinding
- * @return boolean value, based on field or valuebinding.
- */
- private boolean isValueOrBinding(boolean field, boolean fieldSet, String name){
- if( fieldSet ){
- return field;
- }
- ValueBinding vb = getValueBinding(name);
- if (null != vb) {
- return ((Boolean)vb.getValue(getFacesContext())).booleanValue();
- } else {
- return false;
- }
-
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,233 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-import org.ajax4jsf.framework.ajax.AjaxSupport;
-import org.ajax4jsf.framework.ajax.EventValueBinding;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Component for append ajax functions to any control component.
- * Append action functionality to non-action control,
- * setup javascript events for parent component,
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:52 $
- *
- */
-public abstract class UIAjaxSupport extends AjaxActionComponent implements AjaxSupport
-{
-
- //~ Static fields/initializers ---------------------------------------------
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Support";
- public static final String COMPONENT_FAMILY = "javax.faces.Command";
- public static final String DEFAULT_RENDERER_TYPE =
"org.ajax4jsf.components.AjaxSupportRenderer";
- public static final String AJAX_SUPPORT_SET =
"com.exadel.components.ajax.support.";
- private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
-
- /**
- * Name of JavaScript function, called before submit Ajax request
- * description
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOnsubmit();
-
- /**
- * @param newOnsubmit the value to set
- */
- public abstract void setOnsubmit(String newOnsubmit);
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String,
javax.faces.el.ValueBinding)
- */
- public void setValueBinding(String arg0, ValueBinding arg1) {
- // var - not allowed name. must be literal.
- if("var".equals(arg0)){
- throw new FacesException(
- Messages.getMessage(Messages.VAR_MUST_BE_LITERAL, getClientId(getFacesContext())));
- }
- if("event".equals(arg0)){
- throw new FacesException(
- Messages.getMessage(Messages.EVENT_MUST_BE_LITERAL,
getClientId(getFacesContext())));
- }
- super.setValueBinding(arg0, arg1);
- }
-
- /**
- * Create Special <code>ValueBinding</code> for build JavaScrept
- * event code in parent component from this.
- * @return <code>EventValueBinding</code> based on properties of current
component
- */
- private ValueBinding getEventValueBinding()
- {
- if (log.isDebugEnabled())
- {
- log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT, getId()));
- }
- return new EventValueBinding(this);
- }
-
- /**
- * @return JavaScript eventString. Rebuild on every call, since
- * can be in loop ( as in dataTable ) with different parameters.
- */
- public String getEventString()
- {
- StringBuffer buildOnEvent = new StringBuffer();
- String onsubmit = getOnsubmit();
- // Insert script to call before submit ajax request.
- if (null != onsubmit) {
- buildOnEvent.append(onsubmit).append(";");
- }
- // Due to JSF RI 1.1 bug, clear cached clientId
- setId(getId());
- buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(),
- getEvent()));
- String script = buildOnEvent.toString();
- return script;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
- */
- public void decode(FacesContext context) {
- // Due to JSF RI 1.1 bug, clear cached clientId
- setId(getId());
- super.decode(context);
- }
-
- /**
- * After nornal setting <code>parent</code> property in case of
- * created component set Ajax properties for parent.
- * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
- */
- public void setParent(UIComponent parent)
- {
- super.setParent(parent);
- if (null != parent && parent.getFamily() != null ) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
parent.getClass().getName()));
- }
- // TODO If this comopnent configured, set properties for parent component.
- // NEW created component have parent, restored view - null in My faces.
- // and SUN RI not call at restore saved view.
- // In other case - set in restoreState method.
- // if (parent.getParent() != null)
- {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
- }
- setParentProperties(parent);
-
- }
- }
- }
-
- public void setParentProperties(UIComponent parent) {
- ValueBinding valueBinding;
-// Map parentAttributes = parent.getAttributes();
-/* if (parent instanceof ActionSource && null == getEvent())
- {
- log.debug("Set properties for parent as ActionSource");
- // Translate AJAX properties to parent component.
- if (_reRender != null)
- {
- parentAttributes
- .put(AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
- _reRender);
- }
- else if ((valueBinding = getValueBinding("reRender")) != null)
- {
- parent.setValueBinding(
- AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
- valueBinding);
- }
- if (_oncomplete != null)
- {
- parentAttributes
- .put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
- _oncomplete);
- }
- else if ((valueBinding = getValueBinding("oncomplete")) != null)
- {
- parent.setValueBinding(
- AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
- valueBinding);
- }
- if (_status != null)
- {
- parentAttributes.put(AjaxRendererUtils.STATUS_ATTR_NAME,
- _status);
- }
- else if ((valueBinding = getValueBinding("status")) != null)
- {
- parent.setValueBinding(AjaxRendererUtils.STATUS_ATTR_NAME,
- valueBinding);
- }
- if (_limitToListSet)
- {
- parentAttributes.put(
- AjaxRendererUtils.LIMITTOLIST_ATTR_NAME, Boolean
- .valueOf(_limitToList));
- }
- else if ((valueBinding = getValueBinding("limitToList")) != null)
- {
- parent.setValueBinding(
- AjaxRendererUtils.LIMITTOLIST_ATTR_NAME,
- valueBinding);
- }
- // Add Listener for all supported types.
- AjaxRegionListener listener = new AjaxRegionListener();
- ((ActionSource) parent).addActionListener(listener);
- }
- else*/ if (null != getEvent())
- {
- if (log.isDebugEnabled())
- {
- log.debug(Messages.getMessage(Messages.SET_VALUE_BINDING_FOR_EVENT,
getEvent()));
- }
- // for non action/data components, or for non-default events - build listener
for this instance.
- valueBinding = getEventValueBinding();
- // test for valid event attribute name.
- // TODO - test for compability with concrete element.
- parent.setValueBinding(getEvent(), valueBinding);
- }
-
- }
-
- protected UIComponent getSingleComponent() {
- return getParent();
- }
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIInclude.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIInclude.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIInclude.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,304 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxOutput;
-import org.ajax4jsf.framework.ajax.ViewIdHolder;
-
-/**
- * @author shura
- *
- */
-public abstract class UIInclude extends UIComponentBase implements
- ViewIdHolder, NamingContainer, AjaxOutput {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.Include";
-
- public static final String LAYOUT_NONE ="none";
-
- public static final String LAYOUT_BLOCK ="block";
- public static final String LAYOUT_INLINE ="inline";
-
- private boolean wasNavigation = false;
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.ViewIdHolder#skipNavigation(java.lang.String)
- */
- public boolean skipNavigation(String ViewId) {
- wasNavigation = true;
- return true;
- }
-
- private String _viewId = null;
-
- /*
- * viewId for included page. Setter for viewId @param viewId - new value
- */
- public void setViewId(String __viewId) {
- ValueBinding vb = getValueBinding("viewId");
- FacesContext facesContext = getFacesContext();
- if (null != vb && (!vb.isReadOnly(facesContext))) {
- // Change value of viewId in backed bean, if possible.
- vb.setValue(facesContext, __viewId);
- } else {
- this._viewId = __viewId;
- }
- }
-
- /*
- * viewId for included page. Getter for viewId @return viewId value from
- * local variable or value bindings
- */
- public String getViewId() {
- if (null != this._viewId) {
- return this._viewId;
- }
- ValueBinding vb = getValueBinding("viewId");
- if (null != vb) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- private String _layout = null;
-
- /**
- * @return the layout
- */
- public String getLayout() {
- if (null != this._layout) {
- return this._layout;
- }
- ValueBinding vb = getValueBinding("layout");
- if (null != vb) {
- return (String) vb.getValue(getFacesContext());
- } else {
- return null;
- }
- }
-
- /**
- * @param layout the layout to set
- */
- public void setLayout(String layout) {
- _layout = layout;
- }
-
-
- public boolean isAjaxRendered() {
- return (!LAYOUT_NONE.equals(getLayout())) && wasNavigation;
- }
-
- public void setAjaxRendered(boolean ajaxRendered) {
- // unsupported
- }
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- if (event instanceof EventWrapper) {
- FacesEvent wrapped = ((EventWrapper) event).getWrapped();
- FacesContext context = getFacesContext();
- ViewIdHolder holder = setupNavigation(context);
- wrapped.getComponent().broadcast(wrapped);
- restoreNavigation(context, holder);
- } else {
- super.broadcast(event);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#processDecodes(javax.faces.context.FacesContext)
- */
- public void processDecodes(FacesContext context) {
- wasNavigation = false;
- ViewIdHolder holder = setupNavigation(context);
- super.processDecodes(context);
- restoreNavigation(context, holder);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#processUpdates(javax.faces.context.FacesContext)
- */
- public void processUpdates(FacesContext context) {
- ViewIdHolder holder = setupNavigation(context);
- super.processUpdates(context);
- restoreNavigation(context, holder);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#processValidators(javax.faces.context.FacesContext)
- */
- public void processValidators(FacesContext context) {
- ViewIdHolder holder = setupNavigation(context);
- super.processValidators(context);
- restoreNavigation(context, holder);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
- */
- public void queueEvent(FacesEvent event) {
- EventWrapper wrapper = new EventWrapper(this, event);
- super.queueEvent(wrapper);
- }
-
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- Object[] componentState = (Object[]) state;
- super.restoreState(context, componentState[0]);
- this._viewId = (String) componentState[1];
- this._layout = (String) componentState[2];
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- Object[] componentState = new Object[3];
- componentState[0] = super.saveState(context);
- componentState[1] = _viewId;
- componentState[2] = _layout;
- return componentState;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily() {
- // TODO Auto-generated method stub
- return null;
- }
-
- private ViewIdHolder setupNavigation(FacesContext context) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ViewIdHolder viewIdHolder = ajaxContext.getViewIdHolder();
- ajaxContext.setViewIdHolder(this);
- return viewIdHolder;
- }
-
- private void restoreNavigation(FacesContext context, ViewIdHolder viewIdHolder) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ajaxContext.setViewIdHolder(viewIdHolder);
-// if (wasNavigation) {
-// // Clear children to avoid have different components with same id
-// getChildren().clear();
-// }
- }
-
- private static class EventWrapper extends FacesEvent {
-
- private FacesEvent wrapped;
-
- public EventWrapper(UIComponent component, FacesEvent wrapped) {
- super(component);
- this.wrapped = wrapped;
- }
-
- /**
- * @return
- * @see javax.faces.event.FacesEvent#getPhaseId()
- */
- public PhaseId getPhaseId() {
- return wrapped.getPhaseId();
- }
-
- /**
- * @param listener
- * @return
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return wrapped.isAppropriateListener(listener);
- }
-
- /**
- * @param listener
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- wrapped.processListener(listener);
- }
-
- /**
- *
- * @see javax.faces.event.FacesEvent#queue()
- */
- public void queue() {
- wrapped.queue();
- }
-
- /**
- * @param phaseId
- * @see javax.faces.event.FacesEvent#setPhaseId(javax.faces.event.PhaseId)
- */
- public void setPhaseId(PhaseId phaseId) {
- wrapped.setPhaseId(phaseId);
- }
-
- /**
- * @return the wrapped
- */
- public FacesEvent getWrapped() {
- return wrapped;
- }
- }
-
- /**
- * @return the wasNavigation
- */
- public boolean isWasNavigation() {
- return wasNavigation;
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,127 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public abstract class UILoadBundle extends UIComponentBase {
-
- public static final String COMPONENT_FAMILY = "org.ajax4jsf.Bundle";
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Bundle";
-
- private static final Log _log = LogFactory.getLog(UILoadBundle.class);
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily() {
- // TODO Auto-generated method stub
- return COMPONENT_FAMILY;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
- */
- public void encodeBegin(FacesContext context) throws IOException {
- loadBundle(context);
-
- }
-
- public void decode(FacesContext context) {
- loadBundle(context);
- }
- /**
- * @param context
- */
- public void loadBundle(FacesContext context) {
- UIViewRoot viewRoot = context.getViewRoot();
- Locale locale = viewRoot.getLocale();
- if (locale == null) {
- locale = context.getApplication().getDefaultLocale();
- }
-
- ResourceBundle bundle;
- try {
- bundle = ResourceBundle.getBundle(getBasename(), locale, Thread
- .currentThread().getContextClassLoader());
- } catch (MissingResourceException e) {
- _log.error(Messages.getMessage(Messages.COULD_NOT_LOAD_RESOURCE_BUNDLE,
getBasename()));
- return;
- }
-
- context.getExternalContext().getRequestMap().put(getVar(),
- new ResourceBundleMap(bundle));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#getRendererType()
- */
- public String getRendererType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @return Returns the basename.
- */
- public abstract String getBasename();
-
- /**
- * @param basename
- * The basename to set.
- */
- public abstract void setBasename(String basename);
-
- /**
- * @return Returns the var.
- */
- public abstract String getVar();
-
- /**
- * @param var
- * The var to set.
- */
- public abstract void setVar(String var);
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPoll.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPoll.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPoll.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,76 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-
-/**
- * Component for periodically call AJAX events on server ( poll actions )
- * @author shura
- *
- */
-public abstract class UIPoll extends AjaxActionComponent {
-
- public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Poll";
-
-
- private transient boolean _submitted = false;
-
- /**
- * @return the submitted
- */
- public boolean isSubmitted() {
- return _submitted;
- }
-
-
- /**
- * @param submitted the submitted to set
- */
- public void setSubmitted(boolean submitted) {
- _submitted = submitted;
- }
-
- /**
- * @return time in mc for polling interval.
- */
- public abstract int getInterval();
-
- /**
- * @param interval time in mc for polling interval.
- */
- public abstract void setInterval(int interval);
-
- public abstract boolean isEnabled();
-
- public abstract void setEnabled(boolean enable);
-
- protected void setupReRender(FacesContext facesContext) {
- super.setupReRender(facesContext);
- AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(this);
- }
-
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPortlet.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPortlet.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPortlet.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,66 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.ajax;
-
-import java.lang.reflect.Method;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov
- *
- */
-public class UIPortlet extends UIComponentBase implements NamingContainer {
-
- private static final Log _log = LogFactory.getLog(UIPortlet.class);
- /**
- * <p>The standard component type for this component.</p>
- */
- public static final String COMPONENT_TYPE = "org.ajax4jsf.Portlet";
-
-
- /**
- * <p>The standard component family for this component.</p>
- */
- public static final String COMPONENT_FAMILY = "org.ajax4jsf.Portlet";
-
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily() {
- // TODO Auto-generated method stub
- return COMPONENT_FAMILY;
- }
-
- private String portletId = null;
-
- // ----------------------------------------------------- UIComponent Methods
- public String getClientId(FacesContext context) {
- if (portletId == null) {
- Object response = context.getExternalContext().getResponse();
- Class portletResponseClass = response.getClass();
- // Class.forName is used instead of instanceof to account for the case
- // where the porletPage tag is used in a webapp and portlet.jar is not
- // in classpath. In that scenario it will prevent ClassNotFoundException.
- try {
- Method method = portletResponseClass.getMethod("getNamespace", new
Class[]{});
- portletId = (String) method.invoke(response, new Object[]{});
- } catch (Exception e) {
- if(_log.isDebugEnabled()){
- _log.debug("Response is not a portlet RenderResponse");
- }
- }
- if(null == portletId){
- return super.getClientId(context);
- }
- }
- return portletId;
- }
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPush.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPush.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPush.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,111 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.IOException;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.servlet.http.HttpSession;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.xmlfilter.PollEventsManager;
-
-/**
- * Component for periodically call AJAX events on server ( poll actions )
- * @author shura
- *
- */
-public abstract class UIPush extends AjaxActionComponent {
-
- public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Push";
-
-
- private transient boolean _submitted = false;
-
- /**
- * @return the submitted
- */
- public boolean isSubmitted() {
- return _submitted;
- }
-
- public void encodeBegin(FacesContext context) throws IOException {
- MethodBinding producer = getEventProducer();
- // Subscribe events producer to push status listener.
- if(null != producer){
- producer.invoke(context, new Object[]{getListener(context)});
- }
- super.encodeBegin(context);
- }
-
- private PushEventsCounter getListener(FacesContext context){
- PollEventsManager eventsManeger = (PollEventsManager)
context.getExternalContext().getApplicationMap().get(PollEventsManager.EVENTS_MANAGER_KEY);
- return eventsManeger.getListener(getListenerId(context));
- }
-
- public String getListenerId(FacesContext context){
- Object session = context.getExternalContext().getSession(false);
- StringBuffer id = new StringBuffer();
- if(null != session && session instanceof HttpSession){
- HttpSession httpSession = (HttpSession) session;
- id.append(httpSession.getId());
- }
- id.append(context.getViewRoot().getViewId());
- id.append(NamingContainer.SEPARATOR_CHAR);
- id.append(getClientId(context));
- return id.toString();
- }
- /**
- * @param submitted the submitted to set
- */
- public void setSubmitted(boolean submitted) {
- _submitted = submitted;
- }
-
- public abstract MethodBinding getEventProducer();
-
- public abstract void setEventProducer(MethodBinding producer);
- /**
- * @return time in mc for polling interval.
- */
- public abstract int getInterval();
-
- /**
- * @param interval time in mc for polling interval.
- */
- public abstract void setInterval(int interval);
-
- public abstract boolean isEnabled();
-
- public abstract void setEnabled(boolean enable);
-
- protected void setupReRender(FacesContext facesContext) {
- super.setupReRender(facesContext);
-// AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(this);
- //getListener(facesContext).processed();
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIResource.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIResource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIResource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,49 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import javax.faces.component.UIComponentBase;
-
-/**
- * JSF component class
- *
- */
-public abstract class UIResource extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.Resource";
-
- public static final String COMPONENT_FAMILY = "org.ajax4jsf.Resource";
-
- /**
- * Get name of script to load
- * @parameter
- * @return the acceptClass
- */
- public abstract Object getSrc();
-
- /**
- * @param newSrc the value to set
- */
- public abstract void setSrc(Object newSrc);
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/AjaxDataEncoder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,43 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.util.Set;
-
-import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
-
-/**
- * Interface for iterable component, allowed for render given set of rows in ajax
response.
- * @author shura
- *
- */
-public interface AjaxDataEncoder extends AjaxChildrenEncoder {
-
- /**
- * @return Set for values of {@link ExtendedDataModel} keys, encoded in ajax response by
this component.
- */
- public Set getAjaxKeys();
-
- public void setAjaxKeys(Set ajaxKeys);
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataComponentState.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,42 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import javax.faces.component.StateHolder;
-
-/**
- * Interface for classes keeped current iterable component state, as :
- * active data objects range
- * sorting order
- * tree nodes expanded state
- *
- * @author shura
- *
- */
-public interface DataComponentState {
-
- /**
- * Build used data objects range for iteration.
- * @return
- */
- public abstract Range getRange();
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/DataVisitor.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,45 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Interface for classes, able to receive visitor processing calls from
ExtendedDataModel
- * @author shura
- *
- */
-public interface DataVisitor {
-
- /**
- * This method called back ( as visitor ) from {@link
ExtendedDataModel#walk(FacesContext, DataVisitor, Range)} for
- * each row.
- * @param context current JSF context.
- * @param rowKey current row key of DataModel
- * @param argument Implementation-specific argument
- * @throws IOException
- */
- public void process(FacesContext context,Object rowKey, Object argument) throws
IOException;
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/ExtendedDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,83 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModel;
-
-/**
- * Extesion for {@link DataModel} , for support complex data structure, like tree,
spreadsheet etc
- * in iterable components.
- * @author shura
- *
- */
-public abstract class ExtendedDataModel extends DataModel {
-
- /**
- * <p>Instead of simple <code>int</code> for current state selection,
this model can use any object for
- * select current data. Implementation depend on model, with any restrictions
:</p>
- * <ol>
- * <li> key must be {@link Serializable}.</li>
- * <li>{@link Object#toString()} method must return representation compatible with
{@link javax.faces.component.UIComponent#getClientId(javax.faces.context.FacesContext)},
- * as far as this string will be appended to clientId of iterator component.</li>
- * </ol>
- * @param key key for select current data, or null for clear selection.
- */
- public abstract void setRowKey(Object key);
-
- /**
- * @return key for selected data or <code>null</code>
- */
- public abstract Object getRowKey();
-
- /**
- * Iteration component can support save data for use at decoding/validation/update
phases to avoid unnessesary calls to original models,
- * for example - to avoid requests to database until all data is validated.
- * @return
- */
- public SerializableDataModel getSerializableModel(Range range){
- // By default, model not serializable.
- return null;
- }
-
-
- /**
- * Iterate over model by "visitor" pattern, for given range
- * @param context current JSF context.
- * @param visitor instance of {@link DataVisitor}, for process each row.
- * @param range Implementation-specific range of data keys.
- * @param argument Implementation-specific argument
- * @throws IOException
- */
- public abstract void walk(FacesContext context,DataVisitor visitor,Range range, Object
argument) throws IOException;
-
- /**
- * Create Iterator on all row keys for given range.
- * @param range - Implementation-specific range of data keys.
- * @return
- */
-// public abstract Iterator dataIterator(Range range);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/Range.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/Range.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/Range.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-/**
- * Marker interface for building iterator over dataModel values. over {@link
ExtendedDataModel} elements.
- * It can be simple min/max values for data table, but also can provide set of
expanded/collapsed nodes in tree,
- * can provide sorting order,
- * @author shura
- *
- */
-public interface Range {
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/RepeatState.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,81 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.Serializable;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author shura
- *
- */
-public class RepeatState implements DataComponentState,Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -5552520123654180445L;
-
- private int _rows = -1;
-
- private int _first = 0;
-
-
- /**
- * @return the first
- */
- public int getFirst() {
- return _first;
- }
-
- /**
- * @param first the first to set
- */
- public void setFirst(int first) {
- this._first = first;
- }
-
- /**
- * @return the rows
- */
- public int getRows() {
- return _rows;
- }
-
- /**
- * @param rows the rows to set
- */
- public void setRows(int rows) {
- this._rows = rows;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.DataComponentState#getRange()
- */
- public Range getRange() {
- // TODO Auto-generated method stub
- return new SequenceRange(getFirst(),getRows());
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,202 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModel;
-
-/**
- * @author shura
- *
- */
-public class SequenceDataModel extends ExtendedDataModel {
-
- private DataModel wrappedModel;
-
- /**
- * @param wrapped
- */
- public SequenceDataModel(DataModel wrapped) {
- super();
- this.wrappedModel = wrapped;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.ajax.repeat.ExtendedDataModel#dataIterator(org.ajax4jsf.ajax.repeat.Range)
- */
-/* public Iterator dataIterator(Range range) {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = wrapped.getRowCount();
- final int firstRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += firstRow;
- if(rowCount >=0){
- rows = Math.min(rows, rowCount);
- }
- } else if(rowCount >=0 ){
- rows = rowCount;
- }
- final int maxRow = rows;
- return new Iterator(){
-
- int rowIndex = firstRow;
-
- public boolean hasNext() {
- // TODO Auto-generated method stub
- return maxRow < 0 || rowIndex < maxRow;
- }
-
- public Object next() {
- // TODO Auto-generated method stub
- return new Integer(rowIndex++);
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
-
- };
- }
-*/
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = wrappedModel.getRowCount();
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- if(rowCount >=0){
- rows = Math.min(rows, rowCount);
- }
- } else if(rowCount >=0 ){
- rows = rowCount;
- } else {
- rows = -1;
- }
- while (rows < 0 || currentRow < rows) {
- wrappedModel.setRowIndex(currentRow);
- if(wrappedModel.isRowAvailable()){
- visitor.process(context, new Integer(currentRow), argument);
- } else {
- break;
- }
- currentRow++;
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- int index = wrappedModel.getRowIndex();
- if(index<0){
- return null;
- }
- return new Integer(index);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- if(null == key){
- wrappedModel.setRowIndex(-1);
- } else {
- Integer index = (Integer) key;
- wrappedModel.setRowIndex(index.intValue());
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- public int getRowCount() {
- // TODO Auto-generated method stub
- return wrappedModel.getRowCount();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public Object getRowData() {
- // TODO Auto-generated method stub
- return wrappedModel.getRowData();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return wrappedModel.getRowIndex();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- // TODO Auto-generated method stub
- return wrappedModel.getWrappedData();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- // TODO Auto-generated method stub
- return wrappedModel.isRowAvailable();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- wrappedModel.setRowIndex(rowIndex);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- wrappedModel.setWrappedData(data);
- }
-
- /**
- * @return the wrappedModel
- */
- protected DataModel getWrappedModel() {
- return this.wrappedModel;
- }
-
- /**
- * @param wrappedModel the wrappedModel to set
- */
- protected void setWrappedModel(DataModel wrappedModel) {
- this.wrappedModel = wrappedModel;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SequenceRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-/**
- * @author shura
- *
- */
-public class SequenceRange implements Range {
-
- private int firstRow = 0;
-
- private int rows = -1;
-
- /**
- * @return the firstRow
- */
- public int getFirstRow() {
- return firstRow;
- }
-
- /**
- * @return the rows
- */
- public int getRows() {
- return rows;
- }
-
- /**
- * @param firstRow
- * @param rows
- */
- public SequenceRange(int firstRow, int rows) {
- super();
- this.firstRow = firstRow;
- this.rows = rows;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/SerializableDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,39 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.Serializable;
-
-/**
- * Serializable version of {@link ExtendedDataModel}, for save lightweight version of
data
- *
- * @author shura
- *
- */
-public abstract class SerializableDataModel extends ExtendedDataModel implements
Serializable {
-
- /**
- * Method called after update all model values. For example, developer can update
- * database with new values of modified rows.
- */
- public abstract void update();
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,1321 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-import javax.faces.model.DataModel;
-import javax.faces.model.ListDataModel;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
-
-/**
- * Base class for iterable components, like dataTable, Tomahawk dataList,
- * Facelets repeat, tree etc., with support for partial rendering on AJAX
- * responces for one or more selected iterations.
- *
- * @author shura
- *
- */
-public abstract class UIDataAdaptor extends UIData implements AjaxDataEncoder {
-
- /**
- *
- */
- public static final String COMPONENT_STATE_ATTRIBUTE = "componentState";
-
- public final static DataModel EMPTY_MODEL = new ListDataModel(
- Collections.EMPTY_LIST);
-
- /**
- * Base class for visit data model at phases decode, validation and
- * update model
- *
- * @author shura
- *
- */
- protected abstract class ComponentVisitor implements DataVisitor {
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
- setRowKey(context, rowKey);
- if (isRowAvailable()) {
- Iterator childIterator = dataChildren();
- while (childIterator.hasNext()) {
- UIComponent component = (UIComponent) childIterator.next();
- processComponent(context, component, argument);
- }
-
- }
- }
-
- public abstract void processComponent(FacesContext context,
- UIComponent c, Object argument) throws IOException;
-
- }
-
- /**
- * Visitor for process decode on children components.
- */
- protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
-
- public void processComponent(FacesContext context, UIComponent c,
- Object argument) {
- c.processDecodes(context);
- }
-
- };
-
- /**
- * Visitor for process validation phase
- */
- protected ComponentVisitor validateVisitor = new ComponentVisitor() {
-
- public void processComponent(FacesContext context, UIComponent c,
- Object argument) {
- c.processValidators(context);
- }
-
- };
-
- /**
- * Visitor for process update model phase.
- */
- protected ComponentVisitor updateVisitor = new ComponentVisitor() {
-
- public void processComponent(FacesContext context, UIComponent c,
- Object argument) {
- c.processUpdates(context);
- }
-
- };
-
- /**
- * Base client id's of this component, for wich invoked encode...
- * methods. Component will save state and serialisable models for this
- * keys only.
- */
- private Set _encoded;
-
- /**
- * Storage for data model instances with different client id's of this
- * component. In case of child for UIData component, this map will keep
- * data models for different iterations between phases.
- */
- private Map _modelsMap = new HashMap();
-
- /**
- * Reference for curent data model
- */
- private ExtendedDataModel _currentModel = null;
-
- /**
- * States of this component for diferent iterations, same as for models.
- */
- private Map _statesMap = new HashMap();
-
- /**
- * Reference for current component state.
- */
- private DataComponentState _currentState = null;
-
- /**
- * Name of EL variable for current component state.
- */
- private String _stateVar;
-
- private String _rowKeyVar;
-
- /**
- * Key for current value in model.
- */
- private Object _rowKey = null;
-
- /**
- * Values of row keys, encoded on ajax response rendering.
- */
- private Set _ajaxKeys = null;
-
- private Object _ajaxRowKey = null;
-
- private Map _ajaxRowKeysMap = new HashMap();
-
- /**
- * Get name of EL variable for component state.
- *
- * @return the varState
- */
- public String getStateVar() {
- return _stateVar;
- }
-
- /**
- * @param varStatus
- * the varStatus to set
- */
- public void setStateVar(String varStatus) {
- this._stateVar = varStatus;
- }
-
- /**
- * @return the rowKeyVar
- */
- public String getRowKeyVar() {
- return this._rowKeyVar;
- }
-
- /**
- * @param rowKeyVar
- * the rowKeyVar to set
- */
- public void setRowKeyVar(String rowKeyVar) {
- this._rowKeyVar = rowKeyVar;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIData#getRowCount()
- */
- public int getRowCount() {
- return getExtendedDataModel().getRowCount();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIData#getRowData()
- */
- public Object getRowData() {
- return getExtendedDataModel().getRowData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIData#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return this.getExtendedDataModel().isRowAvailable();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIData#setRowIndex(int)
- */
- public void setRowIndex(int index) {
- FacesContext faces = FacesContext.getCurrentInstance();
- ExtendedDataModel localModel = getExtendedDataModel();
- // if(key == localModel.getRowIndex()){
- // return;
- // }
- // save child state
- this.saveChildState(faces);
- // Set current model row by int, but immediately get value from model.
- // for compability, complex models must provide values map between
- // integer and key value.
- localModel.setRowIndex(index);
- this._rowKey = localModel.getRowKey();
- this._clientId = null;
- boolean rowSelected = this._rowKey != null;
-
- setupVariable(faces, localModel, rowSelected);
- // restore child state
- this.restoreChildState(faces);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIData#getRowIndex()
- */
- public int getRowIndex() {
- return getExtendedDataModel().getRowIndex();
- }
-
- /**
- * Same as for int index, but for complex model key.
- *
- * @return
- */
- public Object getRowKey() {
- return this._rowKey;
- }
-
- public void setRowKey(Object key) {
- setRowKey(FacesContext.getCurrentInstance(), key);
- }
-
- /**
- * Setup current roy by key. Perform same functionality as
- * {@link UIData#setRowIndex(int)}, but for key object - it may be not
- * only row number in sequence data, but, for example - path to current
- * node in tree.
- *
- * @param faces -
- * current FacesContext
- * @param key
- * new key value.
- */
- public void setRowKey(FacesContext faces, Object key) {
- ExtendedDataModel localModel = getExtendedDataModel();
- // save child state
- this.saveChildState(faces);
- this._rowKey = key;
- this._clientId = null;
- localModel.setRowKey(key);
-
- boolean rowSelected = key != null;
-
- setupVariable(faces, localModel, rowSelected);
- // restore child state
- this.restoreChildState(faces);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.ajax.repeat.AjaxDataEncoder#getAjaxKeys()
- */
- public Set getAjaxKeys() {
- Set keys = null;
- if (this._ajaxKeys != null) {
- keys = (this._ajaxKeys);
- } else {
- ValueBinding vb = getValueBinding("ajaxKeys");
- if (vb != null) {
- keys = (Set) (vb.getValue(getFacesContext()));
- } else if(null != _ajaxRowKey){
- // If none of above exist , use row with submitted AjaxComponent
- keys = new HashSet(1);
- keys.add(_ajaxRowKey);
- }
- }
- return keys;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.ajax.repeat.AjaxDataEncoder#setAjaxKeys(java.util.Set)
- */
- public void setAjaxKeys(Set ajaxKeys) {
- this._ajaxKeys = ajaxKeys;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
- * java.lang.String, java.util.Set, java.util.Set)
- */
- public void encodeAjaxChild(FacesContext context, String path,
- final Set ids, final Set renderedAreas) throws IOException {
- resetDataModel();
-
- Renderer renderer = getRenderer(context);
- if (null != renderer && renderer instanceof AjaxChildrenRenderer) {
- // If renderer support partial encoding - call them.
- AjaxChildrenRenderer childrenRenderer = (AjaxChildrenRenderer) renderer;
- childrenRenderer.encodeAjaxChildren(context, this, path, ids,
- renderedAreas);
- } else {
- // Use simple ajax children encoding for iterate other keys.
- final AjaxChildrenRenderer childrenRenderer = getChildrenRenderer();
- final String childrenPath = path + getId() + NamingContainer.SEPARATOR_CHAR;
- ComponentVisitor ajaxVisitor = new ComponentVisitor() {
-
- public void processComponent(FacesContext context,
- UIComponent c, Object argument) throws IOException {
- childrenRenderer.encodeAjaxComponent(context, c, childrenPath,
- ids, renderedAreas);
- }
-
- };
- Set ajaxKeys = getAjaxKeys();
- if (null != ajaxKeys) {
- captureOrigValue();
- Object savedKey = getRowKey();
- setRowKey(context, null);
- Iterator fixedChildren = fixedChildren();
- while (fixedChildren.hasNext()) {
- UIComponent component = (UIComponent) fixedChildren.next();
- ajaxVisitor.processComponent(context, component, null);
- }
- for (Iterator iter = ajaxKeys.iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
- ajaxVisitor.process(context, key, null);
- }
- setRowKey(savedKey);
- restoreOrigValue();
- } else {
- iterate(context, ajaxVisitor, null);
- }
- }
- }
-
- /**
- * Instance of default renderer in ajax responses.
- */
- private AjaxChildrenRenderer _childrenRenderer = null;
-
- /**
- * getter for simple {@link AjaxChildrenRenderer} instance in case of
- * ajax responses. If default renderer not support search of children
- * for encode in ajax response, component will use this instance by
- * default.
- *
- * @return
- */
- protected AjaxChildrenRenderer getChildrenRenderer() {
- if (_childrenRenderer == null) {
- _childrenRenderer = new AjaxChildrenRenderer() {
-
- protected Class getComponentClass() {
- return UIDataAdaptor.class;
- }
-
- };
-
- }
-
- return _childrenRenderer;
- }
-
- /**
- * @return Set of values for clientId's of this component, for wich was
- * invoked "encode" methods.
- */
- protected Set getEncodedIds() {
- if (_encoded == null) {
- _encoded = new HashSet();
- }
-
- return _encoded;
- }
-
- /**
- * Setup EL variable for different iteration. Value of row data and
- * component state will be put into request scope attributes with names
- * given by "var" and "varState" bean properties.
- *
- * @param faces
- * current faces context
- * @param localModel
- * @param rowSelected
- */
- protected void setupVariable(FacesContext faces, DataModel localModel,
- boolean rowSelected) {
- Map attrs = faces.getExternalContext().getRequestMap();
- if (rowSelected && isRowAvailable()) {
- // Current row data.
- setupVariable(getVar(), attrs, localModel.getRowData());
- // Component state variable.
- setupVariable(getStateVar(), attrs, getComponentState());
- // Row key Data variable.
- setupVariable(getRowKeyVar(), attrs, getRowKey());
-
- } else {
- removeVariable(getVar(), attrs);
- removeVariable(getStateVar(), attrs);
- removeVariable(getRowKeyVar(), attrs);
- }
- }
-
- /**
- * @param var
- * @param attrs
- * @param rowData
- */
- private void setupVariable(String var, Map attrs, Object rowData) {
- if (var != null) {
- attrs.put(var, rowData);
- }
- }
-
- /**
- * @param var
- * @param attrs
- * @param rowData
- */
- private void removeVariable(String var, Map attrs) {
- if (var != null) {
- attrs.remove(var);
- }
- }
-
- /**
- * Reset data model. this method must be called twice per request -
- * before decode phase and before component encoding.
- */
- protected void resetDataModel() {
- this.setExtendedDataModel(null);
- }
-
- /**
- * Set data model. Model value will be stored in Map with key as current
- * clientId for this component, to keep models between phases for same
- * iteration in case if this component child for other UIData
- *
- * @param model
- */
- protected void setExtendedDataModel(ExtendedDataModel model) {
- this._currentModel = model;
- this._modelsMap.put(getBaseClientId(getFacesContext()), model);
- }
-
- /**
- * Get current data model, or create it by {@link #createDataModel()}
- * method. For different iterations in ancestor UIData ( if present )
- * will be returned different models.
- *
- * @return current data model.
- */
- protected ExtendedDataModel getExtendedDataModel() {
- if (this._currentModel == null) {
- String baseClientId = getBaseClientId(getFacesContext());
- ExtendedDataModel model = (ExtendedDataModel) this._modelsMap
- .get(baseClientId);
- if (null == model) {
- model = createDataModel();
- this._modelsMap.put(baseClientId, model);
- }
- this._currentModel = model;
- }
- return this._currentModel;
- }
-
- /**
- * Hook mathod for create data model in concrete implementations.
- *
- * @return
- */
- protected abstract ExtendedDataModel createDataModel();
-
- /**
- * Set current state ( at most cases, visual representation ) of this
- * component. Same as for DataModel, component will keep states for
- * different iterations.
- *
- * @param state
- */
- public void setComponentState(DataComponentState state) {
- this._currentState = state;
- this._statesMap.put(getBaseClientId(getFacesContext()),
- this._currentState);
- }
-
- /**
- * @return current state of this component.
- */
- public DataComponentState getComponentState() {
- DataComponentState state = null;
- if (this._currentState == null) {
- // Check for binding state to user bean.
- ValueBinding valueBinding =
getValueBinding(UIDataAdaptor.COMPONENT_STATE_ATTRIBUTE);
- FacesContext facesContext = getFacesContext();
- if (null != valueBinding) {
- state = (DataComponentState) valueBinding
- .getValue(facesContext);
- if (null == state) {
- // Create default state
- state = createComponentState();
- if (!valueBinding.isReadOnly(facesContext)) {
- // Store created state in user bean.
- valueBinding.setValue(facesContext, state);
- }
- }
- } else {
- // Check for stored state in map for parent iterations
- String baseClientId = getBaseClientId(facesContext);
- state = (DataComponentState) this._statesMap.get(baseClientId);
- if (null == state) {
- // Create default component state
- state = createComponentState();
- this._statesMap.put(baseClientId, state);
- }
- this._currentState = state;
- }
- } else {
- state = this._currentState;
- }
- return state;
- }
-
- /**
- * Hook method for create default state in concrete implementations.
- *
- * @return
- */
- protected abstract DataComponentState createComponentState();
-
- private String _clientId = null;
-
- public String getClientId(FacesContext faces) {
- if (null == _clientId) {
- StringBuffer id = new StringBuffer(getBaseClientId(faces));
- Object rowKey = getRowKey();
- if (rowKey != null) {
- id.append(NamingContainer.SEPARATOR_CHAR).append(
- rowKey.toString());
- }
- Renderer renderer;
- if (null != (renderer = getRenderer(faces))) {
- _clientId = renderer.convertClientId(faces, id.toString());
- } else {
- _clientId = id.toString();
- }
-
- }
- return _clientId;
- }
-
- private String _baseClientId = null;
-
- /**
- * Get base clietntId of this component ( withowt iteration part )
- *
- * @param faces
- * @return
- */
- public String getBaseClientId(FacesContext faces) {
- // Return any previously cached client identifier
- if (_baseClientId == null) {
-
- // Search for an ancestor that is a naming container
- UIComponent ancestorContainer = this;
- StringBuffer parentIds = new StringBuffer();
- while (null != (ancestorContainer = ancestorContainer.getParent())) {
- if (ancestorContainer instanceof NamingContainer) {
- parentIds.append(ancestorContainer.getClientId(faces))
- .append(NamingContainer.SEPARATOR_CHAR);
- break;
- }
- }
- String id = getId();
- if (null != id) {
- _baseClientId = parentIds.append(id).toString();
- } else {
- _baseClientId = parentIds.append(
- faces.getViewRoot().createUniqueId()).toString();
- }
- }
- return (_baseClientId);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#setId(java.lang.String)
- */
- public void setId(String id) {
- // If component created by restoring tree or JSP, initial Id is null.
- boolean haveId = null != super.getId();
- super.setId(id);
- _baseClientId = null;
- _clientId = null;
- if (haveId) {
- // parent UIData ( if present ) will be set same Id at iteration
- // -
- // we use it for
- // switch to different model and state.
- String baseClientId = getBaseClientId(getFacesContext());
- this._currentState = (DataComponentState) this._statesMap
- .get(baseClientId);
- this._currentModel = (ExtendedDataModel) this._modelsMap
- .get(baseClientId);
- if (null != this._currentModel) {
- this._rowKey = this._currentModel.getRowKey();
- // restoreChildState();
- }
- // Restore value for row with submitted AjaxComponent.
- this._ajaxRowKey = _ajaxRowKeysMap.get(baseClientId);
- }
- }
-
- private Object origValue;
-
- /**
- * Save current state of data variable.
- */
- public void captureOrigValue() {
- captureOrigValue(FacesContext.getCurrentInstance());
- }
-
- /**
- * Save current state of data variable.
- *
- * @param faces
- * current faces context
- */
- public void captureOrigValue(FacesContext faces) {
- String var = getVar();
- if (var != null) {
- Map attrs = faces.getExternalContext().getRequestMap();
- this.origValue = attrs.get(var);
- }
- }
-
- /**
- * Restore value of data variable after processing phase.
- */
- public void restoreOrigValue() {
- restoreOrigValue(FacesContext.getCurrentInstance());
- }
-
- /**
- * Restore value of data variable after processing phase.
- *
- * @param faces
- * current faces context
- */
- public void restoreOrigValue(FacesContext faces) {
- String var = getVar();
- if (var != null) {
- Map attrs = faces.getExternalContext().getRequestMap();
- if (this.origValue != null) {
- attrs.put(var, this.origValue);
- } else {
- attrs.remove(var);
- }
- }
- }
-
- /**
- * Saved values of {@link EditableValueHolder} fields per iterations.
- */
- private Map childState;
-
- /**
- * @param faces
- * @return Saved values of {@link EditableValueHolder} fields per
- * iterations.
- */
- protected Map getChildState(FacesContext faces) {
- if (this.childState == null) {
- this.childState = new HashMap();
- }
- String baseClientId = getBaseClientId(faces);
- Map currentChildState = (Map) childState.get(baseClientId);
- if (null == currentChildState) {
- currentChildState = new HashMap();
- childState.put(baseClientId, currentChildState);
- }
- return currentChildState;
- }
-
- /**
- * Save values of {@link EditableValueHolder} fields before change
- * current row.
- *
- * @param faces
- */
- protected void saveChildState(FacesContext faces) {
-
- Iterator itr = dataChildren();
- while (itr.hasNext()) {
- Map childState = this.getChildState(faces);
- this.saveChildState(faces, (UIComponent) itr.next(), childState);
- }
- }
-
- /**
- * Recursive method for Iterate on children for save
- * {@link EditableValueHolder} fields states.
- *
- * @param faces
- * @param c
- * @param childState
- */
- private void saveChildState(FacesContext faces, UIComponent c,
- Map childState) {
-
- if (c instanceof EditableValueHolder && !c.isTransient()) {
- String clientId = c.getClientId(faces);
- SavedState ss = (SavedState) childState.get(clientId);
- if (ss == null) {
- ss = new SavedState();
- childState.put(clientId, ss);
- }
- ss.populate((EditableValueHolder) c);
- }
-
- // continue hack
- Iterator itr = c.getChildren().iterator();
- while (itr.hasNext()) {
- saveChildState(faces, (UIComponent) itr.next(), childState);
- }
- itr = c.getFacets().values().iterator();
- while (itr.hasNext()) {
- saveChildState(faces, (UIComponent) itr.next(), childState);
- }
- }
-
- /**
- * Restore values of {@link EditableValueHolder} fields after change
- * current row.
- *
- * @param faces
- */
- protected void restoreChildState(FacesContext faces) {
-
- Iterator itr = dataChildren();
- while (itr.hasNext()) {
- Map childState = this.getChildState(faces);
- this.restoreChildState(faces, (UIComponent) itr.next(), childState);
- }
- }
-
- /**
- * Recursive part of
- * {@link #restoreChildState(FacesContext, UIComponent, Map)}
- *
- * @param faces
- * @param c
- * @param childState
- *
- */
- private void restoreChildState(FacesContext faces, UIComponent c,
- Map childState) {
- // reset id
- String id = c.getId();
- c.setId(id);
-
- // hack
- if (c instanceof EditableValueHolder) {
- EditableValueHolder evh = (EditableValueHolder) c;
- String clientId = c.getClientId(faces);
- SavedState ss = (SavedState) childState.get(clientId);
- if (ss != null) {
- ss.apply(evh);
- } else {
- NullState.apply(evh);
- }
- }
-
- // continue hack
- Iterator itr = c.getChildren().iterator();
- while (itr.hasNext()) {
- restoreChildState(faces, (UIComponent) itr.next(), childState);
- }
- itr = c.getFacets().values().iterator();
- while (itr.hasNext()) {
- restoreChildState(faces, (UIComponent) itr.next(), childState);
- }
- }
-
- /**
- * Check for validation errors on children components. If true, saved
- * values must be keep on render phase
- *
- * @param context
- * @return
- */
- private boolean keepSaved(FacesContext context) {
-
- Iterator clientIds = this.getChildState(context).keySet().iterator();
- while (clientIds.hasNext()) {
- String clientId = (String) clientIds.next();
- Iterator messages = context.getMessages(clientId);
- while (messages.hasNext()) {
- FacesMessage message = (FacesMessage) messages.next();
- if (message.getSeverity()
- .compareTo(FacesMessage.SEVERITY_ERROR) >= 0) {
- return (true);
- }
- }
- }
- return false;
- }
-
- /**
- * Perform iteration on all children components and all data rows with
- * given visitor.
- *
- * @param faces
- * @param visitor
- */
- protected void iterate(FacesContext faces, ComponentVisitor visitor,
- Object argument) {
-
- // stop if not rendered
- if (!this.isRendered()) {
- return;
- }
- // reset rowIndex
- this.captureOrigValue(faces);
- this.setRowKey(faces, null);
- try {
- Iterator fixedChildren = fixedChildren();
- while (fixedChildren.hasNext()) {
- UIComponent component = (UIComponent) fixedChildren.next();
- visitor.processComponent(faces, component, argument);
- }
-
- walk(faces, visitor, argument);
- } catch (Exception e) {
- throw new FacesException(e);
- } finally {
- this.setRowKey(faces, null);
- this.restoreOrigValue(faces);
- }
- }
-
- /**
- * Walk ( visit ) this component on all data-avare children for each
- * row.
- *
- * @param faces
- * @param visitor
- * @throws IOException
- */
- public void walk(FacesContext faces, DataVisitor visitor, Object argument)
- throws IOException {
- getExtendedDataModel().walk(faces, visitor,
- getComponentState().getRange(), argument);
- }
-
- protected void processDecodes(FacesContext faces, Object argument) {
- if (!this.isRendered())
- return;
- this.resetComponent(faces);
- this.iterate(faces, decodeVisitor, argument);
- this.decode(faces);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIData#processDecodes(javax.faces.context.FacesContext)
- */
- public void processDecodes(FacesContext faces) {
- processDecodes(faces, null);
- }
-
- /**
- * Reset per-request fields in component.
- *
- * @param faces
- *
- */
- protected void resetComponent(FacesContext faces) {
- // resetDataModel();
- if (null != this.childState) {
- childState.remove(getBaseClientId(faces));
- }
- this._encoded = null;
- }
-
- protected void processUpdates(FacesContext faces, Object argument) {
- if (!this.isRendered())
- return;
- this.iterate(faces, updateVisitor, argument);
- ExtendedDataModel dataModel = getExtendedDataModel();
- // If no validation errors, update values for serializable model,
- // restored from view.
- if (dataModel instanceof SerializableDataModel && (!keepSaved(faces))) {
- SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
- serializableModel.update();
- }
- }
-
- public void processUpdates(FacesContext faces) {
- processUpdates(faces, null);
- }
-
- protected void processValidators(FacesContext faces, Object argument) {
- if (!this.isRendered())
- return;
- this.iterate(faces, validateVisitor, argument);
- }
-
- public void processValidators(FacesContext faces) {
- processValidators(faces, null);
- }
-
- public void encodeBegin(FacesContext context) throws IOException {
- resetDataModel();
- // if(!keepSaved(context)){
- // childState.remove(getBaseClientId(context));
- // }
- // Mark component as used, if parent UIData change own range states not
- // accessed at
- // encode phase must be unsaved.
- getEncodedIds().add(getBaseClientId(context));
- // getComponentState().setUsed(true);
- super.encodeBegin(context);
- }
-
- /**
- * This method must create iterator for all non-data avare children of
- * this component ( header/footer facets for components and columns in
- * dataTable, facets for tree etc.
- *
- * @return iterator for all components not sensitive for row data.
- */
- protected abstract Iterator fixedChildren();
-
- /**
- * This method must create iterator for all children components,
- * processed "per row" It can be children of UIColumn in dataTable,
- * nodes in tree
- *
- * @return iterator for all components processed per row.
- */
- protected abstract Iterator dataChildren();
-
- private final static SavedState NullState = new SavedState();
-
- // from RI
- /**
- * This class keep values of {@link EditableValueHolder} row-sensitive
- * fields.
- *
- * @author shura
- *
- */
- private final static class SavedState implements Serializable {
-
- private Object submittedValue;
-
- private static final long serialVersionUID = 2920252657338389849L;
-
- Object getSubmittedValue() {
- return (this.submittedValue);
- }
-
- void setSubmittedValue(Object submittedValue) {
- this.submittedValue = submittedValue;
- }
-
- private boolean valid = true;
-
- boolean isValid() {
- return (this.valid);
- }
-
- void setValid(boolean valid) {
- this.valid = valid;
- }
-
- private Object value;
-
- Object getValue() {
- return (this.value);
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
-
- private boolean localValueSet;
-
- boolean isLocalValueSet() {
- return (this.localValueSet);
- }
-
- public void setLocalValueSet(boolean localValueSet) {
- this.localValueSet = localValueSet;
- }
-
- public String toString() {
- return ("submittedValue: " + submittedValue + " value: " +
value
- + " localValueSet: " + localValueSet);
- }
-
- public void populate(EditableValueHolder evh) {
- this.value = evh.getLocalValue();
- this.valid = evh.isValid();
- this.submittedValue = evh.getSubmittedValue();
- this.localValueSet = evh.isLocalValueSet();
- }
-
- public void apply(EditableValueHolder evh) {
- evh.setValue(this.value);
- evh.setValid(this.valid);
- evh.setSubmittedValue(this.submittedValue);
- evh.setLocalValueSet(this.localValueSet);
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIData#queueEvent(javax.faces.event.FacesEvent)
- */
- public void queueEvent(FacesEvent event) {
- if (event.getComponent() != this) {
- event = new IndexedEvent(this, event, getRowKey());
- }
- // Send event directly to parent, to avoid wrapping in superclass.
- UIComponent parent = getParent();
- if (parent == null) {
- throw new IllegalStateException(
- "No parent component for queue event");
- } else {
- parent.queueEvent(event);
- }
- }
-
- public void broadcast(FacesEvent event) throws AbortProcessingException {
-
- if (!(event instanceof IndexedEvent)) {
- if (!broadcastLocal(event)) {
- super.broadcast(event);
- }
- return;
- }
-
- // Set up the correct context and fire our wrapped event
- IndexedEvent revent = (IndexedEvent) event;
- Object oldRowKey = getRowKey();
- FacesContext faces = FacesContext.getCurrentInstance();
- captureOrigValue(faces);
- Object eventRowKey = revent.getKey();
- setRowKey(faces, eventRowKey);
- FacesEvent rowEvent = revent.getTarget();
- rowEvent.getComponent().broadcast(rowEvent);
- // For Ajax events, keep row value.
- if (!(rowEvent.getPhaseId() == PhaseId.RENDER_RESPONSE)) {
- this._ajaxRowKey = eventRowKey;
- this._ajaxRowKeysMap.put(getBaseClientId(faces), eventRowKey);
- }
- setRowKey(faces, oldRowKey);
- restoreOrigValue(faces);
- // }
- return;
- }
-
- /**
- * Process events targetted for concrete implementation. Hook method
- * called from {@link #broadcast(FacesEvent)}
- *
- * @param event -
- * processed event.
- * @return true if event processed, false if component must continue
- * processing.
- */
- protected boolean broadcastLocal(FacesEvent event) {
- return false;
- }
-
- /**
- * Wrapper for event from child component, with value of current row
- * key.
- *
- * @author shura
- *
- */
- protected static final class IndexedEvent extends FacesEvent {
-
- private static final long serialVersionUID = -8318895390232552385L;
-
- private final FacesEvent target;
-
- private final Object key;
-
- public IndexedEvent(UIDataAdaptor owner, FacesEvent target, Object key) {
- super(owner);
- this.target = target;
- this.key = key;
- }
-
- public PhaseId getPhaseId() {
- return (this.target.getPhaseId());
- }
-
- public void setPhaseId(PhaseId phaseId) {
- this.target.setPhaseId(phaseId);
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return this.target.isAppropriateListener(listener);
- }
-
- public void processListener(FacesListener listener) {
- UIDataAdaptor owner = (UIDataAdaptor) this.getComponent();
- Object prevIndex = owner._rowKey;
- try {
- owner.setRowKey(this.key);
- this.target.processListener(listener);
- } finally {
- owner.setRowKey(prevIndex);
- }
- }
-
- public Object getKey() {
- return key;
- }
-
- public FacesEvent getTarget() {
- return target;
- }
-
- }
-
- /**
- * "memento" pattern class for state of component.
- *
- * @author shura
- *
- */
- private static class DataState implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 17070532L;
-
- private Object superState;
-
- private Map componentStates = new HashMap();
-
- private Set ajaxKeys;
-
- public String rowKeyVar;
-
- public String stateVar;
-
- }
-
- /**
- * Serialisable model and component state per iteration of parent
- * UIData.
- *
- * @author shura
- *
- */
- private static class PerIdState implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 9037454770537726418L;
-
- /**
- * Flag setted to true if componentState implements StateHolder
- */
- private boolean stateInHolder = false;
-
- /**
- * Serializable componentState or
- */
- private Object componentState;
-
- private SerializableDataModel model;
- }
-
- public void restoreState(FacesContext faces, Object object) {
- DataState state = (DataState) object;
- super.restoreState(faces, state.superState);
- this._ajaxKeys = state.ajaxKeys;
- this._statesMap = new HashMap();
- this._rowKeyVar = state.rowKeyVar;
- this._stateVar = state.stateVar;
- // Restore serializable models and component states for all rows of
- // parent UIData ( single if this
- // component not child of iterable )
- for (Iterator iter = state.componentStates.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry stateEntry = (Map.Entry) iter.next();
- PerIdState idState = (PerIdState) stateEntry.getValue();
- DataComponentState compState;
- if (idState.stateInHolder) {
- // TODO - change RichFaces Tree component, for remove reference
- // to component from state.
- compState = createComponentState();
- ((StateHolder) compState).restoreState(faces,
- idState.componentState);
- } else {
- compState = (DataComponentState) idState.componentState;
- }
- Object key = stateEntry.getKey();
- this._statesMap.put(key, compState);
- this._modelsMap.put(key, idState.model);
- }
- }
-
- public Object saveState(FacesContext faces) {
- DataState state = new DataState();
- state.superState = super.saveState(faces);
- state.ajaxKeys = this._ajaxKeys;
- state.rowKeyVar = this._rowKeyVar;
- state.stateVar = this._stateVar;
- Set encodedIds = getEncodedIds();
- // Save all states of component and data model for all valies of
- // clientId, encoded in this request.
- for (Iterator iter = this._statesMap.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry stateEntry = (Map.Entry) iter.next();
- DataComponentState dataComponentState = ((DataComponentState) stateEntry
- .getValue());
- Object stateKey = stateEntry.getKey();
- if (encodedIds.isEmpty() || encodedIds.contains(stateKey)) {
- PerIdState idState = new PerIdState();
- idState.model = getExtendedDataModel().getSerializableModel(
- dataComponentState.getRange());
- // Save component state , depended if implemented interfaces.
- if (null == dataComponentState) {
- idState.componentState = null;
- } else if (dataComponentState instanceof Serializable) {
- idState.componentState = dataComponentState;
- } else if (dataComponentState instanceof StateHolder) {
- // TODO - change RichFaces Tree component, for remove
- // reference to component from state.
- // Change this code to reference for saveAttachedState.
- idState.componentState = ((StateHolder) dataComponentState)
- .saveState(faces);
- idState.stateInHolder = true;
- }
- if (null != idState.model || null != idState.componentState) {
- state.componentStates.put(stateKey, idState);
- }
- }
- }
- return state;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,136 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.sql.ResultSet;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.ArrayDataModel;
-import javax.faces.model.DataModel;
-import javax.faces.model.ListDataModel;
-import javax.faces.model.ResultDataModel;
-import javax.faces.model.ResultSetDataModel;
-import javax.faces.model.ScalarDataModel;
-import javax.servlet.jsp.jstl.sql.Result;
-/**
- * @author shura
- *
- */
-public class UIRepeat extends UIDataAdaptor {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createComponentState()
- */
- protected DataComponentState createComponentState() {
- // Create component state based on this instance.
- return new DataComponentState(){
-
- public Range getRange() {
- return new SequenceRange(getFirst(),getRows());
- }
-
- public boolean isTransient() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void restoreState(FacesContext arg0, Object arg1) {
- // TODO Auto-generated method stub
-
- }
-
- public Object saveState(FacesContext arg0) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setTransient(boolean arg0) {
- // TODO Auto-generated method stub
-
- }
- };
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createDataModel()
- */
- protected ExtendedDataModel createDataModel() {
- return (ExtendedDataModel) getDataModel();
- }
-
- protected DataModel getDataModel(){
- // Synthesize a DataModel around our current value if possible
- // TODO - for jsf 1.2 use method from superclass ?
- Object current = getValue();
- DataModel model;
- if (current == null) {
- model = new SequenceDataModel(new ListDataModel(Collections.EMPTY_LIST));
- } else if (current instanceof ExtendedDataModel) {
- model = (DataModel) current;
- } else if (current instanceof DataModel) {
- model = new SequenceDataModel((DataModel) current);
- } else if (current instanceof List) {
- model = new SequenceDataModel(new ListDataModel((List) current));
- } else if (Object[].class.isAssignableFrom(current.getClass())) {
- model = new SequenceDataModel(new ArrayDataModel((Object[]) current));
- } else if (current instanceof ResultSet) {
- model = new SequenceDataModel(new ResultSetDataModel((ResultSet) current));
- } else if (current instanceof Result) {
- model = new SequenceDataModel(new ResultDataModel((Result) current));
- } else {
- model = new SequenceDataModel(new ScalarDataModel(current));
- }
- return (model);
- }
-
- protected void setDataModel(DataModel model) {
- ExtendedDataModel iterableModel;
- if( null == model){
- iterableModel = null;
- } else if (model instanceof ExtendedDataModel) {
- iterableModel = (ExtendedDataModel) model;
- } else {
- iterableModel = new SequenceDataModel(model);
- }
- setExtendedDataModel(iterableModel);
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
- */
- protected Iterator dataChildren() {
- // TODO Auto-generated method stub
- return getChildren().iterator();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
- */
- protected Iterator fixedChildren() {
- // TODO Auto-generated method stub
- return getFacets().values().iterator();
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,114 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.repeat;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
-import org.apache.commons.beanutils.PropertyUtils;
-
-/**
- * Base class for component, performed AJAX encoding on selected values in
- * iterable components ( UIData, trees etc )
- *
- * @author shura
- *
- */
-public abstract class UISelector extends UIComponentBase implements
- AjaxDataEncoder {
-
- private static final AjaxChildrenRenderer childrenRenderer = new AjaxChildrenRenderer()
{
-
- protected Class getComponentClass() {
- return UISelector.class;
- }
-
- };
-
- /**
- * Name of serRow ( or simple ) method for setup current value in iterable
- * component
- *
- * @parameter
- * @return the acceptClass
- */
- public abstract String getIterationProperty();
-
- /**
- * @param newSelectMethod
- * the value to set
- */
- public abstract void setIterationProperty(String newSelectMethod);
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
- * java.lang.String, java.util.Set, java.util.Set)
- */
- public void encodeAjaxChild(FacesContext context, String path, Set ids,
- Set renderedAreas) throws IOException {
- if (getChildCount() != 1) {
- throw new FacesException(
- "Selector component must have one, and only one, child");
- }
- UIComponent child = (UIComponent) getChildren().get(0);
- Set ajaxKeys = getAjaxKeys();
- if (null != ajaxKeys) {
- String iterationProperty = getIterationProperty();
- try {
- Object savedKey = PropertyUtils.getProperty(child,
- iterationProperty);
- for (Iterator iter = ajaxKeys.iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
- PropertyUtils.setProperty(child, iterationProperty, key);
- if (true) {
- childrenRenderer.encodeAjaxChildren(context, this, path,
- ids, renderedAreas);
- }
-
- }
- PropertyUtils.setProperty(child, iterationProperty, savedKey);
-
- } catch (IllegalAccessException e) {
- throw new FacesException(
- "Illegal access to iteration selection property "+iterationProperty+"
on component "+child.getClientId(context),e);
- } catch (InvocationTargetException e) {
- throw new FacesException(
- "Error in iteration selection property "+iterationProperty+" on
component "+child.getClientId(context),e.getCause());
- } catch (NoSuchMethodException e) {
- throw new FacesException(
- "No iteration selection property "+iterationProperty+" on component
"+child.getClientId(context),e);
- }
- }
-
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,121 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.resource;
-
-import java.util.Date;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:13 $
- *
- */
-public interface ResourceComponent {
-
- /**
- * Get Mime-type for target .
- * @return
- */
- public abstract String getMimeType();
-
- /**
- * Set Mime-type for target .
- * @param newvalue
- */
- public abstract void setMimeType(String newvalue);
-
-
- /**
- * Get Last modified date for target .
- * @return
- */
- public abstract Date getLastModified();
-
- /**
- * Set Last modified for target .
- * @param newvalue
- */
- public abstract void setLastModified(Date newvalue);
-
-
- /**
- * Get Expiration time for target .
- * @return
- */
- public abstract Date getExpires();
-
- /**
- * Set Expiration time for target .
- * @param newvalue
- */
- public abstract void setExpires(Date newvalue);
-
-
- /**
- * Get caching flag for resource.
- * @return
- */
- public abstract boolean isCacheable();
-
- /**
- * Set caching flag for resource.
- * @param newvalue
- */
- public abstract void setCacheable(boolean newvalue);
-
- /**
- * Get session-avare flag for resource.
- * @return true if resource depend of client session. If false, no JSESSIONID encoded in
URI
- */
- public abstract boolean isSession();
-
- /**
- * Set session-avare flag for resource.
- * @param newvalue
- */
- public abstract void setSession(boolean newvalue);
-
- /**
- * Get Data object, encoded in uri and passed to "send" method for generate
resource content.
- * @return
- */
- public abstract Object getValue();
-
- /**
- * Set Data object, encoded in uri and passed to "send" method for generate
resource content.
- * @param newvalue
- */
- public abstract void setValue(Object newvalue);
-
- /**
- * Get El binding to method in user bean to send resource. Method will called with two
parameters - restored data object and servlet output stream.
- * @return
- */
- public abstract MethodBinding getCreateContent();
-
- /**
- * Set El binding to method in user bean to send resource. Method will called with two
parameters - restored data object and servlet output stream.
- * @param newvalue
- */
- public abstract void setCreateContent(MethodBinding newvalue);
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,59 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.resource;
-
-import javax.faces.component.UIOutput;
-
-/**
- * @author shura
- *
- */
-public abstract class UIMediaOutput extends UIOutput implements ResourceComponent {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.MMedia";
-
- /**
- * Get URI attribute for resource ( src for images, href for links etc ).
- * @return
- */
- public abstract String getUriAttribute();
-
- /**
- * Set URI attribute for resource ( src for images, href for links etc ).
- * @param newvalue
- */
- public abstract void setUriAttribute(String newvalue);
-
- /**
- * Get Element name for rendering ( imj , a , object, applet ).
- * @return
- */
- public abstract String getElement();
-
- /**
- * Set Element name for rendering ( imj , a , object, applet ).
- * @param newvalue
- */
- public abstract void setElement(String newvalue);
-
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/Cache.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/Cache.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/Cache.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,180 +0,0 @@
-package org.ajax4jsf.cache;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * <p>
- * A cache, being a mechanism for efficient temporary storage of objects
- * for the purpose of improving the overall performance of an application
- * system, should not be necessary for the application to function correctly,
- * it only improves the performance.
- * <p>
- * A cache could be scoped, for examples to a JVM, all JVMs on a node, all
- * nodes in a cluster, etc. Operations that are scoped to a cache such as put
- * or load would affect all JVMs in the cache. So the object loaded in 1 JVM
- * would be equally available to all other JVMs in the cache.
- * <p>
- * Objects are identified in the cache by a key. A key can be any Java
- * object that implements the equals and hashcode methods. If the object is
- * to be distributed or persisted (if supported) it must implement
- * serializable.
- * <p/>
- * Each object in the cache will have a <code>CacheEntry<code> object
associated with
- * it. This object will encapsulate the metadata associated with the cached
- * object. Mainly it represents the object statistics.
- * <p/>
- * "CacheStatistics" represents the read-only statistics of the cache,
- * while "CacheAttributes" represents the user settable attributes of the
- * cache.
- */
-public interface Cache
-{
- /**
- * Returns true if the cache contains the specified key. The search is
- * scoped to the cache. Other caches in the system will not be searched
- * and a CacheLoader will not be called.
- * @return true, if the cache contains the specified key.
- */
- public boolean containsKey(Object key);
-
- /**
- * @return true if the cache contains one or more keys to the specified value.
- */
- public boolean containsValue(Object value);
-
- /**
- * Returns a set view of the objects currently contained in the cache.
- * A CacheLoader will not be called. The behavior is unspecified for the
- * case when an object is remove from the cache while the return set is
- * being traversed.
- */
- public Set entrySet();
-
- /**
- * Equality is based on the Set returned by entrySet. Equal will return
- * true if the two objects are referencing the same object or
- * entrySet.equals(((Map)o).entrySet()) returns true.
- */
- public boolean equals(Object o);
-
- /**
- * @param ht a hashtable which holds a pointer pointing to the
- * declarative cache description.
- * @throws CacheException if any error occurs.
- */
-
- /**
- * @return the hash code value for this the cache.
- */
- public int hashCode();
-
- /**
- * @return true if entrySet().isEmpty() returns true.
- */
- public boolean isEmpty();
-
- /**
- * Returns a set view of the keys currently contained in the cache. A
- * CacheLoader will not be called. The behavior is unspecified for the
- * case when an object is remove from the cache while the return set is
- * being traversed.
- */
- public Set keySet();
-
- /**
- * Copies all of the mappings from the specified map to the cache. This
- * would be equivalent to t.entrySet() then iterating through the Set and
- * calling put with each key value pair.
- */
- public void putAll(Map t);
-
- /**
- * @return the number of objects in the cache. This should be the same
- * value as entrySet().size();
- */
- public int size();
-
- /**
- * @return a collection view of the values contained in the cache.
- */
- public Collection values();
-
- /**
- * The get method will return, from the cache, the object associated with
- * the argument "key". If the object is not in the cache, the associated
- * cache loader will be called. If no loader is associated with the object,
- * a null is returned. If a problem is encountered during the retrieving
- * or loading of the object, an exception (to be defined) will be thrown.
- * If the "arg" argument is set, the arg object will be passed to the
- * CacheLoader.load method. The cache will not dereference the object.
- * If no "arg" value is provided a null will be passed to the load method.
- * The storing of null values in the cache is permitted, however, the get
- * method will not distinguish returning a null stored in the cache and
- * not finding the object in the cache. In both cases a null is returned.
- * @throws CacheException
- */
- public Object get(Object key, Object context) throws CacheException;
-
- /**
- * The load method provides a means to "pre load" the cache. This method
- * will, asynchronously, load the specified object into the cache using
- * the associated cacheloader. If the object already exists in the cache,
- * no action is taken. If no loader is associated with the object, no object
- * will be loaded into the cache. If a problem is encountered during the
- * retrieving or loading of the object, an exception should
- * be logged.
- * If the "arg" argument is set, the arg object will be passed to the
- * CacheLoader.load method. The cache will not dereference the object. If
- * no "arg" value is provided a null will be passed to the load method.
- * The storing of null values in the cache is permitted, however, the get
- * method will not distinguish returning a null stored in the cache and not
- * finding the object in the cache. In both cases a null is returned.
- */
- public void load(Object key, Object context) throws CacheException;
-
- /**
- * The peek method will return the object associated with "key" if it
- * currently exists (and is valid) in the cache. If not, a null is
- * returned. With "peek" the CacheLoader will not be invoked and other
- * caches in the system will not be searched.
- */
- public Object peek(Object key);
-
- /**
- * The put method adds the object "value" to the cache identified by the
- * object "key".
- */
- public Object put(Object key, Object value);
-
- /**
- * Returns the CacheEntry object associated with the object identified by
- * "key". If the object is not in the cache a null is returned.
- */
- public CacheEntry getCacheEntry(Object key);
-
- /**
- * The remove method will delete the object from the cache including the
- * key, the associated value and the associated CacheStatistics object.
- */
- public Object remove(Object key);
-
- /**
- * The clear method will remove all objects from the cache including the
- * key, the associated value and the associated CacheStatistics object.
- */
- public void clear();
-
- /**
- * The evict method will remove objects from the cache that are no longer
- * valid. Objects where the specified expiration time has been reached.
- */
- public void evict();
-
- /** Add a listener to the list of cache listeners */
- public void addListener(CacheListener listener);
-
- /** Remove a listener from the list of cache listeners */
- public void removeListener(CacheListener listener);
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.cache;
-
-import java.util.Properties;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 02.05.2007
- *
- */
-public interface CacheConfigurationLoader {
- public Properties loadProperties(String name);
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheEntry.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheEntry.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheEntry.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,29 +0,0 @@
-package org.ajax4jsf.cache;
-
-import java.util.Map;
-
-/**
- * CacheEntry
- *
- * @author Brian Goetz
- */
-public interface CacheEntry extends Map.Entry {
-
- int getHits();
-
- long getLastAccessTime();
- long getLastUpdateTime();
- long getCreationTime();
- long getExpirationTime();
-
- /**
- * Returns a version counter.
- * An implementation may use timestamps for this or an incrementing
- * number. Timestamps usually have issues with granularity and are harder
- * to use across clusteres or threads, so an incrementing counter is often safer.
- */
- long getVersion();
-
- boolean isValid();
- long getCost();
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheException.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheException.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheException.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,43 +0,0 @@
-package org.ajax4jsf.cache;
-
-
-/**
- * CacheException is a generic exception, which indicates
- * a cache error has occurred. All the other cache exceptions are the
- * subclass of this class. All the methods in the cache package only
- * throw CacheException or the sub class of it.
- * <P>
- *
- */
-public class CacheException extends Exception
-{
- /**
- *
- */
- private static final long serialVersionUID = 6712594794189413065L;
-
- /**
- * Constructs a new CacheException.
- */
- public CacheException()
- {
- super();
- }
-
- /**
- * Constructs a new CacheException with a message string.
- */
- public CacheException(String s)
- {
- super(s);
- }
-
- /**
- * Constructs a CacheException with a message string, and
- * a base exception
- */
- public CacheException(String s, Throwable ex)
- {
- super(s, ex);
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheFactory.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheFactory.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheFactory.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,22 +0,0 @@
-package org.ajax4jsf.cache;
-
-import java.util.Map;
-
-/**
- * CacheFactory is a service provider specific interface.
- * Service provider should implement CacheFactory to provide
- * the functionality to create a new implementation specific Cache object.
- */
-public interface CacheFactory
-{
- /**
- * creates a new implementation specific Cache object using the env parameters.
- * @param env implementation specific environment parameters passed to the
- * CacheFactory.
- * @param cacheLoader implementation of the {@link CacheLoader} to use
- * @param cacheConfigurationloader TODO
- * @return an implementation specific Cache object.
- * @throws CacheException if any error occurs.
- */
- public Cache createCache(Map env, CacheLoader cacheLoader, CacheConfigurationLoader
cacheConfigurationloader) throws CacheException;
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheListener.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,20 +0,0 @@
-package org.ajax4jsf.cache;
-
-/** Interface describing various events that can happen as elements are added to
- * or removed from a cache
- */
-public interface CacheListener {
- /** Triggered when a cache mapping is created due to the cache loader being consulted
*/
- public void onLoad(Object key);
-
- /** Triggered when a cache mapping is created due to calling Cache.put() */
- public void onPut(Object key);
-
- /** Triggered when a cache mapping is removed due to eviction */
- public void onEvict(Object key);
-
- /** Triggered when a cache mapping is removed due to calling Cache.remove() */
- public void onRemove(Object key);
-
- public void onClear();
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheLoader.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheLoader.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/cache/CacheLoader.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,24 +0,0 @@
-package org.ajax4jsf.cache;
-
-
-/**
- * User should implement this CacheLoader interface to
- * provide a loader object to load the objects into cache.
- */
-public interface CacheLoader
-{
- /**
- * loads an object. Application writers should implement this
- * method to customize the loading of cache object. This method is called
- * by the caching service when the requested object is not in the cache.
- * <P>
- *
- * @param key the key identifying the object being loaded
- *
- * @return The object that is to be stored in the cache.
- * @throws CacheException
- *
- */
- public Object load(Object key, Object context) throws CacheException;
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd;
-
-import org.ajax4jsf.framework.resource.ClientScript;
-
-/**
- * @author shura
- *
- */
-public class DnDScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.ClientScript#isUsePrototype()
- */
- protected boolean isUsePrototype() {
- return true;
- }
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Draggable.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Draggable.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Draggable.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd;
-
-import javax.faces.el.MethodBinding;
-
-import org.ajax4jsf.dnd.event.DragListener;
-
-
-/**
- * Interface for all draggable components. Describe bean properties, implemented by
component.
- * @author shura
- *
- */
-public interface Draggable {
-
- /**
- * Getter for value parameter, used as key for draggable component.
- * @return
- */
- public Object getDragValue();
-
- public void setDragValue(Object value);
-
- /**
- * Getter for id of component ( instance of {@link UIDragIndicator} ) used for create
drag cursor.
- * @return
- */
- public String getDragIndicator();
-
- /**
- * @param dragIndicator - id of cursor component
- */
- public void setDragIndicator(String dragIndicator);
-
-
- /**
- * Getter for type of this draggable ( file, mail etc ).
- * @return
- */
- public String getDragType();
-
- /**
- * @param dragType
- */
- public void setDragType(String dragType);
-
- /**
- * Getter for JavaScript event handler, called before start drag operation.
- * If this handler return false, drag operation is cancelled.
- * @return javaScript code of event handler.
- */
- public String getOndragstart();
-
- /**
- * @param dragType
- */
- public void setOndragstart(String ondrag);
-
- /**
- *
- * @return
- */
- public String getOndragend();
- public void setOndragend(String ondrag);
-
-
- /**
- * Append drag listener to component listeners collection
- * @param listener
- */
- public void addDragListener(DragListener listener);
-
- /**
- * Get array of all Drop Listeners
- * @return
- */
- public DragListener[] getDragListeners();
-
- /**
- * Remove drop listener from component listeners array.
- * @param listener
- */
- public void removeDragListener(DragListener listener);
-
- public void setDragListener(MethodBinding binding);
- public MethodBinding getDragListener();
-
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Dropzone.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Dropzone.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/Dropzone.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,101 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd;
-
-import org.ajax4jsf.dnd.event.DropSource;
-
-/**
- * Base interface for all components, accesible as drop zone.
- * @author shura
- *
- */
-public interface Dropzone extends DropSource {
-
- /**
- * Getter for dropType's , accepted by this zone.
- * @return
- */
- public Object getAcceptedTypes();
-
- public void setAcceptedTypes(Object types);
-
- /**
- * Getter for mapping between drop types and indicator states.
- * @return
- */
- public Object getTypeMapping();
-
- public void setTypeMapping(Object types);
- /**
- * Getter for JavaScript event handler, called then drag curcor enter in component
area.
- * If this handler return false, or "declined", drop operation on this
component not allowed.
- * If handler return true or "allowed" , or any other supported indicator
states, drop operation
- * is allowed and corresponding indicator state will be displayed.
- * @return javaScript code of event handler.
- */
- public String getOndragenter();
-
- /**
- * @param dragType
- */
- public void setOndragenter(String ondrag);
-
- /**
- * Getter for JavaScript event handler, called before drag cursor leave component
area.
- * @return javaScript code of event handler.
- */
- public String getOndragexit();
-
- /**
- * @param dragType
- */
- public void setOndragexit(String ondrag);
-
- public Object getDropValue();
-
- public void setDropValue(Object o);
-
- /**
- * Javascript code called before drop event.
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOndrop();
-
- /**
- * @param newOndrop the value to set
- */
- public abstract void setOndrop(String newOndrop);
-
- /**
- * Javascript handler for event fired on drop even the drop for given type is not
available
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOndropend();
-
- /**
- * @param newname the value to set
- */
- public abstract void setOndropend(String ondropend);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,103 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-import org.ajax4jsf.dnd.Draggable;
-import org.ajax4jsf.dnd.Dropzone;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.12.2006
- *
- */
-public class DragEvent extends FacesEvent {
-
- private Dropzone dropTarget;
- private Object acceptedTypes;
- private Object dropValue;
- /**
- *
- */
- private static final long serialVersionUID = 6179268394391836905L;
-
- public DragEvent(UIComponent uiComponent) {
- super(uiComponent);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener faceslistener) {
- return faceslistener instanceof DragListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener faceslistener) {
- ((DragListener) faceslistener).processDrag(this);
- }
-
- public Object getDragValue() {
- return ((Draggable) this.getSource()).getDragValue();
- }
-
- public Dropzone getDropTarget() {
- return dropTarget;
- }
-
- /**
- * @see java.util.EventObject#toString()
- */
-/* public String toString() {
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
- append("component", getComponent()).append("source",
getSource()).append("phaseId", getPhaseId()).
- append("dragValue", getDragValue()).
- append("dropTarget", getDropTarget()).
- append("dropValue", getDropValue()).
- toString();
- }
-*/
- public void setDropTarget(Dropzone dropTarget) {
- this.dropTarget = dropTarget;
- }
-
- public Object getAcceptedTypes() {
- return acceptedTypes;
- }
-
- public void setAcceptedTypes(Object acceptedTypes) {
- this.acceptedTypes = acceptedTypes;
- }
-
- public Object getDropValue() {
- return dropValue;
- }
-
- public void setDropValue(Object dropValue) {
- this.dropValue = dropValue;
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragListener.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DragListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.12.2006
- *
- */
-public interface DragListener extends FacesListener {
- public void processDrag(DragEvent event);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,113 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-import org.ajax4jsf.dnd.Draggable;
-import org.ajax4jsf.dnd.Dropzone;
-
-/**
- * @author shura
- *
- */
-public class DropEvent extends FacesEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 1660545054556302746L;
-
- private Draggable draggableSource;
- private String dragType;
- private Object dragValue;
-
- public DropEvent(UIComponent component) {
- super(component);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
-
- return listener instanceof DropListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- if (listener instanceof DropListener) {
- DropListener dropListener = (DropListener) listener;
- dropListener.processDrop(this);
- }
-
- }
-
- /**
- * @return the dropValue
- */
- public Object getDropValue() {
- return ((Dropzone) this.getSource()).getDropValue();
- }
-
- public Draggable getDraggableSource() {
- return draggableSource;
- }
-
- /**
- * @see java.util.EventObject#toString()
- */
-/* public String toString() {
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
- append("component", getComponent()).
- append("source", getSource()).
- append("phaseId", getPhaseId()).
- append("dropValue", getDropValue()).
- append("draggableSource", getDraggableSource()).
- append("dragValue", getDragValue()).
- toString();
- }
-*/
- public void setDraggableSource(Draggable draggableSource) {
- this.draggableSource = draggableSource;
- }
-
- public String getDragType() {
- return dragType;
- }
-
- public void setDragType(String dragType) {
- this.dragType = dragType;
- }
-
- public Object getDragValue() {
- return dragValue;
- }
-
- public void setDragValue(Object dragValue) {
- this.dragValue = dragValue;
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListener.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,39 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * Listener for process Drop events
- * @author shura
- *
- */
-public interface DropListener extends FacesListener {
-
- /**
- * Process event on Drop for this component.
- * @param event
- */
- public void processDrop(DropEvent event);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropListenerBinding.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,104 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd.event;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-/**
- * Wrapper for bind DrolListener to EL expression.
- * @author shura
- *
- */
-public class DropListenerBinding implements DropListener, StateHolder {
-
- private ValueBinding _binding;
-
- private String _dragType;
-
- private ValueBinding _dragTypeBinding;
-
- private boolean _transient = false;
-
- public DropListenerBinding() {
- }
-
- /**
- * @param binding
- */
- public DropListenerBinding(ValueBinding binding) {
- super();
- _binding = binding;
- }
-
- private DropListener getHandler(FacesContext context) {
- return (DropListener) _binding.getValue(context);
- }
-
- public void processDrop(DropEvent event) {
- DropListener handler = getHandler(FacesContext.getCurrentInstance());
- handler.processDrop(event);
- }
-
- public boolean isTransient() {
- // TODO Auto-generated method stub
- return _transient;
- }
-
- public void restoreState(FacesContext context, Object state) {
- _binding = (ValueBinding) UIComponentBase.restoreAttachedState(context, state);
-
- }
-
- public Object saveState(FacesContext context) {
- return UIComponentBase.saveAttachedState(context, _binding);
- }
-
- public void setTransient(boolean newTransientValue) {
- _transient = newTransientValue;
-
- }
-
- /**
- * @return the dragType
- */
- public String getDragType() {
- return _dragType;
- }
-
- /**
- * @param dragType the dragType to set
- */
- public void setDragType(String dragType) {
- _dragType = dragType;
- }
-
- /**
- * @param dragTypeBinding the dragTypeBinding to set
- */
- public void setDragTypeBinding(ValueBinding dragTypeBinding) {
- _dragTypeBinding = dragTypeBinding;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropSource.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropSource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/event/DropSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,54 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd.event;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * Interface for component applicable to process drag/drop events.
- * @author shura
- *
- */
-public interface DropSource {
-
- /**
- * Append drop listener to component listeners collection
- * @param listener
- */
- public void addDropListener(DropListener listener);
-
- /**
- * Get array of all Drop Listeners
- * @return
- */
- public DropListener[] getDropListeners();
-
- /**
- * Remove drop listener from component listeners array.
- * @param listener
- */
- public void removeDropListener(DropListener listener);
-
- public void setDropListener(MethodBinding binding);
- public MethodBinding getDropListener();
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ViewHandlerWrapper.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,172 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.Locale;
-
-import javax.faces.FacesException;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base wrapper for {@link javax.faces.application.ViewHandler} . By default, delegate
all
- * method calls to wrapped handler.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:12 $
- *
- */
-public class ViewHandlerWrapper extends ViewHandler {
- private static final String HANDLERS = "org.ajax4jsf.VIEW_HANDLERS";
-
- private static final Log _log = LogFactory.getLog(ViewHandlerWrapper.class);
-
- /**
- * Wrapped ViewHandler
- */
- protected ViewHandler _handler;
-
- private boolean _initialized = false;
-
- /**
- * @param handler - to wrap.
- */
- public ViewHandlerWrapper(ViewHandler handler) {
- _handler = handler;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.application.ViewHandler#calculateLocale(javax.faces.context.FacesContext)
- */
- public Locale calculateLocale(FacesContext context) {
- fillChain(context);
- return _handler.calculateLocale(context);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.application.ViewHandler#calculateRenderKitId(javax.faces.context.FacesContext)
- */
- public String calculateRenderKitId(FacesContext context) {
- fillChain(context);
- return _handler.calculateRenderKitId(context);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.application.ViewHandler#createView(javax.faces.context.FacesContext,
java.lang.String)
- */
- public UIViewRoot createView(FacesContext context, String viewId) {
- fillChain(context);
- return _handler.createView(context, viewId);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.application.ViewHandler#getActionURL(javax.faces.context.FacesContext,
java.lang.String)
- */
- public String getActionURL(FacesContext context, String url) {
- fillChain(context);
- return _handler.getActionURL(context, url);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.application.ViewHandler#getResourceURL(javax.faces.context.FacesContext,
java.lang.String)
- */
- public String getResourceURL(FacesContext context, String url) {
- fillChain(context);
- return _handler.getResourceURL(context, url);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.application.ViewHandler#renderView(javax.faces.context.FacesContext,
javax.faces.component.UIViewRoot)
- */
- public void renderView(FacesContext context, UIViewRoot root) throws IOException,
FacesException {
- fillChain(context);
- _handler.renderView(context, root);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.application.ViewHandler#restoreView(javax.faces.context.FacesContext,
java.lang.String)
- */
- public UIViewRoot restoreView(FacesContext context, String viewId) {
- fillChain(context);
- return _handler.restoreView(context, viewId);
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.application.ViewHandler#writeState(javax.faces.context.FacesContext)
- */
- public void writeState(FacesContext context) throws IOException {
- fillChain(context);
- _handler.writeState(context);
- }
-
- /**
- * @return Returns the handler.
- */
- protected ViewHandler getHandler() {
- return _handler;
- }
-
- /**
- * Fill view-handlers chain for alternate handlers.
- * @param context
- */
- synchronized protected void fillChain( FacesContext context){
- if(!_initialized){
- _initialized = true;
- String handlers = context.getExternalContext().getInitParameter(HANDLERS);
- if(null != handlers){
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- String[] classes = handlers.split(",");
- for (int i = 0; i < classes.length; i++) {
- String handlerClass = classes[i];
- if (_log.isDebugEnabled()) {
- _log.debug(Messages.getMessage(Messages.CREATE_ALTERNATE_HANDLER, handlerClass));
- }
- try {
- Class clazz = classLoader.loadClass(handlerClass);
- try {
- Constructor constructor = clazz
- .getConstructor(new Class[] { ViewHandler.class });
- _handler = (ViewHandler) constructor
- .newInstance(new Object[] { _handler });
- } catch (NoSuchMethodException e) {
- // No constructor with parent class - create simple instance
- if (_log.isWarnEnabled()) {
- _log.warn(Messages.getMessage(Messages.ALTERNATE_HANDLER_CONSTRUCTOR_WARNING));
- }
- _handler = (ViewHandler) clazz.newInstance();
- }
- } catch (Exception e) {
- _log.error(Messages.getMessage(Messages.VIEW_HANDLER_INSTANTIATION_ERROR), e);
- }
- }
- }
- }
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,155 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:21 $
- *
- */
-public abstract class AjaxActionComponent extends UICommand implements
- AjaxComponent, AjaxSource {
-
- public static final String FOCUS_DATA_ID = "_A4J.AJAX.focus";
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- // Hack - throw exception to AjaxViewRoot, to fix state of all iterable components.
- if (event instanceof AjaxSingleEvent) {
- throw new AjaxSingleException(getSingleComponent());
- }
- // perform default
- super.broadcast(event);
- if (event instanceof AjaxEvent) {
- FacesContext context = getFacesContext();
- // complete re-Render fields. AjaxEvent deliver before render
- // response.
- setupReRender(context);
- // Put data for send in response
- Object data = getData();
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if (null != data) {
- ajaxContext.setResponseData(data);
- }
- String focus = getFocus();
- if (null != focus) {
- // search for component in tree.
- // TODO - use more pourful search, as in h:outputLabel component.
- UIComponent focusComponent = findComponent(focus);
- if(null != focusComponent){
- focus = focusComponent.getClientId(context);
- }
- ajaxContext.getResponseDataMap().put(FOCUS_DATA_ID, focus);
- }
- }
- }
-
- /**
- * Template method with old signature, for backward compability.
- */
- protected void setupReRender() {
- }
-
- /**
- * Template methods for fill set of resions to render in subclasses.
- *
- * @param facesContext
- * TODO
- */
- protected void setupReRender(FacesContext facesContext) {
- AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(
- this);
- setupReRender();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
- */
- public void queueEvent(FacesEvent event) {
- if (event instanceof ActionEvent && event.getComponent() == this) {
- if (isImmediate()) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else if (isBypassUpdates()) {
- event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
- } else {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
- getParent().queueEvent(event);
- if(isAjaxSingle()){
- super.queueEvent(new AjaxSingleEvent(this));
- }
- } else {
- super.queueEvent(event);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
- */
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
- */
- public AjaxListener[] getAjaxListeners() {
- AjaxListener al[] = (AjaxListener[]) getFacesListeners(AjaxListener.class);
- return (al);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
- */
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
-
- }
-
- protected UIComponent getSingleComponent(){
- return this;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,48 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:34 $
- *
- */
-public class AjaxActionEvent extends ActionEvent {
-
-
- /**
- *
- */
- private static final long serialVersionUID = -5406101936114574903L;
-
- /**
- * @param component
- */
- public AjaxActionEvent(UIComponent component) {
- super(component);
- // TODO Auto-generated constructor stub
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxChildrenEncoder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-import java.util.Set;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Marker interface for components, have ability to manipulate rendering in case of Ajax
responses.
- * Such as ajax-enabled iterator, menus etc
- * @author shura
- *
- */
-public interface AjaxChildrenEncoder {
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it.
- * TODO - Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- */
- public void encodeAjaxChild(FacesContext context,
- String path,Set ids,Set renderedAreas) throws IOException ;
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxComponent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,194 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-
-/**
- * Base Interface for Ajax-enabled acting components.
- * TODO - extend <code>ActionSource</code>???
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:01 $
- *
- */
-public interface AjaxComponent
-{
-
- public static final String AJAX_COMPONETT_PARAMETER =
AjaxComponent.class.getName()+".parameter";
-
- /**
- * setter method for property
- * @param new value of String, <code>Collection</code> or array of
component's Id , updated in case of Ajax request by parent component. to set
- */
- public abstract void setReRender(Object targetId);
-
- /**
- * @return value or result of valueBinding of String,
<code>Collection</code> or array of component's Id , updated in case of
Ajax request by parent component.
- */
- public abstract Object getReRender();
-
- /**
- * setter method for property
- * @param new value of ajaxType of control component - link or input to set
- */
-// public abstract void setAjaxType(String ajaxType);
-
- /**
- * @return value or result of valueBinding of ajaxType of control component - link or
input
- */
-// public abstract String getAjaxType();
-
- /**
- * setter method for property
- * @param new value of Id ( in format of UIComponent.findComponent() call ) of
request status indicator to set
- */
- public abstract void setStatus(String status);
-
- /**
- * @return value or result of valueBinding of Id ( in format of
UIComponent.findComponent() call ) of request status indicator
- */
- public abstract String getStatus();
-
- /**
- * setter method for property
- * @param new value of Name of JavaScript function, called on complete Ajax request
to set
- */
- public abstract void setOncomplete(String oncomplete);
-
- /**
- * @return value or result of valueBinding of Name of JavaScript function, called on
complete Ajax request
- */
- public abstract String getOncomplete();
-
- /**
- * setter method for property
- * @param new value of custom data translated to oncomplete function by AJAX
- */
- public abstract void setData(Object data);
-
- /**
- * @return value of custom data for translate to oncomplete function by AJAX
- */
- public abstract Object getData();
-
- /**
- * setter method for property
- * @param new value of Submit ( or not ) full form on Ajax action. to set
- */
- public abstract void setLimitToList(boolean submitForm);
-
- /**
- * @return value or result of valueBinding of Submit ( or not ) full form on Ajax
action.
- */
- public abstract boolean isLimitToList();
-
- /**
- * setter method for property
- * @param new value of Submit ( or not ) full form on Ajax action. to set
- */
- public abstract void setAjaxSingle(boolean single);
-
- /**
- * @return value or result of valueBinding of Submit ( or not ) full form on Ajax
action.
- */
- public abstract boolean isAjaxSingle();
-
- /**
- * Getter for bypassUpdates bean property. Indicate that component must invoke
listeners after Process Validators phase
- * and force render response after it - since no values of components will be
updated. Can be used to perform validation of client input
- * using server-side validators.
- * @return true if component must force render after validation phase.
- */
- public abstract boolean isBypassUpdates();
-
- /**
- * Setter for bypassUpdates bean property.
- * @param bypass true if component must force render after validation phase.
- */
- public abstract void setBypassUpdates(boolean bypass);
-
- /**
- * Getter for property name of events queue on client side - for avoid to send requests
too frequnly ( on key events, for example ), implementation will be generated by
- * componnents-generator
- * @return property value
- */
- public abstract String getEventsQueue();
-
- /**
- * Setter for flag indicated aborting unfinished ajax requests in queue.
- * @param newvalue - new property value. If true, unfinished request in queue will be
aborted on new events.
- */
- public abstract void setIgnoreDupResponses(boolean newvalue);
-
-
- /**
- * Getter for property flag indicated aborting unfinished ajax requests in queue.
- * componnents-generator
- * @return property value
- */
- public abstract boolean isIgnoreDupResponses();
-
- /**
- * Setter for property name of events queue on client side - for avoid to send requests
too frequnly ( on key events, for example ), implementation will be generated by
- * componnents-generator
- * @param newvalue - new property value
- */
- public abstract void setEventsQueue(String newvalue);
-
- /**
- * Getter for property Delay ( in ms. ) for send ajax request on JavaScript event. In
conjunction with events queue can reduce number of requests on keyboard or mouse move
events., implementation will be generated by
- * componnents-generator
- * @return property value
- */
- public abstract int getRequestDelay();
-
- /**
- * Setter for property Delay ( in ms. ) for send ajax request on JavaScript event. In
conjunction with events queue can reduce number of requests on keyboard or mouse move
events., implementation will be generated by
- * componnents-generator
- * @param newvalue - new property value
- */
- public abstract void setRequestDelay(int newvalue);
-
- /**
- * Getter for request timeout
- * @return timeout in ms.
- */
- public abstract int getTimeout();
-
- /**
- * Setter for request timeout
- * @param timeout new value in ms.
- */
- public abstract void setTimeout(int timeout);
-
-
- /**
- * Setter for a 'focus' bean property - id of component( or of DOM element ), to
set focus after AJAX request.
- * @param focus
- */
- public abstract void setFocus(String focus);
-
- /**
- * @return
- */
- public abstract String getFocus();
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,54 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-
-/**
- * Extend Ajax-enabled region to support event listeners on Ajax requests.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:39 $
- *
- */
-public interface AjaxContainer extends AjaxContainerBase, AjaxSource
-{
-
- /**
- * Is ajax container must re-render all output from page or only it's children ?
- * @return true if all ajax-enabled to re-render araes on page must be checked for
output.
- */
- public abstract boolean isRenderRegionOnly();
-
- public abstract void setRenderRegionOnly(boolean reRenderPage);
-
- /**
- * Encode AJAX response from this container ( call encode methods for selected
components only )
- * @param context
- * @throws IOException
- */
- public void encodeAjax(FacesContext context) throws IOException ;
-
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContainerBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,94 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.util.Collection;
-import java.util.Set;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * Base interface for controller component, managed AJAX Requests.
- * Component, implemented this interface, must always return
<code>true</code> for
- * <code>javax.faces.component.UIComponent#getRendersChildren()</code>
method.
- * in common, set of components, rendered of current request, maintain by it.
- * TODO - add capabilites for components, rendered in
<code>PhaseListener</code>
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/06 16:23:20 $
- *
- */
-public interface AjaxContainerBase {
- /**
- * getter for AjaxListener method. Same as for <code>ActionSource</code>
- *
- * @see javax.faces.component.ActionSource#getActionListener()
- */
- public MethodBinding getAjaxListener();
-
- /**
- * setter for AjaxListener <code>MethodBinding</code>
- * in case on AjaxRequest, component must call this method in
- * <code>PhaseId.APPLY_REQUEST_VALUES</code> or
- * <code>PhaseId.INVOKE_APPLICATION</code> phases, depend on immediate
flag.
- *
- * @see
javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
- */
- public void setAjaxListener(MethodBinding AjaxListener);
-
- /**
- * getter for flag immediate call Listener's on PhaseId.APPLY_REQUEST_VALUES
phase.
- *
- * @see javax.faces.component.ActionSource#isImmediate()
- */
- public boolean isImmediate();
-
- /**
- * getter for render method flag of subview. If true, on AJAX-request component
render it children
- * after {@link com.sun.faces.lifecycle.Phase.INVOKE_APPLICATION }
- * @return value of selfRendered flag
- */
- public boolean isSelfRendered();
-
- /**
- * setter for self-render flag.
- * @param selfRendered
- */
- public void setSelfRendered(boolean selfRendered);
- /**
- * setter for immediate flag.
- *
- * @see javax.faces.component.ActionSource#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate);
-
- public boolean isSubmitted();
-
- public void setSubmitted(boolean submitted);
-
- /**
- * Render AJAX response for this container from stored View.
- * @param context
- * @throws FacesException
- */
-// public void renderAjaxRegion(FacesContext context) throws FacesException ;
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,806 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.application.StateManager.SerializedView;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.skin.Skin;
-import org.ajax4jsf.framework.skin.SkinFactory;
-import org.ajax4jsf.framework.skin.SkinNotFoundException;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This class incapsulated
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
- *
- */
-public class AjaxContext {
- /**
- * Key for keep request state information in request-scope attributes.
- */
- public static final String AJAX_CONTEXT_KEY = "ajaxContext";
-
- public static final String SCRIPTS_PARAMETER =
"org.ajax4jsf.framework.HEADER_SCRIPTS";
-
- public static final String STYLES_PARAMETER =
"org.ajax4jsf.framework.HEADER_STYLES";
-
- public static final String RESOURCES_PROCESSED =
"org.ajax4jsf.framework.HEADER_PROCESSED";
-
- public static final String RESPONSE_DATA_KEY = "_ajax:data";
-
- private static final Log log = LogFactory.getLog(AjaxContext.class);
-
- private static ComponentInvoker invoker;
-
- private static Map contextClasses = new HashMap();
-
- Set ajaxAreasToRender = new HashSet();
-
- Set ajaxRenderedAreas = new HashSet();
-
- boolean ajaxRequest = false;
-
- boolean ajaxRequestSet = false;
-
- boolean selfRender = false;
-
- Integer viewSequence = new Integer(1);
-
- String submittedRegionClientId = null;
-
- boolean submittedRegionSet = false;
-
- ViewIdHolder viewIdHolder = null;
-
- Map responseDataMap = new HashMap();
-
- Map commonAjaxParameters = new HashMap();
-
- static {
- try {
- // Attempt to create JSF1.2 specific invoker.
- invoker = new JsfOneOneInvoker();
- } catch (Exception e) {
- invoker = new JsfOneOneInvoker();
- }
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @return memento instance for current request
- */
- public static AjaxContext getCurrentInstance() {
- FacesContext context = FacesContext.getCurrentInstance();
- return getCurrentInstance(context);
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @param context
- * current FacesContext
- * @return instance of AjaxContext.
- */
- public static AjaxContext getCurrentInstance(FacesContext context) {
- if (null == context) {
- throw new NullPointerException("FacesContext is null");
- }
- AjaxContext ajaxContext = (AjaxContext) context.getApplication()
- .getVariableResolver().resolveVariable(context,
- AJAX_CONTEXT_KEY);
- if (null == ajaxContext) {
- // Create default implementation.
- ajaxContext = new AjaxContext();
- context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
- ajaxContext);
- }
- return ajaxContext;
- }
-
- /**
- * @param root
- * @param context
- * @param callback
- * @param regionId
- * @return
- * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
- */
- public static boolean invokeOnComponent(UIComponent root,
- FacesContext context, InvokerCallback callback, String regionId) {
- return invoker.invokeOnComponent(root, context, callback, regionId);
- }
-
- /**
- * @param viewRoot
- * @param context
- * @param callback
- * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback)
- */
- public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
- FacesContext context, InvokerCallback callback) {
- invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
- }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- renderAjaxRegion(context, component, true);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
-
- };
-
- public void renderSubmittedAjaxRegion(FacesContext context) {
- renderSubmittedAjaxRegion(context, true);
- }
-
- public void renderSubmittedAjaxRegion(FacesContext context,
- final boolean useFilterWriter) {
- InvokerCallback ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- renderAjaxRegion(context, component, useFilterWriter);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
-
- };
- if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
- getSubmittedRegionClientId(context))) {
- renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
- }
-
- }
-
- /**
- * @param context
- * @param useFilterWriter
- * TODO
- * @throws AbortProcessingException
- */
- public void renderAjaxRegion(FacesContext context, UIComponent component,
- boolean useFilterWriter) throws FacesException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
- component.getId()));
- }
- try {
- setSelfRender(true);
- // create response writer.
- ExternalContext extContext = context.getExternalContext();
- RenderKit renderKit = context.getRenderKit();
- String encoding;
- // Depends if we talk about servlets, portlets, ...
- if (extContext.getRequest() instanceof ServletRequest) {
- ServletRequest request = (ServletRequest) extContext
- .getRequest();
- ServletResponse response = (ServletResponse) extContext
- .getResponse();
- // HACK - bypass MyFaces ( and other ) extensions filter.
-
- // Setup encoding and content type
- String contentType = "text/xml";
- // get the encoding - must be setup by faces context or filter.
- encoding = request.getCharacterEncoding();
- if (encoding == null) {
- encoding = "UTF-8";
- }
- response.setContentType(contentType + ";charset=" + encoding);
- } else
- encoding = "UTF-8";
-
- PrintWriter servletWriter;
- if (useFilterWriter
- && extContext.getRequestMap().containsKey(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- // HACK - Special case for MyFaces, since <f:view don't call
- // encode methods,
- // encode response as for self-rendered region directly to
- // filter response wrpper.
- // to avoid exceptions, inform wrapper to ignore illegal states
- // for getWriter/Stream.
- ServletResponse servletResponse = (ServletResponse) extContext
- .getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
- servletResponse.resetBuffer();
- servletWriter = servletResponse.getWriter();
- ((FilterServletResponseWrapper) servletResponse)
- .setUseNullStream(true);
- } else {
- servletWriter = getWriter(extContext);
- }
- ResponseWriter writer = renderKit.createResponseWriter(
- servletWriter, null, encoding);
- context.setResponseWriter(writer);
- // make response
- writer.startDocument();
- encodeAjaxBegin(context, component);
- component.encodeBegin(context);
- ((AjaxContainer) component).encodeAjax(context);
- component.encodeEnd(context);
- saveViewState(context);
- encodeAjaxEnd(context, component);
- writer.endDocument();
- writer.flush();
- writer.close();
- servletWriter.close();
- // Save tree state.
- } catch (IOException e) {
- throw new FacesException(Messages.getMessage(
- Messages.RENDERING_AJAX_REGION_ERROR, component
- .getClientId(context)), e);
- } finally {
- context.responseComplete();
- // component.setRendererType(defaultRenderer);
- }
- }
-
- /**
- * Encode declaration for AJAX response. Render
<html><body>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxBegin(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.startElement(HTML.HTML_ELEMENT, component);
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- out.startElement(HTML.BODY_ELEMENT, component);
- }
-
- /**
- * End encoding of AJAX response. Render tag with included areas and
- * close </body></html>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxEnd(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.endElement(HTML.BODY_ELEMENT);
- out.endElement(HTML.HTML_ELEMENT);
- }
-
- /**
- * @param context
- * @param root
- * @throws FacesException
- */
- public void processHeadResources(FacesContext context)
- throws FacesException {
- ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
- if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
- if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- if (log.isDebugEnabled()) {
- log
- .debug("Process component tree for collect used scripts and styles");
- }
- UIViewRoot root = context.getViewRoot();
- Set scripts = new LinkedHashSet();
- Set styles = new LinkedHashSet();
- RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = rkFactory.getRenderKit(context, context
- .getViewRoot().getRenderKitId());
- processHeadResources(context, root, scripts, styles, renderKit);
- if (scripts.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Scripts for insert into head : \n");
- for (Iterator iter = scripts.iterator(); iter.hasNext();) {
- String script = (String) iter.next();
- buff.append(script).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(SCRIPTS_PARAMETER, scripts);
- }
- // Set default style sheet for current skin.
- String styleSheetUri = null;
- try {
- styleSheetUri = (String) SkinFactory.getInstance().getSkin(
- context).getParameter(context,
- Skin.generalStyleSheet);
- } catch (SkinNotFoundException e) {
- log.warn("Current Skin is not found", e);
- }
- if (null != styleSheetUri) {
- String resourceURL = context.getApplication()
- .getViewHandler().getResourceURL(context,
- styleSheetUri);
- // TODO - some resources can be non-session aware, we
- // must
- // skip encoding for this case ?
- // But, in common case - static links not need session
- // info,
- // and dynamic resources perform encodings if nessesary
- // resourceURL =
- // context.getExternalContext().encodeResourceURL(resourceURL);
- styles.add(resourceURL);
- }
- if (styles.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Styles for insert into head : \n");
- for (Iterator iter = styles.iterator(); iter.hasNext();) {
- String style = (String) iter.next();
- buff.append(style).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(STYLES_PARAMETER, styles);
- }
- // Mark as processed.
- requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
- }
-
- }
- }
-
- /**
- * Append nessesary scripts and styles from component ( if renderer
- * implements {@link HeaderResourceProducer}) and recursive process all
- * facets and childrens.
- *
- * @param context
- * TODO
- * @param root
- * @param scripts
- * @param styles
- * @param renderKit
- * TODO
- */
- private void processHeadResources(FacesContext context, UIComponent root,
- Set scripts, Set styles, RenderKit renderKit) {
- Renderer renderer = getRenderer(context, root, renderKit);
- if (null != renderer) {
- if (renderer instanceof HeaderResourceProducer) {
- HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
- Set set = producer.getHeaderScripts(context, root);
- if (null != set) {
- scripts.addAll(set);
- }
- set = producer.getHeaderStyles(context, root);
- if (null != set) {
- styles.addAll(set);
- }
- }
- }
- for (Iterator iter = root.getFacets().values().iterator(); iter
- .hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- }
-
- /**
- * Find renderer for given component.
- *
- * @param context
- * @param comp
- * @param renderKit
- * @return
- */
- private Renderer getRenderer(FacesContext context, UIComponent comp,
- RenderKit renderKit) {
-
- String rendererType = comp.getRendererType();
- if (rendererType != null) {
- return (renderKit.getRenderer(comp.getFamily(), rendererType));
- } else {
- return (null);
- }
-
- }
-
- public void saveViewState(FacesContext context) throws IOException {
- // TODO - for facelets environment, we need to remove transient
- // components.
- try {
- Application.class.getMethod("getExpressionFactory", null);
- } catch (NoSuchMethodException e) {
- // JSF 1.1 !
- }
- ResponseWriter writer = context.getResponseWriter();
- StateManager stateManager = context.getApplication().getStateManager();
- SerializedView serializedView = stateManager
- .saveSerializedView(context);
- if (null != serializedView) {
- StringWriter bufWriter = new StringWriter();
- ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
- context.setResponseWriter(cloneWithWriter);
- stateManager.writeState(context, serializedView);
- cloneWithWriter.flush();
- if (bufWriter.getBuffer().length() > 0) {
- context.getExternalContext().getRequestMap().put(
- AjaxViewHandler.SERIALIZED_STATE_KEY,
- bufWriter.toString());
- }
- // Restore original writer.
- context.setResponseWriter(writer);
- }
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest() {
- return isAjaxRequest(FacesContext.getCurrentInstance());
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest(FacesContext context) {
- if (!this.ajaxRequestSet) {
- ajaxRequest = null != getSubmittedRegionClientId(context);
- ajaxRequestSet = true;
- }
- return ajaxRequest;
- }
-
- /**
- * @param ajaxRequest
- * The ajaxRequest to set.
- */
- public void setAjaxRequest(boolean ajaxRequest) {
- this.ajaxRequest = ajaxRequest;
- this.ajaxRequestSet = true;
- }
-
- /**
- * @return Returns the ajaxAreasToRender.
- */
- public Set getAjaxAreasToRender() {
- return this.ajaxAreasToRender;
- }
-
- /**
- * Add affected regions's ID to ajaxView component.
- *
- * @param component
- */
- public void addRegionsFromComponent(UIComponent component) {
- // First step - find parent ajax view
- Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
- // if (ajaxRegions == null){
- // FacesContext context = FacesContext.getCurrentInstance();
- // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
- // }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
- component.getId()));
- }
- if (ajaxRegions != null) {
- for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
- String id = iter.next().toString();
- ajaxAreasToRender.add(convertId(component, id));
- }
- }
- }
-
- public void addComponentToAjaxRender(UIComponent component) {
- this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
- }
-
- public void addComponentToAjaxRender(UIComponent base, String id) {
- this.ajaxAreasToRender.add(convertId(base, id));
- }
-
- /**
- * Test for relative id of target components. Attempt convert to
- * absolute. For use as argument for
- * {@link UIComponent#findComponent(java.lang.String)}
- *
- * @param component
- * @param id
- * @return
- */
- private String convertId(UIComponent component, String id) {
- if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
- return id;
- }
- if (null == component) {
- throw new NullPointerException(
- "Base component for search re-rendered compnnent is null");
- }
- UIComponent target = null;
- UIComponent parent = component;
- UIComponent root = component;
- while (null == target && null != parent) {
- target = parent.findComponent(id);
- root = parent;
- parent = parent.getParent();
- }
- if (null == target) {
- target = findUIComponentBelow(root, id);
- }
- if (null != target) {
- return AjaxRendererUtils.getAbsoluteId(target);
- }
- log.warn("Target component for id "+id+" not found");
- return id;
- }
-
- private UIComponent findUIComponentBelow(UIComponent root,
- String id) {
-
- UIComponent target = null;
- for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof NamingContainer) {
- try {
- target = child.findComponent(id);
- } catch (IllegalArgumentException iae) {
- continue;
- }
- }
- if (target == null) {
- if (child.getChildCount() > 0) {
- target = findUIComponentBelow(child, id);
- }
- }
-
- if (target != null) {
- break;
- }
-
- }
- return target;
- }
-
- /**
- * @return Returns the ajaxRenderedAreas.
- */
- public Set getAjaxRenderedAreas() {
- return ajaxRenderedAreas;
- }
-
- public void addRenderedArea(String id) {
- ajaxRenderedAreas.add(id);
- }
-
- public boolean removeRenderedArea(String id) {
- return ajaxRenderedAreas.remove(id);
- }
-
- /**
- * @return Returns the submittedClientId.
- */
- public String getSubmittedRegionClientId(FacesContext context) {
- if (!this.submittedRegionSet) {
- this.submittedRegionClientId = (String) context
- .getExternalContext().getRequestParameterMap().get(
- AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- this.submittedRegionSet = true;
- if (!this.ajaxRequestSet) {
- setAjaxRequest(this.submittedRegionClientId != null);
- }
- }
- return this.submittedRegionClientId;
- }
-
- /**
- * @param submittedClientId
- * The submittedClientId to set.
- */
- public void setSubmittedRegionClientId(String submittedClientId) {
- this.submittedRegionClientId = submittedClientId;
- this.submittedRegionSet = true;
- }
-
- /**
- * @return Returns the selfRender.
- */
- public boolean isSelfRender() {
- return selfRender;
- }
-
- /**
- * @param selfRender
- * The selfRender to set.
- */
- public void setSelfRender(boolean selfRender) {
- this.selfRender = selfRender;
- }
-
- /**
- * @return the vievIdHolder
- */
- public ViewIdHolder getViewIdHolder() {
- return viewIdHolder;
- }
-
- /**
- * @param viewIdHolder
- * the vievIdHolder to set
- */
- public void setViewIdHolder(ViewIdHolder viewIdHolder) {
- this.viewIdHolder = viewIdHolder;
- }
-
- /**
- * @return the responseData
- */
- public Object getResponseData() {
- return responseDataMap.get(RESPONSE_DATA_KEY);
- }
-
- /**
- * @param responseData
- * the responseData to set
- */
- public void setResponseData(Object responseData) {
- this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
- }
-
- /**
- * @return the responseDataMap
- */
- public Map getResponseDataMap() {
- return responseDataMap;
- }
-
- /**
- * Gives back the writer of a Response object.
- *
- * @param extContext
- * The external context.
- * @return The writer of the response.
- * @throws FacesException
- * If the response object has no getWriter() method.
- */
- protected PrintWriter getWriter(ExternalContext extContext)
- throws FacesException {
- PrintWriter writer = null;
- Object response = extContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getWriter", new Class[0]);
- writer = (PrintWriter) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return writer;
- }
-
- public String getAjaxActionURL() {
- return getAjaxActionURL(FacesContext.getCurrentInstance());
- }
-
- public String getAjaxActionURL(FacesContext context) {
- // Check arguments
- if (null == context) {
- throw new NullPointerException(
- "Faces context for build AJAX Action URL is null");
- }
- UIViewRoot viewRoot = context.getViewRoot();
- if (null == viewRoot) {
- throw new NullPointerException(
- "Faces view tree for build AJAX Action URL is null");
- }
- String viewId = viewRoot.getViewId();
- if (null == viewId) {
- throw new NullPointerException(
- "View id for build AJAX Action URL is null");
- }
- if (!viewId.startsWith("/")) {
- throw new IllegalArgumentException(
- "Illegal view Id for build AJAX Action URL: " + viewId);
- }
- ViewHandler viewHandler = context.getApplication().getViewHandler();
- return context.getExternalContext().encodeActionURL(
- viewHandler.getActionURL(context, viewId));
- }
-
- /**
- * @return the commonAjaxParameters
- */
- public Map getCommonAjaxParameters() {
- return commonAjaxParameters;
- }
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
- *
- * Event for send by <code>AjaxContainer</code> in case of Ajax Request.
- * Used for build set of id's to render at current request, perform special render
etc.
- */
-public class AjaxEvent extends FacesEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = -5624716710738446159L;
-
- /**
- * @param component
- */
- public AjaxEvent(UIComponent component) {
- super(component);
- setPhaseId(PhaseId.RENDER_RESPONSE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return (listener instanceof AjaxListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- ((AjaxListener) listener).processAjax(this);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,40 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.event.FacesListener;
-
-/**
- * Base interface for all listeners, capable for receive
<code>AjaxEvent</code>
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:36 $
- */
-public interface AjaxListener extends FacesListener {
-
- public static final Class[] AJAX_LISTENER_ARGS = { AjaxEvent.class };
-
- /**
- * @param event - to process
- */
- void processAjax(AjaxEvent event);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxOutput.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-/**
- * Marker interface for all JSF components, encoded ( or not ) on rendering
- * Ajax request , depend on it self properties ( such as messages, help or like
components )
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:39 $
- *
- */
-public interface AjaxOutput {
- /**
- * getter for ajax-rendered flag property.
- * @return
- */
- public boolean isAjaxRendered();
- /**
- * Setter for ajax rendered property.
- * @param ajaxRendered
- */
- public void setAjaxRendered(boolean ajaxRendered);
-
- /**
- * getter for ajax-rendered flag property.
- * @return
- */
- public boolean isKeepTransient();
- /**
- * Setter for ajax rendered property.
- * @param ajaxRendered
- */
- public void setKeepTransient(boolean ajaxRendered);
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,65 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:41 $
- *
- */
-public class AjaxRenderEvent extends FacesEvent {
-
- /**
- * @param component
- */
- public AjaxRenderEvent(UIComponent component) {
- super(component);
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- // TODO Auto-generated method stub
- return listener instanceof AjaxRenderListener;
- }
-
- public void processListener(FacesListener listener) {
- if (listener instanceof AjaxRenderListener) {
- AjaxRenderListener renderListener = (AjaxRenderListener) listener;
- renderListener.processAjaxRender(this);
- }
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#getPhaseId()
- */
-// public PhaseId getPhaseId() {
-// // TODO Auto-generated method stub
-// return PhaseId.INVOKE_APPLICATION;
-// }
-
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRenderListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author shura
- *
- */
-public interface AjaxRenderListener extends FacesListener {
-
- public void processAjaxRender(AjaxRenderEvent event);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,51 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-/**
- * Interface for all components capable to process {@link
org.ajax4jsf.framework.ajax.AjaxEvent}'s
- * @author shura
- *
- */
-public interface AjaxSource {
- /**
- * same as for ActionSource, but for AjaxListener
- *
- * @see
javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
- */
- public void addAjaxListener(AjaxListener listener);
-
- /**
- * same as for ActionSource, but for AjaxListener
- *
- * @see javax.faces.component.ActionSource#getActionListeners()
- */
- public AjaxListener[] getAjaxListeners();
-
- /**
- * same as for ActionSource, but for AjaxListener
- * @see
javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
- */
- public void removeAjaxListener(AjaxListener listener);
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSupport.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,71 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Version of {@link org.ajax4jsf.framework.ajax.AjaxComponent} for append
- * Ajax functions for non-ajax components
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:34 $
- *
- */
-public interface AjaxSupport extends AjaxComponent {
-
- /**
- * @return JavaScript eventString. Rebuild on every call, since
- * can be in loop ( as in dataTable ) with different parameters.
- */
- public String getEventString();
- /**
- * setter method for property
- * @param new value of Name of event property of parent component for build
JavaScript AJAX.Submit call to set
- */
- public abstract void setEvent(String event);
-
- /**
- * @return value or result of valueBinding of Name of event property of parent
component for build JavaScript AJAX.Submit call
- */
- public abstract String getEvent();
-
-
- /**
- * Getter for property If true, disable default action for target event ( encode
'return false' to JavaScript ), implementation will be generated by
- * componnents-generator
- * @return property value
- */
- public abstract boolean isDisableDefault();
-
- /**
- * Setter for property If true, disable default action for target event ( encode
'return false' to JavaScript ), implementation will be generated by
- * componnents-generator
- * @param newvalue - new property value
- */
- public abstract void setDisableDefault(boolean newvalue);
-
- /**
- * Set property for JavaScrept event generated by this component.
- * @param parent
- */
- public void setParentProperties(UIComponent parent);
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourceProducer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.util.LinkedHashSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * Interface for renderers, for wich nessesary insert script or style resource in
header.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
- *
- */
-public interface HeaderResourceProducer {
-
- /**
- * Return set of strings with URI's of nessesary scripts.
- * Use linked set to preserve insertion order
- * @param context - current faces context.
- * @param component TODO
- * @return - set of URI's or null
- */
- public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component);
-
- /**
- * Return set of strings with URI's of nessesary CSS styles.
- * Use linked set to preserve insertion order.
- * @param context - current faces context.
- * @param component TODO
- * @return - set of URI's or null
- */
- public LinkedHashSet getHeaderStyles(FacesContext context, UIComponent component);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,98 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
- *
- */
-public abstract class ImageRenderer extends BaseResourceRenderer {
-
- private static final String _tag = "img";
- private static final String _hrefAttr = "src";
- private static final String[][] _commonAttrs = {
-
- };
- /**
- * @return Returns the commonAttrs.
- */
- protected String[][] getCommonAttrs() {
- return null ; //_commonAttrs;
- }
-
- /**
- * @return Returns the hrefAttr.
- */
- protected String getHrefAttr() {
- return _hrefAttr;
- }
-
- /**
- * @return Returns the tag.
- */
- protected String getTag() {
- return _tag;
- }
-
- /**
- * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
- * @param context - current faces context.
- * @param image - imaje to send
- */
- public abstract void sendImage(ResourceContext context,RenderedImage image) throws
IOException;
-
- /**
- * @return type of image for create {@link BufferedImage}
- */
- public abstract int getImageType();
-
- /**
- * Create blank {@link BufferedImage} for paint.
- * Type of image determined by current renderer.
- * @param width
- * @param height
- * @return new image
- */
- public BufferedImage createImage(int width,int height){
- return new BufferedImage(width,height,getImageType());
- }
-
- protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
- if (resource instanceof Java2Dresource) {
- Java2Dresource j2d = (Java2Dresource) resource;
- Dimension dim = j2d.getDimensions(context, data);
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute("width", String.valueOf(dim.width),
"width");
- writer.writeAttribute("height", String.valueOf(dim.height),
"height");
- }
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,192 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Interface for work with off-page internet resources ( images, scripts, styles etc. )
- * All instances must work in two phases - render page ( application set HTML code and
attributes to reference resource )
- * and in concrete request to resource body.
- * For best performance, preffer to realise it as "lightweght" pattern.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:15 $
- *
- */
-public interface InternetResource {
-
- public static final String ENCODE_URI_PARAMETER =
"org.ajax4jsf.ENCRYPT_RESOURCE_DATA";
- public static final String ENCODE_PASS_PARAMETER =
"org.ajax4jsf.ENCRYPT_PASSWORD";
- public static final String CODEC_ATTR =
"org.ajax4jsf.framework.resource.CODEC";
-
- public static final String RESOURCE_PROTOCOL = "resource";
- public static final String RESOURCE_URI_PREFIX = "resource://";
- public static final int RESOURCE_URI_PREFIX_LENGTH = RESOURCE_URI_PREFIX.length();
- public static final String DATA_SEPARATOR = "/DATA/";
- static public final long DEFAULT_EXPIRE = 1000L * 60L * 60L * 24L;// 1 day
-
- /**
- * @param resourceContext current {@link ResourceContext}
- * @return Returns the contentLength.
- */
- public int getContentLength(ResourceContext resourceContext);
-
- /**
- * @param resourceContext current {@link ResourceContext}
- * @return Returns the expired.
- */
- public Date getExpired(ResourceContext resourceContext);
-
- /**
- * @param resourceContext current {@link ResourceContext}
- * @return Returns the lastModified.
- */
- public Date getLastModified(ResourceContext resourceContext);
-
- /**
- * @param resourceContext current {@link ResourceContext}
- * @return Returns the cacheable.
- */
- public boolean isCacheable(ResourceContext resourceContext);
-
- /**
- * @param resourceContext current {@link ResourceContext}
- * @return Returns the mimeType.
- */
- public String getContentType(ResourceContext resourceContext);
-
- /**
- * @param context TODO
- * @return input stream with resource
- */
- public InputStream getResourceAsStream(ResourceContext context);
-
- /**
- * @return string with URI for get resource from page.
- */
- public String getUri(FacesContext context, Object data);
-
-
-
- /**
- * Encode resource as Markup .
- * @param context
- * @param data
- * @throws IOException
- */
- public void encode(FacesContext context, Object data) throws IOException;
-
- /**
- * Encode resource as Markup with custom attributes .
- * @param context
- * @param data
- * @param attributes
- * @throws IOException
- */
- public void encode(FacesContext context, Object data,Map attributes) throws
IOException;
-
- /**
- * Encode start tag, attributes and body ( for inline script or style )
- * @param context
- * @param component
- * @param attrs
- * @throws IOException
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs) throws
IOException;
-
- /**
- * Encode closed tag.
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException;
-
- /**
- * Send incapsulated resource to client by {@link ResourceContext} .
- * @param context
- */
- public void send(ResourceContext context) throws IOException;
-
- /**
- * Set response headers based on resource properties ( mime type etc )
- * TODO - send via {@link FacesContext } ???
- * @param response
- */
- public void sendHeaders(ResourceContext response);
-
- /**
- * Custom properties for resource ( image size etc. )
- * @param key
- * @return property value, or null if not set.
- */
- public Object getProperty(Object key);
-
- /**
- * Set new value for custom property.
- * @param key
- * @param value
- */
- void setProperty(Object key,Object value);
-
-
- /**
- * Set concrete renderer ( for brige pattern ). In renderer, incapsulate encoding
functions,
- * content type, resource encoding.
- * @param renderer
- */
- public void setRenderer(ResourceRenderer renderer);
-
- /**
- * @return true, if resource must be rendered in faces request cicle.
- */
- public boolean requireFacesContext();
-
- /**
- * Flag for check session-dependencies for resource. In application-wide case,
- * resource URL not prepared by
context.getExternalContext().encodeResourceURL(resourceURL)
- * and used application-wide cache for store.
- * @return
- */
- public boolean isSessionAware();
-
- void setKey(String key);
-
- String getKey();
-
- public abstract ResourceRenderer getRenderer(ResourceContext resourceContext);
-
- public abstract void setSessionAware(boolean sessionAware);
-
- public abstract void setCacheable(boolean cacheable);
-
- public abstract void setLastModified(Date lastModified);
-
- public abstract void setExpired(Date expired);
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,175 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class InternetResourceBuilder {
-
- private static final Log log = LogFactory.getLog(InternetResourceBuilder.class);
-
- /**
- * Get application start time for check resources modification time.
- *
- * @return application start time in msec's
- */
- public abstract long getStartTime();
-
- /**
- * @param cacheable
- * @param session
- * @param mime
- * @return
- * @throws FacesException
- */
- public abstract InternetResource createUserResource(boolean cacheable,
- boolean session, String mime) throws FacesException;
-
- /**
- * @param key
- * @param resource
- */
- public abstract void addResource(String key, InternetResource resource);
-
- /**
- * @param path
- * @return
- * @throws ResourceNotFoundException
- */
- public abstract InternetResource getResource(String path)
- throws ResourceNotFoundException;
-
- /**
- * @param key
- * @return
- */
- public abstract Object getResourceDataForKey(String key);
-
- /**
- * @param key
- * @return
- * @throws ResourceNotFoundException
- */
- public abstract InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException;
-
- /**
- * @param resource
- * @param context
- * @param storeData
- * @return
- */
- public abstract String getUri(InternetResource resource,
- FacesContext context, Object storeData);
-
- /**
- * @param base
- * @param path
- * @return
- * @throws FacesException
- */
- public abstract InternetResource createResource(Object base, String path)
- throws FacesException;
-
- /**
- * @throws ServletException
- */
- public abstract void init()
- throws FacesException;
-
- /**
- * static instance variable.
- */
- private static Map instances = Collections.synchronizedMap(new HashMap());
-
- /**
- * Get ( or create if nessesary ) instance of builder for current
- * loader. check content of file
- * META-INF/services/org.ajax4jsf.framework.resource.InternetResourceBuilder
- * for name of class to instantiate, othrthise create
- * {@link ResourceBuilderImpl} instance.
- *
- * @return current builder instance.
- */
- public static InternetResourceBuilder getInstance() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InternetResourceBuilder instance = (InternetResourceBuilder) instances
- .get(loader);
- if (null == instance) {
- try {
- String resource = "META-INF/services/"
- + InternetResourceBuilder.class.getName();
- InputStream in = loader.getResourceAsStream(resource);
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
- String serviceClassName = reader.readLine();
- reader.close();
- Class builderClass = loader.loadClass(serviceClassName);
- instance = (InternetResourceBuilder) builderClass.newInstance();
- if (log.isDebugEnabled()) {
- log.debug("Create instance of InternetBuilder from class "
- + serviceClassName);
- }
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log
- .debug("Create default implementation instance of InternetBuilder");
- }
- instance = new ResourceBuilderImpl();
- }
- instances.put(loader, instance);
- }
- if(log.isDebugEnabled()){
- log.debug("Return instance of internet resource builder
"+instance.toString());
- }
- return instance;
- }
-
- /**
- * Package-wide method for reset instance in Junit tests.
- *
- * @param instance
- */
- public static void setInstance(InternetResourceBuilder instance) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- instances.put(loader, instance);
- }
-
- public InternetResourceBuilder() {
- super();
- }
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,145 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
-/**
- * Abstraction context class for rendering resource ( image, script, style )
- * can be work in 2 variants - for simple ServletRequest and as JSF context
encapsulation.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:57 $
- *
- */
-public abstract class ResourceContext {
-
- private boolean cacheEnabled = false;
- private Object resourceData;
- // response headers
- /**
- * Delegate to {@link javax.servlet.ServletResponse} setHeader
- * @param name name of header
- * @param value new value
- */
- public abstract void setHeader(String name, String value);
-
- /**
- * Delegate to {@link javax.servlet.ServletResponse} setHeader
- * @param name name of header
- * @param value new value
- */
- public abstract void setIntHeader(String name, int value);
-
- /**
- * Delegate to {@link javax.servlet.ServletResponse} setHeader
- * @param name name of header
- * @param value new value
- */
- public abstract void setDateHeader(String name, long value);
-
- /**
- * @return
- * @throws IOException
- */
- public abstract OutputStream getOutputStream() throws IOException;
-
- /**
- * @return
- */
- public abstract String getQueryString();
-
- /**
- * @return
- */
- public abstract String getPathInfo();
-
- /**
- * @return
- */
- public abstract String getServletPath();
-
- /**
- * Get session attribute for given name. session not created
- * @param name attribute name
- * @return value for attribute, or null.
- */
- public abstract Object getSessionAttribute(String name);
-
- public abstract InputStream getResourceAsStream(String path);
-
- /**
- * Get request parameter for given name.
- * @param data_parameter
- * @return
- */
- public abstract String getRequestParameter(String data_parameter);
-
- /**
- * @return Returns the cacheEnabled.
- */
- public boolean isCacheEnabled() {
- return this.cacheEnabled;
- }
-
- /**
- * @param cacheEnabled The cacheEnabled to set.
- */
- public void setCacheEnabled(boolean cacheEnabled) {
- this.cacheEnabled = cacheEnabled;
- }
-
- /**
- * get output writer for send response.
- * @return
- */
- public abstract PrintWriter getWriter() throws IOException;
-
- /**
- * Setup response content type as {@see
javax.servlet.ServletResponse#setContentType(java.lang.String)}
- * @param contentType
- */
- public abstract void setContentType(String contentType);
-
- public abstract String getInitParameter(String name);
-
- public Object getResourceData() {
- // TODO Auto-generated method stub
- return resourceData;
- }
-
- public void setResourceData(Object data) {
- resourceData = data;
-
- }
-
- /**
- * Release any data used by this context.
- * Close buffers used by cached context, release FacesContext, if exist.
- */
- public void release() {
-
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceNotFoundException.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,67 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import javax.faces.FacesException;
-
-/**
- * Exception for throw in case of illegal creation of resource ( not existed file etc. )
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:08 $
- *
- */
-public class ResourceNotFoundException extends FacesException {
-
- /**
- *
- */
- public ResourceNotFoundException() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param arg0
- */
- public ResourceNotFoundException(String arg0) {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param arg0
- */
- public ResourceNotFoundException(Throwable arg0) {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param arg0
- * @param arg1
- */
- public ResourceNotFoundException(String arg0, Throwable arg1) {
- super(arg0, arg1);
- // TODO Auto-generated constructor stub
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceProduser.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-
-/**
- * Interface for all Renderers ( or other classes ? ) for
- * generate internet resources.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
- *
- */
-public interface ResourceProduser {
- /**
- * @param path - local path to internet resource.
- * @return resource instance
- */
- public InternetResource getResource( String path) throws ResourceNotFoundException;
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * "Brige" for concrete resource types - images, scripts, styles.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:07 $
- *
- */
-public interface ResourceRenderer {
-
- /**
- * @return content type ( image/jpeg , text/javascript etc. ) for given type.
- */
- String getContentType();
-
- /**
- * Encode concrete HTML element for resource.
- * @param context
- * @param data
- * @throws IOException
- */
- void encode(InternetResource resource, FacesContext context, Object data) throws
IOException;
-
- /**
- * Encode concrete HTML element for resource.
- * @param context
- * @param data
- * @throws IOException
- */
- void encode(InternetResource resource, FacesContext context, Object data, Map
attributes) throws IOException;
-
- void encodeBegin(InternetResource base, FacesContext context, Object data, Map
attributes) throws IOException;
-
- void encodeEnd(InternetResource base, FacesContext context, Object data) throws
IOException;
-
- /**
- * @return true, if resource must be rendered in faces request cicle.
- */
- public boolean requireFacesContext();
-
- /**
- * Send incapsulated resource to client by {@link ResourceContext} .
- * Perform any conversions, nessesary for this resources ( template interpretations,
JavaScript conversions etc )
- * @param context
- * @return TODO
- */
- public int send(InternetResource base,ResourceContext context) throws IOException;
-
- /**
- * Get data to build URI for given resource. Can be any Serialisable object,
- * @param base TODO
- * @return data for Store in URI/ Cache key.
- */
- public Object getData(InternetResource base, FacesContext context, Object data);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,137 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.ajax.resource.ResourceComponent;
-
-/**
- * @author shura
- *
- */
-public class UserResource extends InternetResourceBase {
-
- private String contentType;
- /**
- *
- */
- public UserResource(boolean cacheable, boolean session, String mime) {
- super();
- setCacheable(cacheable);
- setSessionAware(session);
- setContentType(mime);
- }
- /**
- * @return Returns the contentType.
- */
- public String getContentType(ResourceContext resourceContext) {
- return contentType;
- }
- /**
- * @param contentType The contentType to set.
- */
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public Object getDataToStore(FacesContext context, Object data) {
- UriData dataToStore = null;
- if (data instanceof ResourceComponent) {
- ResourceComponent resource = (ResourceComponent) data;
- dataToStore = new UriData();
- dataToStore.value = resource.getValue();
- dataToStore.createContent =
UIComponentBase.saveAttachedState(context,resource.getCreateContent());
- if (data instanceof UIComponent) {
- UIComponent component = (UIComponent) data;
- ValueBinding expires = component.getValueBinding("expires");
- if (null != expires) {
- dataToStore.expires = UIComponentBase.saveAttachedState(context,expires);
- }
- ValueBinding lastModified = component.getValueBinding("lastModified");
- if (null != lastModified) {
- dataToStore.modified = UIComponentBase.saveAttachedState(context,lastModified);
- }
- }
- }
- return dataToStore;
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.resource.InternetResourceBase#send(org.ajax4jsf.framework.resource.ResourceContext)
- */
- public void send(ResourceContext context) throws IOException {
- UriData data = (UriData) restoreData(context);
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (null != data && null != facesContext ) {
- // Send headers
- if(data.expires != null){
- ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.expires);
- Date expires = (Date) binding.getValue(facesContext);
- context.setDateHeader("Expires",expires.getTime());
- }
- if(data.modified != null){
- ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.modified);
- Date modified = (Date) binding.getValue(facesContext);
- context.setDateHeader("Last-Modified",modified.getTime());
- }
- // Send content
- OutputStream out = context.getOutputStream();
- MethodBinding send = (MethodBinding)
UIComponentBase.restoreAttachedState(facesContext,data.createContent);
- send.invoke(facesContext,new Object[]{out,data.value});
- }
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.InternetResourceBase#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // TODO Auto-generated method stub
- return true;
- }
-
- public static class UriData implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1258987L;
-
- private Object value;
-
- private Object createContent;
-
- private Object expires;
-
- private Object modified;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/Skin.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/Skin.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/Skin.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,324 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Main interface for configurable parameters.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
- *
- */
-public interface Skin {
- // parameters names constants
-
-// parameters names constants
-
- /**
- * used for define url with general CSS file for current skin.
- */
- public static final String generalStyleSheet = "generalStyleSheet";
-
- /**
- * used for defining a header background color in the panel, a tabpanel active tab
- * background color, a bar background color for ddmenu, tables background color,
- * buttons background color. Default value #1D7DB3.
- */
- public static final String headerBackgroundColor = "headerBackgroundColor";
-
- /**
- * used for defining color of the titles of the top level of the menu, the panel header
- * color, the table header color, color of the title of the active tab in the tabpanel,
- * color of the title on the buttons. Default value #FFFFFF.
- */
- public static final String headTextColor = "headTextColor";
-
- /**
- * used for defining the background color of the bar under the header in the panel and
- * the tabpanel, color of the border for the top level of the ddmenu, background
- * highlight color of the selected item in the dropdown list boxes of the ddmenu,
- * background color of the footer in the tables, color of the text for the inactive and
- * disabled tab in the tabpanel, color of the border of the buttons. Default value
- * #BFD7E4.
- */
- public static final String selectBackgroundColor = "selectBackgroundColor";
-
- /**
- * used for defining the background color of the basic area of the panel and tabpanels,
- * background color of the dropdown list boxes of ddmenu. Default value #BFD7E4.
- */
- public static final String generalBackgroundColor = "generalBackgroundColor";
-
- /**
- * used for defining color of the basic text, color of the text in the dropdown list
- * boxes of ddmenu, color of the right and top borders for the controls like text,
- * textArea, secret. Default value #000000.
- */
- public static final String generalTextColor = "generalTextColor";
-
- /**
- * used for defining shadow background color of the panels, color of the bottom and
right
- * borders for the dropdown list box in ddmenu. Default value #AFB1B2.
- */
- public static final String shadowBackgroundColor = "shadowBackgroundColor";
-
- /**
- * used for defining the seamlessness of the tip shadow. Default value 2.
- */
- public static final String shadowOpacity = "shadowOpacity";
-
- /**
- * used for defining tables border color, color of the bottom and left controls like
- * text, textArea, secret, color of the top and left borders for the dropdown list box
in
- * the ddmenu. Default value #CCCCCC.
- */
- public static final String tableBorderColor = "tableBorderColor";
-
- /**
- * used for defining tables and controls background color. Default value #FFFFFF.
- */
- public static final String tableBackgroundColor = "tableBackgroundColor";
-
- /**
- * Font size for the displaying panels headers and top level of the ddmenu. Default
- * value 12px.
- */
- public static final String headerSizeFont = "headerSizeFont";
-
- /**
- * Font name for the displaying panels headers and top level of the ddmenu.Default
value
- * Arial, Verdana.
- */
- public static final String headerFamilyFont = "headerFamilyFont";
-
- /**
- * Font size for displaying tab titles. Default value 11px.
- */
- public static final String tabSizeFont = "tabSizeFont";
-
- /**
- * Font name for displaying tab titles. Default value Arial, Verdana.
- *
- */
- public static final String tabFamilyFont = "tabFamilyFont";
-
- /**
- * Rounding-off radius of the tabs corners. Default value 5px.
- */
- public static final String tabRadiusCorner = "tabRadiusCorner";
-
- /**
- * Font size for displaying buttons titles. Default value 11px.
- */
- public static final String buttonSizeFont = "buttonSizeFont";
-
- /**
- * Font name for displaying buttons titles. Default value Arial, Verdana.
- */
- public static final String buttonFamilyFont = "buttonFamilyFont";
-
- /**
- * Rounding-off radius of the buttons corners. Default value 13px.
- *
- */
- public static final String buttonRadiusCorner = "buttonRadiusCorner";
-
- /**
- * Rounding-off radius of the panels corners. Default value 5px.
- */
- public static final String panelRadiusCorner = "panelRadiusCorner";
-
- /**
- * Style of the text displaying on the button. Default value normal.
- *
- */
- public static final String buttonStyleFont = "buttonStyleFont";
-
- /**
- * Depth of the text displaying on the button. Default value bold.
- */
- public static final String buttonWeightFont = "buttonWeightFont";
-
- /**
- * Style of the text displaying on the active (selected) tabs.Default value normal.
- */
- public static final String activetabStyleFont = "activetabStyleFont";
-
- /**
- * Depth of the text displaying on the active (selected) tabs.Default value bold.
- */
- public static final String activetabWeightFont = "activetabWeightFont";
-
- /**
- * Style of of the text displaying on the inactive (unselected) tabs. Default value
- * normal.
- */
- public static final String tabStyleFont = "tabStyleFont";
-
- /**
- * Depth of the text displaying on the inactive (unselected) tabs.Default value normal.
- */
- public static final String tabWeightFont = "tabWeightFont";
-
- /**
- * Style of the text displaying on the disabled tabs.Default value normal.
- */
- public static final String disabledTabStyleFont = "disabledTabStyleFont";
-
- /**
- * Depth of the text displaying on the disabled tabs.Default value normal.
- */
- public static final String disabledTabWeightFont = "disabledTabWeightFont";
-
- /**
- * Color for selected checkbox or selectOneRadio.
- */
- public static final String selectControlColor = "selectControlColor";
-
- /**
- * Responsible for the borders color of the radiobutton and checkbox and color of light
- * part of the fields and text area border. Default value #B0B0B0.
- */
- public static final String controlBorderColor = "controlBorderColor";
-
- /**
- * Parameter responsible for 3D Look of panels and buttons.
- */
-
- public static final String interfaceLevel3D = "interfaceLevel3D";
-
- /**
- * defines the layout of the tabs in the panel. Possible values Top. Left. Bottom,
Right.
- * Default value ???.
- */
- public static final String preferableTabPosition = "preferableTabPosition";
-
- /**
- * defines the variant of text writing. Values - Hor (horisontal position), Vert
- * (vertical position - letters are arranged into column), VertCW (vertical
- * position with text rotation anticlockwise). Default value Hor.
- */
- public static final String preferableTabTextOrientation =
"preferableTabTextOrientation";
- /**
- * text aligning in the tabs with the fixed tab length (hight). Values Left,
Center,Right
- * for the horizontal oriented tabs, values Top, center, Bottom - for vertical oriented
- * tabs. Default value center.
- */
-
-
- public static final String preferableTabTextDirection =
"preferableTabTextDirection";
-
-
- /**
- *
- */
- public static final String overAllBackground = "overAllBackground";
- /**
- *
- */
- public static final String generalLinkColor = "generalLinkColor";
-
- public static final String panelTextColor = "panelTextColor";
-
- // Preferable parameters
- /**
- * Preferable parameters names for skin ( in common, for Preferable.Name
- * parameter will PreferableName )
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
- *
- */
-
- public interface Preferable {
- /**
- *
- */
- public static final String dataSizeFont = "preferableDataSizeFont";
-
- /**
- *
- */
- public static final String dataFamilyFont = "preferableDataFamilyFont";
-
- /**
- *
- */
- public static final String panelBodyPadding = "preferablePanelBodyPadding";
-
- /**
- *
- */
- public static final String headerWeightFont = "preferableHeaderWeightFont";
-
- }
-
- /**
- * Get Rener Kit name for this skin.
- *
- * @param context -
- * {@link FacesContext } for current request. need for
- * {@link javax.faces.el.ValueBinding} evaluation.
- * @return RenderKitId for this skin, or <code>null</code> for default.
- */
- public String getRenderKitId(FacesContext context);
-
- /**
- * Get value for configuration parameter. If parameter set as EL-expression,
- * calculate it value.
- *
- * @param context -
- * {@link FacesContext } for current request.
- * @param name
- * name of paremeter.
- * @return value of parameter in config, or null
- */
- public Object getParameter(FacesContext context, String name);
-
- /**
- * Get value for configuration parameter. If parameter set as EL-expression,
- * calculate it value.
- *
- * @param context -
- * {@link FacesContext } for current request.
- * @param name
- * name of paremeter.
- * @param defaultValue - default value if parameter not present in Skin
- * @return value of parameter in config, or null
- */
- public Object getParameter(FacesContext context, String name, Object defaultValue);
-
- /**
- * @param name
- * @return
- */
- public boolean containsProperty(String name);
-
- /**
- * Calculate unique ( as possible ) code to identity this skin instance. Used for
generate hash key in skin-depended resources
- * @param context
- * @return
- */
- public int hashCode(FacesContext context);
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinConfiguration.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Fine tuning parameters for components configuration.
- * For any skin, calculation of concrete component parameners done by special
"configuration",
- * pointed as special skin parameter ( or by default configuration ).
- * Work like "transformation" of limited set Skin parameters to fine-grained
individual component
- * parameters.
- * @author shura
- *
- */
-public interface SkinConfiguration {
-
- /**
- * Get value for configuration parameter. If parameter set as EL-expression,
- * calculate it value.
- *
- * @param context -
- * {@link FacesContext } for current request.
- * @param name
- * name of paremeter.
- * @return value of parameter in config, or null
- */
- public Object getParameter(FacesContext context, String name);
-
- /**
- * Get value for skin parameter, for build extensible ( mandatory/fine tuning ) with
three-stage checks :
- * <ul>
- * <li>first, check value for parameter with given name. If value not null, return
it</li>
- * <li>second, got parameter value from skin by skinName key. If not null, return
it.</li>
- * <li>if both above parameters is null, return default value.</li>
- * </ul>
- * @param context - Current JSF context.
- * @param name - name of parameter.
- * @param skinName - name of according ( default ) parameter i Skin for same purpose.
may be <code>null</code>.
- * @param defaultValue - default parameter value.
- * @return - value of parameter.
- */
- public Object getParameter(FacesContext context, String name,String skinName, Object
defaultValue);
- /**
- * Test for present parameter for given name.
- * @param name of parameter to test
- * @return true if parameter present in configuration.
- */
- public boolean containsParameter(String name);
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,179 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Constructor;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base factory class ( implement Singleton design pattern ). Produce self
- * instance to build current skin configuration. At present, realised as lazy
- * creation factory. TODO - select point to initialize.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
- *
- */
-public abstract class SkinFactory {
-
- /**
- * static instance variable.
- */
- private static Map instances = Collections.synchronizedMap(new HashMap());
-
- private static final Log log = LogFactory.getLog(SkinFactory.class);
-
-
- public static void reset() {
- instances = Collections.synchronizedMap(new HashMap());
- }
-
- /**
- * Initialize skin factory. TODO - make call from init() method of any
- * servlet or custom faces element method ??? If exist resource
- * META-INF/services/org.ajax4jsf.framework.skin.SkinFactory , create
- * instance of class by name from first line of this file. If such class
- * have constructor with {@link SkinFactory} parameter, instantiate it with
- * instance of default factory ( as usual in JSF ). If any error occurs in
- * instantiate custom factory, return default.
- */
- public static final SkinFactory getInstance() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- SkinFactory instance = (SkinFactory) instances.get(loader);
- if (instance == null) {
- // Pluggable factories.
- InputStream input = null; // loader.getResourceAsStream(SERVICE_RESOURCE);
- input = loader.getResourceAsStream(SERVICE_RESOURCE);
- // have services file.
- if (input != null) {
- try {
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(input));
- String factoryClassName = reader.readLine();
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.SET_SKIN_FACTORY_INFO,
- factoryClassName));
- }
- Class clazz = Class.forName(factoryClassName);
- try {
- // try construct factory chain.
- Constructor factoryConstructor = clazz
- .getConstructor(new Class[] { SkinFactory.class });
- instance = (SkinFactory) factoryConstructor
- .newInstance(new Object[] { instance });
- } catch (NoSuchMethodException e) {
- // no chain constructor - attempt default.
- instance = (SkinFactory) clazz.newInstance();
- }
- } catch (Exception e) {
- log
- .warn(
- Messages
- .getMessage(Messages.CREATING_SKIN_FACTORY_ERROR),
- e);
- } finally {
- try {
- input.close();
- } catch (IOException e) {
- // can be ignored
- }
-
- }
- }
- if (instance == null) {
- instance = new SkinFactoryImpl();
- }
- instances.put(loader, instance);
- }
-
- return instance;
- }
-
- /**
- * Get default {@link Skin} implementation.
- * @param context
- * @return
- */
- public abstract Skin getDefaultSkin(FacesContext context);
-
- /**
- * Get current {@link Skin} implementation.
- * @param context
- * @return
- */
- public abstract Skin getSkin(FacesContext context);
-
-// public abstract SkinConfiguration getSkinConfiguration(FacesContext context);
-
-
-
- /**
- * Get EL-enabled value. Return same string, if not el-expression.
- * Otherthise, return parsed and evaluated expression.
- *
- * @param context -
- * current Faces Context.
- * @param value -
- * string to parse.
- * @return - interpreted el or unmodified value.
- */
- protected static boolean isValueReference(String value) {
- if (value == null)
- return false;
-
- int start = value.indexOf("#{");
- if (start >= 0) {
- int end = value.lastIndexOf('}');
- if (end >= 0 && start < end) {
- return true;
- }
- }
- return false;
- }
- /**
- * Resource Uri for file with name of class for application-wide SkinFactory same as SPI
definitions for common Java SAX, Jsf etc. factories
- */
- public static final String SERVICE_RESOURCE = "META-INF/services/" +
SkinFactory.class.getName();
-
- /**
- * Name of web application init parameter for current skin . Can be simple
- * String for non-modified name, or EL-expression for calculate current
- * skin. If EL evaluated to <code>String</code> - used as skin name, if to
- * instance of {@link Skin } - used this instance. by default -
- * "org.exadel.chameleon.SKIN"
- */
- public static final String SKIN_PARAMETER = "org.ajax4jsf.SKIN";
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/skin/SkinNotFoundException.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,48 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.skin;
-
-import javax.faces.FacesException;
-
-public class SkinNotFoundException extends FacesException {
-
- public SkinNotFoundException() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- public SkinNotFoundException(String arg0) {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
-
- public SkinNotFoundException(Throwable arg0) {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
-
- public SkinNotFoundException(String arg0, Throwable arg1) {
- super(arg0, arg1);
- // TODO Auto-generated constructor stub
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScript.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScript.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScript.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.command;
-
-import org.ajax4jsf.framework.resource.ClientScript;
-
-public class CommandScript extends ClientScript {
-
-
- public String getJavaScript() {
- return "command.js";
- }
-
- protected boolean isUsePrototype() {
- return true;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScriptBuilder.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScriptBuilder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/command/CommandScriptBuilder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,162 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.command;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
-
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.resource.ClientScript;
-import org.ajax4jsf.framework.util.InputUtils;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.javascript.JSReference;
-import org.ajax4jsf.framework.util.javascript.ScriptString;
-/**
- * Utility class to build command links, buttons etc.
- * Introduces correct parameter escaping
- * @author Maksim Kaszynski
- *
- */
-public class CommandScriptBuilder {
- public static final ClientScript SCRIPT = new CommandScript();
-
- private static final ScriptString JSR_EVENT = new JSReference("(event ||
window.event)");
-
- private boolean checkActionAndListener = true;
- private StringBuffer codeAfter = new StringBuffer();
- private StringBuffer codeBefore = new StringBuffer();
- private UICommand component;
- private Map parameters;
- private String target;
- private boolean useOriginalOnclick = true;
-
- public CommandScriptBuilder(UICommand command) {
- this.component = command;
- collectParams();
- }
-
- public void addCodeAfter(String codeAfter) {
- this.codeAfter.append(codeAfter);
- }
-
- public void addCodeBefore(String codeBefore) {
- this.codeBefore.append(codeBefore);
- }
-
- public void addParameter(String name, Object value) {
- if (parameters == null) {
- parameters = new LinkedHashMap();
- }
- parameters.put(name, value);
- }
-
-
-
- private void addParameter(UIParameter parameter) {
- addParameter(parameter.getName(), parameter.getValue());
- }
-
- private void collectParams () {
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
- UIComponent kid = (UIComponent) iter.next();
- if (kid instanceof UIParameter) {
- addParameter((UIParameter) kid);
- }
- }
-
- }
-
- public StringBuffer getScript() {
- StringBuffer script = new StringBuffer();
-
- script.append(codeBefore).append(";");
-
- if (useOriginalOnclick) {
- Object onclick = component.getAttributes().get(HTML.onclick_ATTRIBUTE);
-
- if (onclick != null) {
- script.append(onclick).append(";");
- }
- }
-
-
- if (shouldGenerateAction()) {
- JSFunction function = new JSFunction("new A4J_Command");
- function.addParameter(JSR_EVENT);
- function.addParameter(parameters);
- function.addParameter(target);
-
- function.appendScript(script);
- script.append(";");
- }
-
-
- script.append(codeAfter).append(";");
-
- return script;
- }
-
- public String getTarget() {
- return target;
- }
-
- private boolean hasActionOrListenerSet() {
- return (component.getAction() != null) || (component.getActionListener() != null);
- }
-
- public boolean isCheckActionAndListener() {
- return checkActionAndListener;
- }
-
- public boolean isUseOriginalOnclick() {
- return useOriginalOnclick;
- }
-
- public void setCheckActionAndListener(boolean checkActionAndListener) {
- this.checkActionAndListener = checkActionAndListener;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- public void setUseOriginalOnclick(boolean useOriginalOnclick) {
- this.useOriginalOnclick = useOriginalOnclick;
- }
-
- private boolean shouldGenerateAction() {
-
- return (!InputUtils.isDisabled(component)) && (checkActionAndListener ?
hasActionOrListenerSet() : true);
-
- }
-
- public String toString() {
- return getScript().toString();
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,99 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public class AjaxSubmitFunction extends JSFunction {
-
- /**
- * Name Javasript function for submit AJAX request
- */
- public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
-
- /**
- * Attribute for keep clientId of status component
- */
- public static final String STATUS_ATTR_NAME = "status";
-
- /**
- * Attribute for keep JavaScript funtion name for call after complete
- * request.
- */
- public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
-
- /**
- * Attribute to keep
- */
- public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
-
- private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
-
- public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
-
- private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
-
- private UIComponent component;
-
- private Map options = new HashMap();
-
- private Map requestParameters = new HashMap();
-
- /**
- *
- */
- public AjaxSubmitFunction(UIComponent component) {
- this(component,AJAX_FUNCTION_NAME);
- }
- /**
- * @param name
- */
- public AjaxSubmitFunction(UIComponent component,String name) {
- super(name);
- this.component = component;
- // Fill parameters and options values.
- }
- /**
- * @return the options
- */
- public Map getOptions() {
- return this.options;
- }
- /**
- * @return the requestParameters
- */
- public Map getRequestParameters() {
- return this.requestParameters;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,119 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-/**
- * @author shura
- * Encode chars as JavaScript sequences
- */
-public class JSEncoder {
- private char APOSTROPHE[] = { '\\', '\'' };
-
- private static final char ENCODE_HEX[] = "0123456789ABCDEF".toCharArray();
-
- private static final char ENCODE_APOS[] = "\\'".toCharArray();
-
- private static final char ENCODE_QUOT[] = "\\\"".toCharArray();
-
- private static final char ENCODE_CR[] = "\\r".toCharArray();
-
- private static final char ENCODE_LF[] = "\\n".toCharArray();
-
- private static final char ENCODE_FF[] = "\\f".toCharArray();
-
- private static final char ENCODE_TAB[] = "\\t".toCharArray();
-
- private static final char ENCODE_BS[] = "\\\\".toCharArray();
-
- private static final char ENCODE_ESC[] = "\\e".toCharArray();
-
- /**
- * Create a new instance of this <code>XMLEncoder</code>.
- */
- public JSEncoder() {
- }
-
- /**
- * Return true or false wether this encoding can encode the specified
- * character or not.
- * <p>
- * This method will return true for the following character range: <br />
- * <code>
- * <nobr>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]</nobr>
- * </code>
- * </p>
- *
- * @see <a
href="http://www.w3.org/TR/REC-xml#charsets">W3C XML 1.0
</a>
- */
- public boolean compile(char c) {
-
- if ((c == 0x09) || // [\t]
- (c == 0x0a) || // [\n]
- (c == 0x0d) || // [\r](c == 0x22) || // ["]
- (c == 0x22) || // ["]
- (c == 0x27) || // [']
- (c == 0x5c) || // [\]
- (c == 0x03) || // [esc]
- (c == ']') || // ] - to avoid conflicts in CDATA
- (c < 0x20) || // See <
http://www.w3.org/TR/REC-xml#charsets>
- ((c > 0xd7ff) && (c < 0xe000)) || (c > 0xfffd)|| (c >
0xff)) {
- return (false);
- }
-
- return (true);
- }
-
- /**
- * Return an array of characters representing the encoding for the specified
- * character.
- */
- public char[] encode(char c) {
- switch (c) {
- case 0x03:
- return (ENCODE_FF); // (>) [>]
- case 0x09:
- return (ENCODE_TAB); // (>) [>]
- case 0x0a:
- return (ENCODE_LF); // (>) [>]
- case 0x0d:
- return (ENCODE_CR); // (>) [>]
- case 0x22:
- return (ENCODE_QUOT); // (") ["]
- case 0x27:
- return (ENCODE_APOS); // (') [']
- case 0x5c:
- return (ENCODE_BS); // (<) [<]
- default: {
- if (c > 0xff) {
- char ret[] = { '\\', 'u', ENCODE_HEX[c >> 0xc &
0xf],
- ENCODE_HEX[c >> 0x8 & 0xf], ENCODE_HEX[c >> 0x4
& 0xf],
- ENCODE_HEX[c & 0xf] };
- return (ret);
- }
- char ret[] = { '\\', 'x', ENCODE_HEX[c >> 0x4 &
0xf],
- ENCODE_HEX[c & 0xf] };
- return (ret);
- }
- }
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunction.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,104 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:26 $
- *
- */
-public class JSFunction extends ScriptStringBase implements ScriptString {
-
- private String name;
-
- private List parameters = null;
-
- /**
- * @param name
- */
- public JSFunction(String name) {
- // TODO Auto-generated constructor stub
- this.name = name;
- }
-
- /**
- * @param name
- * @param parameters
- */
- public JSFunction(String name, List parameters) {
- // TODO Auto-generated constructor stub
- this.name = name;
- this.parameters = parameters;
- }
-
- /**
- * @param name
- * @param parameters
- */
- public JSFunction(String name, Object parameter) {
- // TODO Auto-generated constructor stub
- this.name = name;
- this.parameters = new ArrayList(1);
- this.parameters.add(parameter);
- }
-
- public JSFunction addParameter(Object parameter) {
- getParameters().add(parameter);
- return this;
- }
-
- public void appendScript(StringBuffer functionString) {
- functionString.append(name).append('(');
- boolean first = true;
- List parameters = getParameters();
- if (null != parameters) {
- for (Iterator param = parameters.iterator(); param.hasNext();) {
- Object element = param.next();
- if (!first) {
- functionString.append(',');
- }
- if (null != element) {
- functionString.append(ScriptUtils.toScript(element));
- } else {
- functionString.append("null");
- }
- first = false;
- }
-
- }
- functionString.append(")");
- }
-
- /**
- * @return the parameters
- */
- public List getParameters() {
- if (this.parameters == null) {
- this.parameters = new ArrayList();
- }
- return this.parameters;
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSFunctionDefinition.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,112 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/24 13:22:31 $
- *
- */
-public class JSFunctionDefinition extends ScriptStringBase implements ScriptString
-{
-
-
-
- private List parameters = new ArrayList();
-
- private StringBuffer body = new StringBuffer();
-
- private String name ;
-
-
- public JSFunctionDefinition(){
- }
-
- public JSFunctionDefinition( List parameters)
- {
-
- this.parameters = parameters;
- }
-
- /**
- * @param body
- * @param parameters
- */
- public JSFunctionDefinition( Object parameter)
- {
- this.parameters.add(parameter);
- }
-
-
- public JSFunctionDefinition addParameter(Object parameter)
- {
- this.parameters.add(parameter);
- return this;
- }
-
- public JSFunctionDefinition addToBody(Object body)
- {
- this.body.append(body);
- return this;
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.components.renderkit.scriptutils.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer functionString)
- {
- functionString.append("function");
- if(null != name){
- functionString.append(" ").append(name);
- }
- functionString.append("(");
- boolean first = true;
- for (Iterator param = parameters.iterator(); param.hasNext();)
- {
- Object element = param.next();
- if(!first){
- functionString.append(',');
- }
- functionString.append(element.toString());
- first = false;
- }
- functionString.append("){").append(body).append("}");
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSMin.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,327 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * JSMin.java 2006-02-13
- *
- * Copyright (c) 2006 John Reilly (
www.inconspicuous.org)
- *
- * This work is a translation from C to Java of jsmin.c published by
- * Douglas Crockford. Permission is hereby granted to use the Java
- * version under the same conditions as the jsmin.c on which it is
- * based.
- *
- *
- *
- *
- * jsmin.c 2003-04-21
- *
- * Copyright (c) 2002 Douglas Crockford (
www.crockford.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package org.ajax4jsf.framework.util.javascript;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PushbackInputStream;
-
-
-
-
-public class JSMin {
- private static final int EOF = -1;
-
- private PushbackInputStream in;
- private OutputStream out;
-
- private int theA;
- private int theB;
-
- public JSMin(InputStream in, OutputStream out) {
- this.in = new PushbackInputStream(in);
- this.out = out;
- }
-
- /**
- * isAlphanum -- return true if the character is a letter, digit,
- * underscore, dollar sign, or non-ASCII character.
- */
- static boolean isAlphanum(int c) {
- return ( (c >= 'a' && c <= 'z') ||
- (c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'Z') ||
- c == '_' ||
- c == '$' ||
- c == '\\' ||
- c > 126);
- }
-
- /**
- * get -- return the next character from stdin. Watch out for lookahead. If
- * the character is a control character, translate it to a space or
- * linefeed.
- */
- int get() throws IOException {
- int c = in.read();
-
- if (c >= ' ' || c == '\n' || c == EOF) {
- return c;
- }
-
- if (c == '\r') {
- return '\n';
- }
-
- return ' ';
- }
-
-
-
- /**
- * Get the next character without getting it.
- */
- int peek() throws IOException {
- int lookaheadChar = in.read();
- in.unread(lookaheadChar);
- return lookaheadChar;
- }
-
- /**
- * next -- get the next character, excluding comments. peek() is used to see
- * if a '/' is followed by a '/' or '*'.
- */
- int next() throws IOException, UnterminatedCommentException {
- int c = get();
- if (c == '/') {
- switch (peek()) {
- case '/':
- for (;;) {
- c = get();
- if (c <= '\n') {
- return c;
- }
- }
-
- case '*':
- get();
- for (;;) {
- switch (get()) {
- case '*':
- if (peek() == '/') {
- get();
- return ' ';
- }
- break;
- case EOF:
- throw new UnterminatedCommentException();
- }
- }
-
- default:
- return c;
- }
-
- }
- return c;
- }
-
- /**
- * action -- do something! What you do is determined by the argument: 1
- * Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B.
- * (Delete A). 3 Get the next B. (Delete B). action treats a string as a
- * single character. Wow! action recognizes a regular expression if it is
- * preceded by ( or , or =.
- */
-
- void action(int d) throws IOException, UnterminatedRegExpLiteralException,
- UnterminatedCommentException, UnterminatedStringLiteralException {
- switch (d) {
- case 1:
- out.write(theA);
- case 2:
- theA = theB;
-
- if (theA == '\'' || theA == '"') {
- for (;;) {
- out.write(theA);
- theA = get();
- if (theA == theB) {
- break;
- }
- if (theA <= '\n') {
- throw new UnterminatedStringLiteralException();
- }
- if (theA == '\\') {
- out.write(theA);
- theA = get();
- }
- }
- }
-
- case 3:
- theB = next();
- if (theB == '/' && (theA == '(' || theA == ',' || theA
== '=')) {
- out.write(theA);
- out.write(theB);
- for (;;) {
- theA = get();
- if (theA == '/') {
- break;
- } else if (theA == '\\') {
- out.write(theA);
- theA = get();
- } else if (theA <= '\n') {
- throw new UnterminatedRegExpLiteralException();
- }
- out.write(theA);
- }
- theB = next();
- }
- }
- }
-
- /**
- * jsmin -- Copy the input to the output, deleting the characters which are
- * insignificant to JavaScript. Comments will be removed. Tabs will be
- * replaced with spaces. Carriage returns will be replaced with linefeeds.
- * Most spaces and linefeeds will be removed.
- */
- public void jsmin() throws IOException, UnterminatedRegExpLiteralException,
UnterminatedCommentException, UnterminatedStringLiteralException{
- theA = '\n';
- action(3);
- while (theA != EOF) {
- switch (theA) {
- case ' ':
- if (isAlphanum(theB)) {
- action(1);
- } else {
- action(2);
- }
- break;
- case '\n':
- switch (theB) {
- case '{':
- case '[':
- case '(':
- case '+':
- case '-':
- action(1);
- break;
- case ' ':
- action(3);
- break;
- default:
- if (isAlphanum(theB)) {
- action(1);
- } else {
- action(2);
- }
- }
- break;
- default:
- switch (theB) {
- case ' ':
- if (isAlphanum(theA)) {
- action(1);
- break;
- }
- action(3);
- break;
- case '\n':
- switch (theA) {
- case '}':
- case ']':
- case ')':
- case '+':
- case '-':
- case '"':
- case '\'':
- action(1);
- break;
- default:
- if (isAlphanum(theA)) {
- action(1);
- } else {
- action(3);
- }
- }
- break;
- default:
- action(1);
- break;
- }
- }
- }
- out.flush();
- }
-
- class UnterminatedCommentException extends Exception {
- }
-
- class UnterminatedStringLiteralException extends Exception {
- }
-
- class UnterminatedRegExpLiteralException extends Exception {
- }
-
- public static void main(String arg[]) {
- try {
- JSMin jsmin = new JSMin(new FileInputStream(arg[0]), System.out);
- jsmin.jsmin();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (ArrayIndexOutOfBoundsException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (UnterminatedRegExpLiteralException e) {
- e.printStackTrace();
- } catch (UnterminatedCommentException e) {
- e.printStackTrace();
- } catch (UnterminatedStringLiteralException e) {
- e.printStackTrace();
- }
- }
-
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSObject.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-import java.util.List;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:30 $
- *
- */
-public class JSObject extends JSFunction
-{
-
- /**
- * @param name
- */
- public JSObject(String name)
- {
- super(name);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param name
- * @param parameters
- */
- public JSObject(String name, List parameters)
- {
- super(name, parameters);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param name
- * @param parameter
- */
- public JSObject(String name, Object parameter)
- {
- super(name, parameter);
- // TODO Auto-generated constructor stub
- }
-
- public void appendScript(StringBuffer functionString)
- {
- functionString.append("new ");
- super.appendScript(functionString);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/JSReference.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-/**
- * Create reference to JavaScript variable with optional index.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:30 $
- *
- */
-public class JSReference extends ScriptStringBase {
-
- public static final JSReference THIS = new JSReference("this");
-
- public static final JSReference TRUE = new JSReference("true");
- public static final JSReference FALSE = new JSReference("false");
- public static final JSReference NULL = new JSReference("null");
-
- private String name;
- private Object index=null;
-
- /**
- * @param name
- */
- public JSReference(String name) {
- // TODO Auto-generated constructor stub
- this.name = name;
- }
-
- /**
- * @param name
- * @param index
- */
- public JSReference(String name, Object index) {
- // TODO Auto-generated constructor stub
- this.name = name;
- this.index = index;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.util.javascript.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer functionString) {
- functionString.append(name);
- if (null != index) {
- functionString.append("[").append(ScriptUtils.toScript(index)).append("]");
- }
-
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptString.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:32 $
- *
- */
-public interface ScriptString
-{
-
- /**
- * Return object content as JavaScript String.
- * @return
- */
- public abstract String toScript();
-
- /**
- * Append JavaScript code to @link StringBuffer
- * @param functionString
- */
- public void appendScript(StringBuffer functionString);
-}
\ No newline at end of file
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptStringBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/26 10:38:52 $
- *
- */
-public abstract class ScriptStringBase implements ScriptString
-{
-
-
-
-
-
- public String toScript()
- {
- StringBuffer functionString = new StringBuffer();
- appendScript(functionString);
- return functionString.toString();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return toScript();
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,156 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.util.javascript;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.FacesException;
-
-import org.apache.commons.beanutils.PropertyUtils;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/01/24 13:22:31 $
- *
- */
-public class ScriptUtils {
-
- /**
- * This is utility class, don't instantiate.
- */
- private ScriptUtils() {
-
- }
-
- /**
- * Convert any Java Object to JavaScript representation ( as possible ).
- * @param obj
- * @return
- */
- public static String toScript(Object obj) {
- if (null == obj) {
- return "null";
- } else if (obj instanceof ScriptString) {
- return ((ScriptString) obj).toScript();
- } else if (obj.getClass().isArray()) {
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (int i = 0; i < Array.getLength(obj); i++) {
- Object element = Array.get(obj, i);
- if (!first) {
- ret.append(',');
- }
- ret.append(toScript(element));
- first = false;
- }
- return ret.append("] ").toString();
- } else if (obj instanceof Collection) {
- // Collections put as JavaScript array.
- Collection collection = (Collection) obj;
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (Iterator iter = collection.iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(toScript(element));
- first = false;
- }
- return ret.append("] ").toString();
- } else if (obj instanceof Map) {
- // Maps put as JavaScript hash.
- Map map = (Map) obj;
-
- StringBuffer ret = new StringBuffer("{");
- boolean first = true;
- for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
- if (!first) {
- ret.append(',');
- }
- addEncodedString(ret, key);
- ret.append(":");
- ret.append(toScript(map.get(key)));
- first = false;
- }
- return ret.append("} ").toString();
- } else if (obj instanceof Number || obj instanceof Boolean) {
- // numbers and boolean put as-is, without conversion
- return obj.toString();
- } else if (obj instanceof String) {
- // all other put as encoded strings.
- StringBuffer ret = new StringBuffer();
- addEncodedString(ret, obj);
- return ret.toString();
- }
- // All other objects threaded as Java Beans.
- try {
- StringBuffer ret = new StringBuffer("{");
- PropertyDescriptor[] propertyDescriptors = PropertyUtils
- .getPropertyDescriptors(obj);
- boolean first = true;
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
- String key = propertyDescriptor.getName();
- if ("class".equals(key)) {
- continue;
- }
- if (!first) {
- ret.append(',');
- }
- addEncodedString(ret, key);
- ret.append(":");
- ret.append(toScript(PropertyUtils.getProperty(obj, key)));
- first = false;
- }
- return ret.append("} ").toString();
- } catch (Exception e) {
- throw new FacesException(
- "Error in conversion Java Object to JavaScript", e);
- }
- }
-
- public static void addEncodedString(StringBuffer buff, Object obj) {
- buff.append("'");
- addEncoded(buff, obj);
- buff.append("'");
-
- }
-
- public static void addEncoded(StringBuffer buff, Object obj) {
- JSEncoder encoder = new JSEncoder();
- char chars[] = obj.toString().toCharArray();
- for (int i = 0; i < chars.length; i++) {
- char c = chars[i];
- if (!encoder.compile(c)) {
- buff.append(encoder.encode(c));
- } else {
- buff.append(c);
- }
- }
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,115 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
-import javax.faces.component.html.HtmlCommandButton;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
- *
- */
-public abstract class AjaxCommandRendererBase extends AjaxComponentRendererBase {
-
- protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
-
- //super.decode must not be called, because value is handled here
- if ( isSubmitted(facesContext, uiComponent))
- {
- Map attributes = uiComponent.getAttributes();
- Object type = attributes.get("type");
- if (! "reset".equalsIgnoreCase((String)type) ) {
- ActionEvent event;
- event = new ActionEvent(uiComponent);
- uiComponent.queueEvent(event);
- }
- uiComponent.queueEvent( new AjaxEvent(uiComponent));
-//
org.ajax4jsf.framework.ajax.AjaxRegionListener.addRegionsFromComponent(uiComponent,
facesContext);
- }
- }
-
- public String getOnClick(FacesContext context, UIComponent component) {
- StringBuffer onClick;
- if ( !getUtils().isBooleanAttribute(component,"disabled")) {
- onClick = AjaxRendererUtils.buildOnClick(component, context);
- if (!"reset".equals(component.getAttributes().get("type"))) {
- onClick.append(";return false;");
- }
- } else {
- onClick = new StringBuffer("return false;");
- }
- return onClick.toString();
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- renderChildren(context, component);
- }
-
- public Object getValue(UIComponent uiComponent) {
- if (uiComponent instanceof ValueHolder) {
- return ((ValueHolder) uiComponent).getValue();
- }
- return uiComponent.getAttributes().get("value");
- }
-
- public String getType(UIComponent uiComponent) {
- String type;
- if (uiComponent instanceof HtmlCommandButton) {
- type = ((HtmlCommandButton) uiComponent).getType();
- } else {
- type = (String) uiComponent.getAttributes().get("type");
- }
- if (type == null) {
- type = "button";
- }
- return type;
- }
-
-
- protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
- // Componet accept only ajax requests.
- if ( !AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(facesContext)) {
- return false;
- }
- if(getUtils().isBooleanAttribute(uiComponent,"disabled")){
- return false;
- }
- String clientId = uiComponent.getClientId(facesContext);
- Map paramMap = facesContext.getExternalContext().getRequestParameterMap();
- Object value = paramMap.get( clientId );
- return null != value;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,92 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.UIAjaxFunction;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
-import org.ajax4jsf.framework.util.javascript.JSReference;
-import org.ajax4jsf.framework.util.javascript.ScriptUtils;
-
-/**
- * @author shura
- *
- */
-public class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getFunction(FacesContext context, UIAjaxFunction component) {
- StringBuffer script = new StringBuffer();
- JSFunctionDefinition func = new JSFunctionDefinition();
- func.setName(component.getName());
- // Create AJAX Submit function.
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
- component, context,AjaxRendererUtils.AJAX_FUNCTION_NAME);
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
- Map parameters = (Map) options.get("parameters");
- if (null == parameters) {
- parameters = new HashMap();
- options.put("parameters", parameters);
- }
- ajaxFunction.addParameter(JSReference.NULL);
- ajaxFunction.addParameter(options);
- // Fill parameters.
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- if (child instanceof UIParameter) {
- UIParameter parameter = ((UIParameter) child);
- String name = parameter.getName();
- func.addParameter(name);
- // Put parameter name to AJAX.Submit parameter, with default value.
- JSReference reference = new JSReference(name);
- if (null != parameter.getValue()) {
- reference = new JSReference(name + "||"
- + ScriptUtils.toScript(parameters.get(name)));
-
- }
- // Replace parameter value to reference.
- parameters.put(name, reference);
- }
- }
- func.addToBody(ajaxFunction.toScript());
- func.appendScript(script);
- return script.toString();
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,93 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import java.util.LinkedHashSet;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.UIResource;
-import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.resource.InternetResource;
-
-/**
- * @author shura
- *
- */
-public class LoadResourceRendererBase extends RendererBase implements
HeaderResourceProducer {
-
- private static final String
SCRIPT_COMPONENT_FAMILY="org.ajax4jsf.LoadScript";
- private static final String STYLE_COMPONENT_FAMILY="org.ajax4jsf.LoadStyle";
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
- UIResource resource = (UIResource) component;
- if (SCRIPT_COMPONENT_FAMILY.equals(resource.getFamily())) {
- return getResources(context, resource);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public LinkedHashSet getHeaderStyles(FacesContext context, UIComponent component) {
- UIResource resource = (UIResource) component;
- if (STYLE_COMPONENT_FAMILY.equals(resource.getFamily())) {
- return getResources(context, resource);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- return UIResource.class;
- }
-
- private LinkedHashSet getResources(FacesContext context, UIResource resource) {
- Object src = resource.getSrc();
- if(null == src){
- throw new FacesException("Source for resource is null for component
"+resource.getClientId(context));
- }
- LinkedHashSet set = new LinkedHashSet(1);
- String uri ;
- if(src instanceof InternetResource){
- uri=((InternetResource)src).getUri(context, resource);
- } else {
- // Process as ordinary url, same as for h:graphicsImage.
- uri=context.getApplication().getViewHandler().
- getResourceURL(context, src.toString());
- uri=context.getExternalContext().encodeResourceURL(uri);
- }
- set.add(uri);
- return set;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,382 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.html.HtmlForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.UIAjaxForm;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.resource.InternetResource;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.javascript.JSReference;
-
-/**
- * @author shura
- *
- */
-public class AjaxFormRenderer extends AjaxComponentRendererBase {
-
- public static final String FORM_SUBMIT_FUNCTION_NAME = "_JSFFormSubmit";
-
- public static final String FORM_CLEAR_FUNCTION_NAME =
"_clearJSFFormParameters";
-
- private static final String FORM_HAS_COMMAND_LINK_ATTR =
"com.sun.faces.FORM_HAS_COMMAND_LINK_ATTR";
-
- private static final String NO_COMMAND_LINK_FOUND_VALUE =
"com.sun.faces.NO_COMMAND_LINK_FOUND";
-
- public static final String CONTENT_TYPE_IS_XHTML = "com.sun.faces"
- + "ContentTypeIsXHTML";
-
- public static final String HIDDEN_FIELD_SUFFIX = NamingContainer.SEPARATOR_CHAR
- + UIViewRoot.UNIQUE_ID_PREFIX + "cl";
-
- private static final String HIDDEN_COMMAND_INPUTS_SET_ATTR = UIForm.class
- .getName()
- + ".org.apache.myfaces.HIDDEN_COMMAND_INPUTS_SET";
-
- private static final String MYFACES_HIDDEN_FIELD_SUFFIX =
NamingContainer.SEPARATOR_CHAR
- + "_link_hidden_";
-
- private InternetResource[] _scripts = { getResource("scripts/form.js") };
-
- private static final String[] exclusions = { "onsubmit" };
-
- public static final String AJAX_FORM_FUNCTION_NAME = "A4J.AJAX.SubmitForm";
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doDecode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- protected void doDecode(FacesContext context, UIComponent component) {
- UIForm form = (UIForm) component;
- boolean submitted = context.getExternalContext()
- .getRequestParameterMap().containsKey(
- component.getClientId(context));
- form.setSubmitted(submitted);
- if (component instanceof UIAjaxForm) {
- UIAjaxForm ajaxForm = (UIAjaxForm) component;
- if (submitted && ajaxForm.isAjaxSubmit()) {
- component.queueEvent(new AjaxEvent(component));
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase#getScripts()
- */
- protected InternetResource[] getAdditionalScripts() {
- // TODO Auto-generated method stub
- return _scripts;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
- String clientId = component.getClientId(context);
- writer.startElement(HTML.FORM_ELEMENT, component);
- writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
- getUtils().encodeAttribute(context, component, "style");
- getUtils().encodeAttribute(context, component, "class");
- getUtils().encodePassThru(context, component);
- context.getExternalContext().getRequestMap().put(
- FORM_HAS_COMMAND_LINK_ATTR, clientId);
- if (component instanceof UIAjaxForm) {
- UIAjaxForm form = (UIAjaxForm) component;
- if (form.isAjaxSubmit()) {
- StringBuffer onSubmit = new StringBuffer("javascript:");
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
- component, context,
- AJAX_FORM_FUNCTION_NAME);
- ajaxFunction.addParameter(AjaxRendererUtils.buildEventOptions(
- context, component));
- ajaxFunction.appendScript(onSubmit);
- writer.writeURIAttribute("action", onSubmit, "action");
- } else {
- encodeSubmitAction(writer, context);
- }
- } else {
- encodeSubmitAction(writer, context);
- }
- }
-
- /**
- * @param writer
- * @param context
- * @throws IOException
- */
- private void encodeSubmitAction(ResponseWriter writer, FacesContext context)
- throws IOException {
- String actionURL = getUtils().getActionUrl(context);
- String encodedActionURL = context.getExternalContext().encodeActionURL(
- actionURL);
- writer.writeURIAttribute("action", encodedActionURL, "action");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
- // Encode form submitting flag hidden field.
- String clientId = component.getClientId(context);
- renderHiddenInputField(writer, clientId, clientId);
- renderHiddenInputField(writer, "autoScroll", null);
- // MyFaces compability - render hidden field and Script.
- // render hidden command inputs
- Set hiddenFields = new HashSet();
- hiddenFields.add(clientId + HIDDEN_FIELD_SUFFIX);
- hiddenFields.add(clientId + MYFACES_HIDDEN_FIELD_SUFFIX);
- Set set = (Set) component.getAttributes().get(
- HIDDEN_COMMAND_INPUTS_SET_ATTR);
- if (set != null) {
- hiddenFields.addAll(set);
- }
- set = (Set) context.getExternalContext().getRequestMap().get(
- getHiddenCommandInputsSetName(context, component));
- if (set != null) {
- hiddenFields.addAll(set);
- }
- renderHiddenCommandFormParams(writer, hiddenFields);
- String target;
- if (component instanceof HtmlForm) {
- target = ((HtmlForm) component).getTarget();
- } else {
- target = (String) component.getAttributes().get(
- HTML.target_ATTRIBUTE);
- }
- renderClearHiddenCommandFormParamsFunction(writer, clientId, hiddenFields, target);
- // Script
- if (component instanceof UIAjaxForm) {
- UIAjaxForm form = (UIAjaxForm) component;
- if (form.isAjaxSubmit()) {
- renderAjaxFormSetupScript(writer, clientId);
- }
- }
- // writeFormSubmitScript(context, writer);
- getUtils().encodeEndForm(context, writer);
- context.getExternalContext().getRequestMap().put(
- FORM_HAS_COMMAND_LINK_ATTR, NO_COMMAND_LINK_FOUND_VALUE);
- }
-
- private static String getHiddenCommandInputsSetName(
- FacesContext facesContext, UIComponent form) {
- StringBuffer buf = new StringBuffer();
- buf.append(HIDDEN_COMMAND_INPUTS_SET_ATTR);
- buf.append("_");
- buf.append(form.getClientId(facesContext));
- return buf.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIForm.class;
- }
-
- // For MyFaces compability - create hidden firlds and script. Code got from
- // project to simulate same functionality.
- public void renderHiddenCommandFormParams(ResponseWriter writer,
- Set formParams) throws IOException {
- for (Iterator it = formParams.iterator(); it.hasNext();) {
- Object name = it.next();
- renderHiddenInputField(writer, name, "");
- }
- }
-
- public void renderHiddenInputField(ResponseWriter writer, Object name,
- Object value) throws IOException {
- writer.startElement(HTML.INPUT_ELEM, null);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, name, null);
- writer.writeAttribute(HTML.value_ATTRIBUTE, value != null?value:"", null);
- writer.endElement(HTML.INPUT_ELEM);
- }
-
-
- public void renderAjaxFormSetupScript(ResponseWriter writer, String formName) throws
IOException {
- writer.startElement(HTML.SCRIPT_ELEM, null);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- writer.writeText("A4J.setupForm('"+formName+"');", null);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
-
- /**
- * Render the javascript function that is called on a click on a commandLink
- * to clear the hidden inputs. This is necessary because on a browser back,
- * each hidden input still has it's old value (browser cache!) and therefore
- * a new submit would cause the according action once more!
- *
- * @param writer
- * @param formName
- * @param dummyFormParams
- * @param formTarget
- * @throws IOException
- */
- public void renderClearHiddenCommandFormParamsFunction(
- ResponseWriter writer, String formName, Set dummyFormParams,
- String formTarget) throws IOException {
- // render the clear hidden inputs javascript function
- String functionName = getClearHiddenCommandFormParamsFunctionName(formName);
- writer.startElement(HTML.SCRIPT_ELEM, null);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
-
- // Using writeComment instead of write with <!-- tag
- StringBuffer script = new StringBuffer();
- script.append("function ");
- script.append(functionName);
- script.append("() {\n");
- script.append(FORM_CLEAR_FUNCTION_NAME);
- script.append("('");
- script.append(formName);
- script.append("','");
- if (formTarget != null && formTarget.length() > 0) {
- script.append(formTarget);
- }
- script.append("'");
- if (dummyFormParams != null) {
- script.append(",[");
- for (Iterator it = dummyFormParams.iterator(); it.hasNext();) {
- script.append('\'');
- script.append((String) it.next());
- script.append('\'');
- if (it.hasNext()) {
- script.append(',');
- }
- }
- script.append("]");
- }
- script.append(");");
- script.append("\n}");
- script.append("\n");
- script.append("function
").append("clearFormHiddenParams_").append(
- getValidJavascriptName(formName));
- script.append("(){").append(functionName).append("();}\n");
- // MyFaces 1.1.5 clear form function name
- script.append("function
").append("clearFormHiddenParams_").append(
- formName.replace("-", "$_").replace(':', '_'));
- script.append("(){").append(functionName).append("();}\n");
- // Just to be sure we call this clear method on each load.
- // Otherwise in the case, that someone submits a form by pressing Enter
- // within a text input, the hidden inputs won't be cleared!
- script.append(functionName);
- script.append("();");
-
- writer.writeText(script.toString(), null);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
-
- /**
- * Prefixes the given String with "clear_" and removes special characters
- *
- * @param formName
- * @return String
- */
- public String getClearHiddenCommandFormParamsFunctionName(String formName) {
- return "clear_" + getValidJavascriptName(formName);
- }
-
- public String getValidJavascriptName(String s) {
-
- StringBuffer buf = null;
- for (int i = 0, len = s.length(); i < len; i++) {
- char c = s.charAt(i);
-
- if (Character.isLetterOrDigit(c)||c=='_' ) {
- // allowed char
- if (buf != null)
- buf.append(c);
- } else {
- if (buf == null) {
- buf = new StringBuffer(s.length() + 10);
- buf.append(s.substring(0, i));
- }
-
- buf.append('_');
- if (c < 16) {
- // pad single hex digit values with '0' on the left
- buf.append('0');
- }
-
- if (c < 128) {
- // first 128 chars match their byte representation in UTF-8
- buf.append(Integer.toHexString(c).toUpperCase());
- } else {
- byte[] bytes;
- try {
- bytes = Character.toString(c).getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
-
- for (int j = 0; j < bytes.length; j++) {
- int intVal = bytes[j];
- if (intVal < 0) {
- // intVal will be >= 128
- intVal = 256 + intVal;
- } else if (intVal < 16) {
- // pad single hex digit values with '0' on the left
- buf.append('0');
- }
- buf.append(Integer.toHexString(intVal).toUpperCase());
- }
- }
- }
-
- }
-
- return buf == null ? s : buf.toString();
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,97 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.UIInclude;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:25 $
- *
- */
-public class AjaxIncludeRenderer extends RendererBase {
-
- private final String[] STYLE_ATTRIBUTES = new String[] { "style",
"class" };
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIInclude.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
- UIInclude panel = (UIInclude) component;
- if (!UIInclude.LAYOUT_NONE.equals(panel.getLayout())) {
- writer.startElement(getTag(panel), panel);
- getUtils().encodeId(context, component);
- getUtils().encodePassThru(context, component);
- getUtils().encodeAttributesFromArray(context, component,
- STYLE_ATTRIBUTES);
-
- }
- }
-
- /**
- * @param panel
- * @return
- */
- private String getTag(UIInclude panel) {
- // TODO Auto-generated method stub
- return UIInclude.LAYOUT_BLOCK.equals(panel.getLayout()) ? HTML.DIV_ELEM
- : HTML.SPAN_ELEM;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
- UIInclude panel = (UIInclude) component;
- if (!UIInclude.LAYOUT_NONE.equals(panel.getLayout())) {
- writer.endElement(getTag(panel));
-
- }
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,148 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.UIAjaxOutputPanel;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:27 $
- *
- */
-public class AjaxOutputPanelRenderer extends RendererBase {
-
- private final String[] STYLE_ATTRIBUTES = new
String[]{"style","class"};
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- //
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if ("none".equals(panel.getLayout())) {
- if (component.getChildCount() > 0) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- boolean ajaxRequest = ajaxContext.isAjaxRequest();
- Set ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- String childId = child.getClientId(context);
- if (child.isRendered()) {
- renderChild(context, child);
- } else {
- // Render "dummy" span.
- ResponseWriter out = context.getResponseWriter();
- out.startElement(HTML.SPAN_ELEM,child);
- out.writeAttribute(HTML.id_ATTRIBUTE,childId,HTML.id_ATTRIBUTE);
- out.writeAttribute(HTML.style_ATTRIBUTE,"display:
none;","style");
- out.endElement(HTML.SPAN_ELEM);
- }
- // register child as rendered
- if(ajaxRequest && null != ajaxRenderedAreas) {
- ajaxRenderedAreas.add(childId);
- }
- }
- }
-
- } else {
- renderChildren(context,component);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
- public boolean getRendersChildren() {
- // TODO Auto-generated method stub
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIAjaxOutputPanel.class;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (!"none".equals(panel.getLayout())) {
- writer.startElement(getTag(panel), panel);
- getUtils().encodeId(context, component);
- getUtils().encodePassThru(context, component);
- getUtils().encodeAttributesFromArray(context,component,STYLE_ATTRIBUTES);
- }
- }
-
- /**
- * @param panel
- * @return
- */
- private String getTag(UIAjaxOutputPanel panel) {
- // TODO Auto-generated method stub
- return "block".equals(panel.getLayout())?HTML.DIV_ELEM:HTML.SPAN_ELEM;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (!"none".equals(panel.getLayout())) {
- writer.endElement(getTag(panel));
- }
- if (panel.isKeepTransient()) {
- markNoTransient(component);
- }
- }
-
- /**
- * Set "transient" flag to false for component and all its children (
recursive ).
- * @param component
- */
- private void markNoTransient(UIComponent component) {
- for (Iterator iter = component.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent element = (UIComponent) iter.next();
- markNoTransient(element);
- element.setTransient(false);
- }
-
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,228 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-
-/**
- * @author shura
- *
- * Render full Html page for AJAX view. Facet "head" rendered in
<head> of
- * page.
- */
-public class AjaxPageRenderer extends AjaxContainerRenderer {
-
- public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxPageRenderer";
-
- private static final Map doctypes ;
-
- static {
- // Fill doctype, content-type and namespace map for different formats.
- doctypes = new HashMap();
- doctypes
- .put(
- "html-transitional",
- new String[] {
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n",
- "text/html", null });
- doctypes.put("html", new String[] {
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n"
- + "\"http://www.w3.org/TR/html4/strict.dtd\">\n",
- "text/html", null });
- doctypes.put("html-frameset", new String[] {
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Frameset//EN\"\n"
- + "\"http://www.w3.org/TR/html4/frameset.dtd\">\n",
- "text/html", null });
- doctypes
- .put(
- "xhtml",
- new String[] {
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Strict//EN\"\n"
- +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n",
- "application/xhtml+xml",
- "http://www.w3.org/1999/xhtml" });
- doctypes
- .put(
- "xhtml-transitional",
- new String[] {
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"\n"
- +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n",
- "application/xhtml+xml",
- "http://www.w3.org/1999/xhtml" });
- doctypes
- .put(
- "xhtml-frameset",
- new String[] {
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Frameset//EN\"\n"
- +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n",
- "application/xhtml+xml",
- "http://www.w3.org/1999/xhtml" });
- doctypes.put("html-3.2", new String[] {
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2
Final//EN\">\n",
- "text/html", null });
- }
-
- // private PreparedTemplate pageStyles =
- //
HtmlCompiler.compileResource("com/exadel/vcp/renderers/templates/ajax/page-styles.xml");
- protected void preEncodeBegin(FacesContext context, UIComponent component)
- throws IOException {
- // Scripts must be encoded in component, not before html element
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void doEncodeBegin(ResponseWriter out, FacesContext context,
- UIComponent component) throws IOException {
- AjaxContainer ajax = (AjaxContainer) component;
- // ServletResponse response = (ServletResponse)
- // context.getExternalContext().getResponse();
- Map attributes = component.getAttributes();
- String format = (String) attributes.get("format");
- String contentType = null;
- String namespace = null;
- // String characterEncoding = out.getCharacterEncoding();
- if (null != format) {
- String[] docType = (String[]) doctypes.get(format);
- if (null != docType) {
- contentType = docType[1];
- namespace = docType[2];
- out.write(docType[0]);
- }
- }
- if (null == contentType) {
- contentType = (String) attributes.get("contentType");
- }
- if (null != contentType) {
- // response.setContentType(contentType /*+ ";charset=" +
- // characterEncoding*/);
- }
- // TODO - create "format" attribute and insert properly DOCTYPE
- // declaratiom
- out.startElement("html", component);
- if (null == namespace) {
- namespace = (String) attributes.get("namespace");
- }
- if (null != namespace) {
- out.writeAttribute("xmlns", namespace, "namespace");
- }
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- if (!AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
- out.startElement("head", component);
- // Out title - requied html element.
- Object title = attributes.get("pageTitle");
- String viewId = context.getViewRoot().getViewId();
- if (null == title) {
- title = viewId;// use viewId for empty title
- }
- out.startElement(HTML.title_ELEM, component);
- out.writeText(title, "pageTitle");
- out.endElement(HTML.title_ELEM);
- // Page base - set to current view action url.
- // String pageBase =
- // context.getApplication().getViewHandler().getActionURL(context,
- // viewId);
- // out.startElement("base", component);
- // out.writeURIAttribute("href", pageBase, "pageBase");
- // out.endElement("base");
- // pageStyles.encode(this, context, component);
- UIComponent headFacet = component.getFacet("head");
- if (headFacet != null) {
- // context.getExternalContext().log("Render head facet in AJAX
- // Page");
- renderChild(context, headFacet);
- }
- if (null != contentType) {
- out.startElement("meta", component);
- out.writeAttribute("http-equiv", "Content-Type", null);
- out.writeAttribute("content",
- contentType /* + ";charset=" + characterEncoding */,
- null);
- out.endElement("meta");
- }
- if ((null == context.getExternalContext().getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))) {
- // Filter not used - encode scripts and CSS before component.
- encodeResourcesArray(context, component, getScripts());
- encodeResourcesArray(context, component, getStyles());
- }
- out.endElement("head");
- }
- out.startElement("body", component);
- getUtils().encodePassThru(context, component);
- getUtils().encodeAttributesFromArray(context, component,
- HTML.PASS_THRU_STYLES);
- // TODO - special body attributes :
- getUtils().encodeAttribute(context, component, "onload");
- getUtils().encodeAttribute(context, component, "onunload");
- // onload, onunload
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void doEncodeEnd(ResponseWriter out, FacesContext context,
- UIComponent component) throws IOException {
- out.endElement("body");
- out.endElement("html");
- // DebugUtils.traceView("ViewRoot in AJAX Page encode end");
- }
-
- /*
- * (non-Javadoc) For ajax requests, ViewRoot render childrens directly.
- *
- * @see org.ajax4jsf.framework.renderer.AjaxContainerRenderer#getRendersChildren()
- */
- public boolean getRendersChildren() {
- FacesContext context = FacesContext.getCurrentInstance();
- if (AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
- // Ajax Request. Control all output.
- return true;
- }
- // For non Ajax request, view root not render children
- return false;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,100 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.UIPoll;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
-import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
-
-/**
- * @author shura
- *
- */
-public class AjaxPollRenderer extends AjaxCommandRendererBase {
-
-
-
- private static final String AJAX_POLL_FUNCTION = "A4J.AJAX.Poll";
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIPoll poll = (UIPoll) component;
- writer.startElement(HTML.SPAN_ELEM, component);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
- getUtils().encodeId(context, component);
- // polling script.
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- StringBuffer script = new StringBuffer("\n");
- if(poll.isEnabled()){
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_POLL_FUNCTION);
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
- Integer interval = new Integer(poll.getInterval());
- options.put("pollinterval", interval);
- options.put("pollId", component.getClientId(context));
- Object onsubmit = component.getAttributes().get("onsubmit");
- if (null != onsubmit) {
- JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
- onsubmitFunction.addToBody(onsubmit);
- options.put("onsubmit", onsubmitFunction);
- }
-
-// options.put("timeout", interval);
- function.addParameter(options);
- function.appendScript(script);
- } else {
- script.append("A4J.AJAX.StopPoll('").append(component.getClientId(context)).append("')");
- }
- script.append(";\n");
- writer.writeText(script.toString(),null);
- writer.endElement(HTML.SCRIPT_ELEM);
- writer.endElement(HTML.SPAN_ELEM);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // only poll component is allowed.
- return UIPoll.class;
- }
-
- protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
- boolean submitted = super.isSubmitted(facesContext, uiComponent);
- UIPoll poll = (UIPoll) uiComponent;
- poll.setSubmitted(submitted);
- return submitted;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,118 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.UIPush;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.javascript.JSReference;
-import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
-
-/**
- * @author shura
- *
- */
-public class AjaxPushRenderer extends AjaxCommandRendererBase {
-
- public static final String PUSH_INTERVAL_PARAMETER =
"A4J.AJAX.Push.INTERVAL";
-
- public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
-
- public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
-
- public static final int DEFAULT_PUSH_INTERVAL = 1000;
-
- public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
-
- private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIPush push = (UIPush) component;
- writer.startElement(HTML.SPAN_ELEM, component);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
- getUtils().encodeId(context, component);
- getUtils().encodeBeginFormIfNessesary(context, component);
- // pushing script.
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- StringBuffer script = new StringBuffer("\n");
- if(push.isEnabled()){
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_PUSH_FUNCTION);
- // Set dummy form id, if nessesary.
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
- options.put("dummyForm",
component.getClientId(context)+RendererUtils.DUMMY_FORM_ID);
- int interval = push.getInterval();
- if(interval == Integer.MIN_VALUE){
- String intervalInitParameter =
context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
- if(null != intervalInitParameter){
- interval = Integer.parseInt(intervalInitParameter);
- } else {
- interval = DEFAULT_PUSH_INTERVAL;
- }
- }
- options.put("pushinterval", new Integer(interval));
- options.put("pushId", push.getListenerId(context));
- String pushUrl = context.getExternalContext().getInitParameter(PUSH_URL_PARAMETER);
- if(null != pushUrl){
- options.put("pushUrl", pushUrl);
- }
- // options.put("timeout", interval);
- function.addParameter(options);
- function.appendScript(script);
- } else {
- script.append("A4J.AJAX.StopPush('").append(push.getListenerId(context)).append("')");
- }
- script.append(";\n");
- writer.writeText(script.toString(),null);
- writer.endElement(HTML.SCRIPT_ELEM);
- getUtils().encodeEndFormIfNessesary(context, component);
- writer.endElement(HTML.SPAN_ELEM);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // only push component is allowed.
- return UIPush.class;
- }
-
- protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
- boolean submitted = super.isSubmitted(facesContext, uiComponent);
- UIPush push = (UIPush) uiComponent;
- push.setSubmitted(submitted);
- return submitted;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:28 $
- *
- */
-public class AjaxRegionRenderer extends AjaxContainerRenderer {
-
- public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxRegionRenderer";
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
-// AjaxRendererUtils.encodeClientScript(context,component);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
-// if (((AjaxContainer) component).isAjaxRequest()) {
-// AjaxRendererUtils.encodeAreas(context,component);
-// }
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,167 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.UIAjaxStatus;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/19 11:17:10 $
- *
- * Render status component as two span's, one for start request,
- * one for complete.
- */
-public class AjaxStatusRenderer extends RendererBase
-{
- /**
- *
- */
- public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxStatusRenderer";
-
- /**
- *
- */
- public static final String START_STYLE = "display: none";
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException
- {
- // find form clientId for wich we render status.
- String statusId = component.getClientId(context);
- String tag = getTag(component);
- writer.startElement(tag, component);
- writer.writeAttribute(HTML.id_ATTRIBUTE, statusId , null);
- // render 2 span components for different states
- encodeSpan(writer, context, component,statusId, "start", tag);
- encodeSpan(writer, context, component,statusId, "stop", tag);
- writer.endElement(tag);
- }
-
- /**
- * Encode one span for start or stop status
- * @param context - current context
- * @param component - status component
- * @param state - name of state ( start or stop ) for span.
- * @param tag TODO
- * @throws IOException
- */
- protected void encodeSpan(ResponseWriter writer, FacesContext context, UIComponent
component, String id, String state, String tag) throws IOException {
- writer.startElement(tag, component);
- String spanId = id+"."+state;
- writer.writeAttribute(HTML.id_ATTRIBUTE, spanId , null);
- // Styles for concrete state.
- String style = getNamedAttribute(component, "Style", state);
- // for start state rendered style always disable display of status
- // ( since it will enabled by JavaScript on start request )
- if("start".equals(state)) {
- if(null == style) {
- style = START_STYLE;
- } else {
- style += "; "+START_STYLE;
- }
- }
-// HtmlRendererUtils.renderHTMLAttribute(writer, "style",
"style", style );
-// HtmlRendererUtils.renderHTMLAttribute(writer, "styleClass",
"styleClass", getNamedAttribute(component, "StyleClass", state));
- if (null != style) {
- writer.writeAttribute("style", style, null);
- }
- String styleClass = getNamedAttribute(component, "StyleClass", state);
- if(null != styleClass){
- writer.writeAttribute("class", styleClass, null);
- }
-// getUtils().encodeAttribute(context,component,"class");
- getUtils().encodePassThru(context , component);
- // render facet or text.
- UIComponent facet = component.getFacet(state);
- if(null != facet) {
- renderChild(context, facet);
- } else {
- String namedAttribute = getNamedAttribute(component, "Text",
state);
- if (null != namedAttribute) {
- writer.writeText(namedAttribute, "text");
- }
-// else {
-// throw new FacesException("Status component must have one of
'"+state+"' facet or '"+state+"Text' atribute");
-// }
- }
- writer.endElement(tag);
- // ENCODE onstart/onstop javaScript.
- Object eventHandler = component.getAttributes().get("on"+state);
- if(null != eventHandler){
- StringBuffer script = new StringBuffer("\n");
-
script.append("window.document.getElementById('").append(spanId).append("').on").append(state).append("=");
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addToBody(eventHandler).addToBody(";").appendScript(script);
- script.append(";\n");
- getUtils().writeScript(context, component, script);
- }
- }
-
- /**
- * @param component
- * @param name name of attribute for current state
- * @param state 'start' or 'stop' . all dublicated attributes foe
Ajax state
- * have same syntax : startStyle/stopStyle ...
- * @return value of attribute for name and state
- */
- protected String getNamedAttribute(UIComponent component, String name, String state)
- {
- String fullName = (new StringBuffer(state).append(name)).toString();
- return (String) component.getAttributes().get(fullName);
- }
-
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIAjaxStatus.class;
- }
-
- /**
- * @param status
- * @return
- */
- private String getTag(UIComponent status) {
- // TODO Auto-generated method stub
- return
"block".equals(status.getAttributes().get("layout"))?HTML.DIV_ELEM:HTML.SPAN_ELEM;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
- public boolean getRendersChildren() {
- // TODO Auto-generated method stub
- return true;
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,57 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-
-/**
- * Since <code>UIAjaxRegion</code> dont render itself ( only set apropriate
event to parent component )
- * only <code>decode()</code> method implemented.
- * In case of Ajax Request caused by event for a given component
- * send action event.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:24 $
- *
- */
-public class AjaxSupportRenderer extends AjaxCommandRendererBase
-{
- private static final Log log = LogFactory.getLog(AjaxSupportRenderer.class);
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
- public boolean getRendersChildren()
- {
-
- return false;
- }
-
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return org.ajax4jsf.ajax.UIAjaxSupport.class;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,212 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIParameter;
-import javax.faces.component.ValueHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * "Wrapped" standard {@link javax.faces.component.html.HtmlCommandLink}
renderer,
- * to avoid common problem - If no commandLink's exist in initial rendered page,
{@link javax.faces.component.html.HtmlForm} renderer
- * don't encode nessesary hidden fields for link and it's param. Our form-link
renderer can avoid this problem.
- * @author shura
- *
- */
-public class HtmlCommandLinkRenderer extends RendererBase {
-
- private static final Log _log = LogFactory.getLog(HtmlCommandLinkRenderer.class);
-
- private static final String[] LINK_EXCLUSIONS =
{"onclick","target","href"};
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doDecode(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- protected void doDecode(FacesContext context, UIComponent component) {
- UIForm form = getUtils().getNestingForm(context,component);
- if(null != form){
- String hiddenFieldId =
form.getClientId(context)+AjaxFormRenderer.HIDDEN_FIELD_SUFFIX;
- Object hiddenFieldValue;
- if(null !=
(hiddenFieldValue=context.getExternalContext().getRequestParameterMap().get(hiddenFieldId))){
- if(component.getClientId(context).equals(hiddenFieldValue)){
- // Link submitted !
- if(_log.isDebugEnabled()){
- _log.debug(Messages.getMessage(Messages.COMMAND_LINK_SUBMIT_INFO,
component.getClientId(context)));
- }
- ActionEvent actionEvent = new ActionEvent(component);
- component.queueEvent(actionEvent);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- if(isDisabled(context,component)){
- doEncodePassiveBegin(writer, context, component);
- } else {
- doEncodeActiveBegin(writer, context, component);
- }
- }
-
- protected void doEncodeActiveBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
- writer.startElement(HTML.a_ELEMENT,component);
- getUtils().encodeId(context,component);
- getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
- getUtils().encodePassThruWithExclusionsArray(context,component,LINK_EXCLUSIONS);
- writer.writeAttribute("href","#",null);
- UIForm form = getUtils().getNestingForm(context,component);
- String clientId = component.getClientId(context);
- if(null == form){
- if(_log.isWarnEnabled()){
- _log.warn(Messages.getMessage(Messages.COMMAND_LINK_NOT_IN_FORM_WARNING, clientId));
- }
- return;
- }
- // Encode onclick attribute.
- Object click = component.getAttributes().get("onclick");
- StringBuffer onclick = new StringBuffer(256);
- if(null != click){
- onclick.append(click).append(';');
- }
- JSFunction submit = new JSFunction(AjaxFormRenderer.FORM_SUBMIT_FUNCTION_NAME);
- submit.addParameter(clientId);
- submit.addParameter(form.getClientId(context));
- submit.addParameter(component.getAttributes().get("target"));
- Map parameters = new HashMap();
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
- Object child = iter.next();
- if (child instanceof UIParameter) {
- UIParameter param = (UIParameter) child;
- parameters.put(param.getName(),param.getValue());
- }
- }
- submit.addParameter(parameters);
- onclick.append("return ");
- submit.appendScript(onclick);
- writer.writeAttribute(HTML.onclick_ATTRIBUTE,onclick,"onclick");
- //
- encodeValue(writer,context,component);
- }
-
- protected void doEncodePassiveBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
- writer.startElement(HTML.SPAN_ELEM,component);
- getUtils().encodeId(context,component);
- getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
- getUtils().encodePassThru(context,component);
- encodeValue(writer,context,component);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- // TODO Auto-generated method stub
- renderChildren(context,component);
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- if(isDisabled(context,component)){
- doEncodePassiveEnd(writer, context, component);
- } else {
- doEncodeActiveEnd(writer, context, component);
- }
- }
-
- protected void doEncodeActiveEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
- writer.endElement(HTML.a_ELEMENT);
- }
-
- protected void doEncodePassiveEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
- writer.endElement(HTML.SPAN_ELEM);
- }
-
-/**
- * Check for disabled component
- * @param context
- * @param command
- * @return true if link is disabled.
- */
-private boolean isDisabled(FacesContext context, UIComponent command){
- if (command.getAttributes().get("disabled") != null) {
- if ((command.getAttributes().get("disabled")).equals(Boolean.TRUE)) {
- return true;
- }
- }
- return false;
-}
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UICommand.class;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
- public boolean getRendersChildren() {
- return true;
- }
-
- protected void encodeValue(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException{
- String valueString = null;
- if (component instanceof UICommand) {
- Object value = ((UICommand) component).getValue();
- if (value != null) {
- valueString = value.toString();
- }
- } else if (component instanceof ValueHolder) {
- Object value = ((ValueHolder) component).getValue();
- if (value != null) {
- valueString = getUtils().formatValue(context,component,value);
- }
- }
-
- if (null != valueString && valueString.length()>0) {
- writer.write(valueString);
- }
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,134 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.ajax.resource.UIMediaOutput;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.resource.InternetResource;
-import org.ajax4jsf.framework.resource.InternetResourceBuilder;
-import org.ajax4jsf.framework.util.message.Messages;
-
-/**
- * @author shura
- *
- */
-public class MediaOutputRenderer extends RendererBase {
-
- public static final String RENDERER_TYPE = "org.ajax4jsf.MMediaRenderer";
-
- /**
- * Associationd between element name and uri attributes
- */
- private static final Map uriAttributes;
-
- static {
- uriAttributes = new HashMap();
- uriAttributes.put("a","href");
- uriAttributes.put("img","src");
- uriAttributes.put("object","data");
- uriAttributes.put("link","href");
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIMediaOutput mmedia = (UIMediaOutput) component;
- String element = mmedia.getElement();
- if(null == element){
- throw new
FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
- }
- writer.endElement(element);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIMediaOutput.class;
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIMediaOutput mmedia = (UIMediaOutput) component;
- String element = mmedia.getElement();
- if(null == element){
- throw new
FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
- }
- String uriAttribute = mmedia.getUriAttribute();
- // Check for pre-defined attributes
- if(null == uriAttribute){
- uriAttribute = (String) uriAttributes.get(element);
- if(null == uriAttribute){
- throw new
FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"uriAttribute",component.getClientId(context)));
- }
- }
- writer.startElement(element,mmedia);
- getUtils().encodeId(context,component);
- InternetResourceBuilder internetResourceBuilder =
InternetResourceBuilder.getInstance();
- InternetResource resource =
internetResourceBuilder.createUserResource(mmedia.isCacheable(),mmedia.isSession(),mmedia.getMimeType());
- StringBuffer uri = new StringBuffer(resource.getUri(context,mmedia));
- // Append parameters to resource Uri
- boolean haveQestion = uri.indexOf("?")>=0;
- Iterator kids = component.getChildren().iterator();
- while (kids.hasNext()) {
- UIComponent kid = (UIComponent) kids.next();
-
- if (kid instanceof UIParameter) {
- UIParameter uiParam = (UIParameter) kid;
- String name = uiParam.getName();
- Object value = uiParam.getValue();
- if(null != value){
- if(haveQestion){
- uri.append('&');
- } else {
- uri.append('?');
- haveQestion = true;
- }
- uri.append(name).append('=').append(value.toString());
- }
- }
- }
- writer.writeURIAttribute(uriAttribute,uri,"uri");
- getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
- getUtils().encodePassThru(context,mmedia);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,81 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.io.IOException;
-import java.util.ListIterator;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.UIRepeat;
-import org.ajax4jsf.framework.renderer.RendererBase;
-
-/**
- * @author shura
- *
- */
-public class RepeatRenderer extends RendererBase {
-
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException {
- final UIRepeat repeater = (UIRepeat) component;
- repeater.captureOrigValue(context);
- try {
- DataVisitor visitor = new DataVisitor() {
-
- public void process(FacesContext context, Object rowKey, Object argument) throws
IOException {
- repeater.setRowKey(rowKey);
- ListIterator childIterator = repeater.getChildren()
- .listIterator();
- while (childIterator.hasNext()) {
- UIComponent child = (UIComponent) childIterator.next();
- renderChild(context, child);
- }
-
- }
-
- };
- repeater.walk(context, visitor, null);
-
- } finally {
- repeater.restoreOrigValue(context);
- repeater.setRowKey(null);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIRepeat.class;
- }
-
- public boolean getRendersChildren() {
- return true;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,178 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import javax.faces.application.Application;
-import javax.faces.component.ActionSource;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.ajax.UIActionParameter;
-import org.ajax4jsf.framework.util.message.Messages;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.LegacyValueBinding;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
- *
- */
-public class ActionParamHandler extends ComponentHandler {
-
- /**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
- *
- */
- public static class ActionParamMetaRule extends MetaRule {
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.tag.SuggestionHandler.SuggestionMetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
- */
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UIActionParameter.class)) {
- if ("assignTo".equals(name)) {
- return new AssignToValueBindingMetadata(attribute);
- } else if ("converter".equals(name)) {
- if (attribute.isLiteral()) {
- return new LiteralConverterMetadata(attribute.getValue());
- } else {
- return new DynamicConverterMetadata(attribute);
- }
-
- }
- }
-
- return null;
- }
-
-
- }
-
- final static class LiteralConverterMetadata extends Metadata {
-
- private final String converterId;
-
- public LiteralConverterMetadata(String converterId) {
- this.converterId = converterId;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIActionParameter) instance).setConverter(ctx.getFacesContext()
- .getApplication().createConverter(this.converterId));
- }
- }
-
- final static class DynamicConverterMetadata extends Metadata {
-
- private final TagAttribute attr;
-
- public DynamicConverterMetadata(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIActionParameter) instance).setConverter((Converter) this.attr
- .getObject(ctx, Converter.class));
- }
- }
-
- final static class AssignToValueBindingMetadata extends Metadata {
-
- private final TagAttribute attr;
-
- public AssignToValueBindingMetadata(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIActionParameter) instance).setAssignToBinding(
- new LegacyValueBinding(attr.getValueExpression(ctx,
- Object.class)));
- }
- }
-
-
- private TagAttribute _assignTo;
- private TagAttribute _converter;
-
- /**
- * @param config
- */
- public ActionParamHandler(ComponentConfig config) {
- super(config);
- _assignTo = getAttribute("assignTo");
- _converter = getAttribute("converter");
- if(null != _assignTo) {
- if (_assignTo.isLiteral()) {
- throw new TagAttributeException(this.tag, this._assignTo,
Messages.getMessage(Messages.MUST_BE_EXPRESSION_ERROR));
- }
-
- }
- // TODO Auto-generated constructor stub
- }
- /*
- * (non-Javadoc)
- *
- * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
- * javax.faces.component.UIComponent)
- */
- public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
{
- if (parent instanceof ActionSource)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Application application = facesContext.getApplication();
- if (_assignTo != null) {
- UIActionParameter al = (UIActionParameter)c;
- // TODO - in jsf 1.2 use ELValueExpression
-//
al.setAssignToBinding(application.createValueBinding(_assignTo.getValue()));
-// if (_converter != null) {
-// Converter converter =
application.createConverter(_converter.getValue(ctx));
-// al.setConverter(converter);
-// }
- ((ActionSource)parent).addActionListener(al);
- }
- }
- }
-
- private static final ActionParamMetaRule actionParamMetaRule = new
ActionParamMetaRule();
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
- */
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset metaRules = super.createMetaRuleset(type);
- metaRules.addRule(actionParamMetaRule);
- return metaRules;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,99 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import javax.faces.component.ActionSource;
-import javax.faces.event.ActionEvent;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.LegacyMethodBinding;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:21 $
- *
- */
-public class AjaxActionsRule extends MetaRule {
-
- public final static Class[] ACTION_SIG = new Class[0];
-
- public final static Class[] ACTION_LISTENER_SIG = new Class[] { ActionEvent.class };
-
- public final static class ActionMapper extends Metadata {
-
- private final TagAttribute attr;
-
- public ActionMapper(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((ActionSource) instance).setAction(new LegacyMethodBinding(
- this.attr.getMethodExpression(ctx, String.class,
- AjaxActionsRule.ACTION_SIG)));
- }
- }
-
- public final static class ActionListenerMapper extends Metadata {
-
- private final TagAttribute attr;
-
- public ActionListenerMapper(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((ActionSource) instance)
- .setActionListener(new LegacyMethodBinding(this.attr
- .getMethodExpression(ctx, null,
- AjaxActionsRule.ACTION_LISTENER_SIG)));
- }
-
- }
-
- public final static AjaxActionsRule instance = new AjaxActionsRule();
-
- public AjaxActionsRule() {
- super();
- }
-
- public Metadata applyRule(String name, TagAttribute attribute,
- MetadataTarget meta) {
- if (meta.isTargetInstanceOf(ActionSource.class)) {
-
-
- if ("action".equals(name)) {
- return new ActionMapper(attribute);
- }
-
- if ("actionListener".equals(name)) {
- return new ActionListenerMapper(attribute);
- }
- }
- return null;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import javax.faces.component.ActionSource;
-
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
- *
- */
-public class AjaxComponentHandler extends ComponentHandler {
-
- /**
- * @param config
- */
- public AjaxComponentHandler(ComponentConfig config) {
- super(config);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.jsf.ComponentHandler#createMetaRuleset(java.lang.Class)
- */
- protected MetaRuleset createMetaRuleset(Class type) {
- // TODO Auto-generated method stub
- MetaRuleset metaRules = super.createMetaRuleset(type);
- if (ActionSource.class.isAssignableFrom(type)) {
- metaRules.addRule(AjaxActionsRule.instance);
- }
- metaRules.addRule(AjaxReRendrRule.instance);
- return metaRules;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,119 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.IOException;
-
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.ajax.AjaxListenerHelper;
-import org.ajax4jsf.framework.ajax.AjaxSource;
-import org.ajax4jsf.framework.util.message.Messages;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.el.LegacyValueBinding;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagException;
-import com.sun.facelets.tag.TagHandler;
-
-/**
- * Register an ActionListener instance on the UIComponent associated with the
- * closest parent UIComponent custom action. <p/> See <a
target="_new"
- *
href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f...
- * documentation</a>.
- *
- * @see javax.faces.event.ActionListener
- * @see javax.faces.component.AjaxContainer
- * @author Jacob Hookom
- * @version $Id: AjaxListenerHandler.java,v 1.1.2.1 2007/02/01 15:31:23 alexsmirnov Exp
$
- */
-public final class AjaxListenerHandler extends TagHandler {
-
- private Class listenerType;
-
- private final TagAttribute type;
-
- private final TagAttribute binding;
-
- /**
- * @param config
- */
- public AjaxListenerHandler(TagConfig config) {
- super(config);
- this.binding = this.getAttribute("binding");
- this.type = this.getRequiredAttribute("type");
- if (type != null) {
- if (!type.isLiteral()) {
- throw new TagAttributeException(this.tag, this.type,
Messages.getMessage(Messages.MUST_BE_LITERAL_ERROR));
- }
- try {
- this.listenerType = Class.forName(type.getValue());
- } catch (Exception e) {
- throw new TagAttributeException(this.tag, this.type, e);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
- * javax.faces.component.UIComponent)
- */
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, FaceletException, ELException {
- if (parent instanceof AjaxSource) {
- // only process if parent was just created
- if (parent.getParent() == null) {
- AjaxSource src = (AjaxSource) parent;
- AjaxListener listener = null;
- ValueExpression ve = null;
- if (this.binding != null) {
- ve = this.binding.getValueExpression(ctx,
- AjaxListener.class);
- // TODO - handle both JSF 1.2/1.1 cases.
- listener = new AjaxListenerHelper(new LegacyValueBinding(ve));
- }
- if (listener == null) {
- try {
- listener = (AjaxListener) listenerType.newInstance();
- } catch (Exception e) {
- throw new TagAttributeException(this.tag, this.type,
e.getCause());
- }
- if (ve != null) {
- ve.setValue(ctx, ve);
- }
- }
- src.addAjaxListener(listener);
- }
- } else {
- throw new TagException(this.tag,
Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR, parent));
- }
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.util.Set;
-
-import org.ajax4jsf.framework.ajax.AjaxComponent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
-public class AjaxReRendrRule extends MetaRule {
-
- public static final AjaxReRendrRule instance = new AjaxReRendrRule();
- /**
- *
- */
- public AjaxReRendrRule() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
- */
- public Metadata applyRule(String name, TagAttribute attribute,
- MetadataTarget meta) {
- if (meta.isTargetInstanceOf(AjaxComponent.class)) {
- if ("reRender".equals(name)) {
- if (attribute.isLiteral()) {
- return new ReRendersSetMataData(attribute.getValue());
- } else {
- // Process as usual expression
- return null;
- }
- }
- }
- return null;
- }
-
- static class ReRendersSetMataData extends Metadata{
-
- private Set _reRender;
- /**
- * @param value
- */
- public ReRendersSetMataData(String value) {
- _reRender = AjaxRendererUtils.asSet(value);
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
java.lang.Object)
- */
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AjaxComponent) instance).setReRender(_reRender);
-
- }
-
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,97 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.IOException;
-
-import javax.el.ELException;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-
-import org.ajax4jsf.taglib.html.jsp.AjaxSupportTag;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-
-/**
- * "proxy" class for creating UIAjaxSupport component as facet for it's
parent.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
-public class AjaxSupportHandler extends TagHandler {
- /**
- * A UIComponent for capturing a child UIComponent, representative of the
- * desired Facet
- *
- * @author Jacob Hookom
- *
- */
- private final static class UIFacet extends UIComponentBase {
- public String getFamily() {
- return null;
- }
- }
-
- /**
- * Real tag handler for create component.
- */
- private TagHandler _ajaxSupportHandler;
-
- private TagAttribute _event;
- /**
- * @param config
- */
- public AjaxSupportHandler(ComponentConfig config) {
- super(config);
- _event = getRequiredAttribute("event");
- _ajaxSupportHandler = new AjaxComponentHandler(config);
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
- */
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, FaceletException, ELException {
- UIComponent c;
- // our id
-// String id = ctx.generateUniqueId(this.tagId);
- UIFacet facet = new UIFacet();
- // Find facet for support component
- String facetName = AjaxSupportTag.AJAX_SUPPORT_FACET+_event.getValue();
- c = parent.getFacet(facetName);
- if (null != c) {
- parent.getFacets().remove(facetName);
- facet.getChildren().add(c);
- }
- this._ajaxSupportHandler.apply(ctx, facet);
- c = (UIComponent) facet.getChildren().get(0);
- parent.getFacets().put(facetName, c);
- // Fix for possible incompabilites in different frameworks.
-// c.setParentProperties(parent);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,94 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.IOException;
-
-import javax.el.ELException;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-
-import org.ajax4jsf.framework.util.message.Messages;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagException;
-import com.sun.facelets.tag.TagHandler;
-
-/**
- * Register a named facet on the UIComponent associated with the closest parent
- * UIComponent custom action. <p/> See <a target="_new"
- *
href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f...
- * documentation</a>.
- *
- * @author Jacob Hookom
- * @version $Id: FacetHandler.java,v 1.1.2.1 2007/02/01 15:31:21 alexsmirnov Exp $
- */
-public final class FacetHandler extends TagHandler {
-
- /**
- * A UIComponent for capturing a child UIComponent, representative of the
- * desired Facet
- *
- * @author Jacob Hookom
- *
- */
- private final static class UIFacet extends UIComponentBase {
- public String getFamily() {
- return null;
- }
- }
-
- protected final TagAttribute name;
-
- public FacetHandler(TagConfig config) {
- super(config);
- this.name = this.getRequiredAttribute("name");
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
- */
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, FaceletException, ELException {
- UIFacet facet = new UIFacet();
- UIComponent c;
- // Check for existing facet
- String facetName = this.name.getValue(ctx);
- c = parent.getFacet(facetName);
- if (null != c) {
- parent.getFacets().remove(facetName);
- facet.getChildren().add(c);
- }
- this.nextHandler.apply(ctx, facet);
- int childCount = facet.getChildCount();
- if (childCount == 1) {
- c = (UIComponent) facet.getChildren().get(0);
- parent.getFacets().put(facetName, c);
- } else {
- throw new TagException(this.tag,
Messages.getMessage(Messages.FACET_TAG_MANY_CHILDREN_ERROR));
- }
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,274 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.el.ELException;
-import javax.el.ELResolver;
-import javax.el.ExpressionFactory;
-import javax.el.FunctionMapper;
-import javax.el.VariableMapper;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.TemplateClient;
-
-/**
- * @author shura
- *
- */
-public class IncludeFaceletContext extends FaceletContext {
-
- private FaceletContext defaultContext;
-
- private Map ids;
-
- /**
- * @param defaultContext
- */
- public IncludeFaceletContext(FaceletContext defaultContext) {
- this.defaultContext = defaultContext;
- this.ids = new HashMap();
- }
-
- /**
- * @param client
- * @see com.sun.facelets.FaceletContext#extendClient(com.sun.facelets.TemplateClient)
- */
- public void extendClient(TemplateClient client) {
- this.defaultContext.extendClient(client);
- }
-
- /**
- * @param base
- * @return
- * @see com.sun.facelets.FaceletContext#generateUniqueId(java.lang.String)
- */
- public String generateUniqueId(String base) {
- Integer cnt = (Integer) this.ids.get(base);
- if (cnt == null) {
- this.ids.put(base, new Integer(0));
- return base;
- } else {
- int i = cnt.intValue() + 1;
- this.ids.put(base, new Integer(i));
- return base + "_" + i;
- }
- }
-
- /**
- * @param name
- * @return
- * @see com.sun.facelets.FaceletContext#getAttribute(java.lang.String)
- */
- public Object getAttribute(String name) {
- return this.defaultContext.getAttribute(name);
- }
-
- /**
- * @param key
- * @return
- * @see javax.el.ELContext#getContext(java.lang.Class)
- */
- public Object getContext(Class key) {
- return this.defaultContext.getContext(key);
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getELResolver()
- */
- public ELResolver getELResolver() {
- return this.defaultContext.getELResolver();
- }
-
- /**
- * @return
- * @see com.sun.facelets.FaceletContext#getExpressionFactory()
- */
- public ExpressionFactory getExpressionFactory() {
- return this.defaultContext.getExpressionFactory();
- }
-
- /**
- * @return
- * @see com.sun.facelets.FaceletContext#getFacesContext()
- */
- public FacesContext getFacesContext() {
- return this.defaultContext.getFacesContext();
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getFunctionMapper()
- */
- public FunctionMapper getFunctionMapper() {
- return this.defaultContext.getFunctionMapper();
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getLocale()
- */
- public Locale getLocale() {
- return this.defaultContext.getLocale();
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getVariableMapper()
- */
- public VariableMapper getVariableMapper() {
- return this.defaultContext.getVariableMapper();
- }
-
- /**
- * @return
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return this.defaultContext.hashCode();
- }
-
- /**
- * @param parent
- * @param name
- * @return
- * @throws IOException
- * @throws FaceletException
- * @throws FacesException
- * @throws ELException
- * @see
com.sun.facelets.FaceletContext#includeDefinition(javax.faces.component.UIComponent,
java.lang.String)
- */
- public boolean includeDefinition(UIComponent parent, String name) throws IOException,
FaceletException, FacesException, ELException {
- return this.defaultContext.includeDefinition(parent, name);
- }
-
- /**
- * @param parent
- * @param relativePath
- * @throws IOException
- * @throws FaceletException
- * @throws FacesException
- * @throws ELException
- * @see
com.sun.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent,
java.lang.String)
- */
- public void includeFacelet(UIComponent parent, String relativePath) throws IOException,
FaceletException, FacesException, ELException {
- this.defaultContext.includeFacelet(parent, relativePath);
- }
-
- /**
- * @param parent
- * @param absolutePath
- * @throws IOException
- * @throws FaceletException
- * @throws FacesException
- * @throws ELException
- * @see
com.sun.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent,
java.net.URL)
- */
- public void includeFacelet(UIComponent parent, URL absolutePath) throws IOException,
FaceletException, FacesException, ELException {
- this.defaultContext.includeFacelet(parent, absolutePath);
- }
-
- /**
- * @return
- * @see javax.el.ELContext#isPropertyResolved()
- */
- public boolean isPropertyResolved() {
- return this.defaultContext.isPropertyResolved();
- }
-
- /**
- * @param client
- * @see com.sun.facelets.FaceletContext#popClient(com.sun.facelets.TemplateClient)
- */
- public void popClient(TemplateClient client) {
- this.defaultContext.popClient(client);
- }
-
- /**
- * @param client
- * @see com.sun.facelets.FaceletContext#pushClient(com.sun.facelets.TemplateClient)
- */
- public void pushClient(TemplateClient client) {
- this.defaultContext.pushClient(client);
- }
-
- /**
- * @param key
- * @param contextObject
- * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
- */
- public void putContext(Class key, Object contextObject) {
- this.defaultContext.putContext(key, contextObject);
- }
-
- /**
- * @param name
- * @param value
- * @see com.sun.facelets.FaceletContext#setAttribute(java.lang.String,
java.lang.Object)
- */
- public void setAttribute(String name, Object value) {
- this.defaultContext.setAttribute(name, value);
- }
-
- /**
- * @param fnMapper
- * @see com.sun.facelets.FaceletContext#setFunctionMapper(javax.el.FunctionMapper)
- */
- public void setFunctionMapper(FunctionMapper fnMapper) {
- this.defaultContext.setFunctionMapper(fnMapper);
- }
-
- /**
- * @param locale
- * @see javax.el.ELContext#setLocale(java.util.Locale)
- */
- public void setLocale(Locale locale) {
- this.defaultContext.setLocale(locale);
- }
-
- /**
- * @param resolved
- * @see javax.el.ELContext#setPropertyResolved(boolean)
- */
- public void setPropertyResolved(boolean resolved) {
- this.defaultContext.setPropertyResolved(resolved);
- }
-
- /**
- * @param varMapper
- * @see com.sun.facelets.FaceletContext#setVariableMapper(javax.el.VariableMapper)
- */
- public void setVariableMapper(VariableMapper varMapper) {
- this.defaultContext.setVariableMapper(varMapper);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,95 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.IOException;
-
-import javax.el.ELException;
-import javax.el.VariableMapper;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.servlet.jsp.JspException;
-
-import org.ajax4jsf.ajax.UIInclude;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.VariableMapperWrapper;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
-/**
- * @author shura
- *
- */
-public class IncludeHandler extends ComponentHandler {
-
- private TagAttribute viewId;
-
- public IncludeHandler(ComponentConfig config) {
- super(config);
- this.viewId = getRequiredAttribute("viewId");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
com.sun.facelets.tag.jsf.ComponentHandler#onComponentCreated(com.sun.facelets.FaceletContext,
- * javax.faces.component.UIComponent,
- * javax.faces.component.UIComponent)
- */
- protected void onComponentCreated(FaceletContext ctx, UIComponent c,
- UIComponent parent) {
- // TODO Auto-generated method stub
- super.onComponentCreated(ctx, c, parent);
- }
-
- protected void applyNextHandler(FaceletContext ctx, UIComponent component)
- throws IOException, FacesException, ELException {
- String path;
- if (component instanceof UIInclude) {
- UIInclude include = (UIInclude) component;
- path = include.getViewId();
- if(include.isWasNavigation()){
- component.getChildren().clear();
- }
- } else {
- path = (String) component.getAttributes().get("viewId");
- }
- VariableMapper orig = ctx.getVariableMapper();
- ctx.setVariableMapper(new VariableMapperWrapper(orig));
- try {
- this.nextHandler.apply(ctx, component);
- ctx.includeFacelet(component, path);
- } catch (Exception e) {
- throw new FacesException("UIInclude component "
- + component.getClientId(ctx.getFacesContext())
- + " could't include page with path " + path, e);
- } finally {
- ctx.setVariableMapper(orig);
- }
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.IOException;
-
-import javax.el.ELException;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
-import org.ajax4jsf.framework.util.message.Messages;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagHandler;
-
-/**
- * @author shura
- *
- */
-public class KeepAliveHandler extends TagHandler {
-
- private final TagAttribute beanName;
-
- private final TagAttribute ajaxOnly;
- /**
- * @param config
- */
- public KeepAliveHandler(TagConfig config) {
- super(config);
- this.beanName = this.getRequiredAttribute("beanName");
- if (beanName != null) {
- if (!beanName.isLiteral()) {
- throw new TagAttributeException(this.tag, this.beanName,
Messages.getMessage(Messages.MUST_BE_LITERAL_ERROR));
- }
- }
- this.ajaxOnly = getAttribute("ajaxOnly");
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
- */
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, FaceletException, ELException {
- // Get bean instance from EL expression.
- String name = beanName.getValue();
- boolean isAjaxOnly = ajaxOnly!=null?ajaxOnly.getBoolean(ctx):false;
- FacesContext facesContext = ctx.getFacesContext();
- String beanExpression = "#{"+name+"}";
- ValueBinding valueBinding =
facesContext.getApplication().createValueBinding(beanExpression);
- Object bean = valueBinding.getValue(facesContext);
- String beanAttributeName =
isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+name;
- // Put bean instance to ViewRoot.
- facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,121 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.OutputStream;
-
-import org.ajax4jsf.ajax.resource.UIMediaOutput;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.LegacyMethodBinding;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
-public class MediaOutputHandler extends ComponentHandler {
-
- private static final MetaRule mmediaMetaRule = new MMediaMetaRule();
- /**
- * @param config
- */
- public MediaOutputHandler(ComponentConfig config) {
- super(config);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
- */
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset metaRules = super.createMetaRuleset(type);
- metaRules.addRule(mmediaMetaRule);
- return metaRules;
- }
-
- /**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
- static class MMediaMetaRule extends MetaRule{
-
- /**
- *
- */
- public MMediaMetaRule() {
- super();
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
- */
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UIMediaOutput.class)) {
-
-
- if ("createContent".equals(name)) {
- return new MMediaActionMapper(attribute);
- }
- }
- return null;
- }
-
- }
- /**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
- static class MMediaActionMapper extends Metadata {
-
- private static final Class[] MMEDIA_ACTION_SIG = new Class[]
{OutputStream.class,Object.class};
-
- private final TagAttribute _send;
- /**
- * @param attribute
- */
- public MMediaActionMapper(TagAttribute attribute) {
- _send = attribute;
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
java.lang.Object)
- */
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIMediaOutput) instance)
- .setCreateContent(new LegacyMethodBinding(this._send
- .getMethodExpression(ctx, null,
- MMEDIA_ACTION_SIG)));
- }
-
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,146 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.application.Application;
-import javax.faces.component.ActionSource;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.webapp.UIComponentTag;
-
-import org.ajax4jsf.ajax.UIActionParameter;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
-import org.ajax4jsf.framework.util.message.Messages;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:31 $
- *
- */
-public class ActionParamTag extends UIComponentTagBase
-{
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType()
- {
- return "org.ajax4jsf.components.ActionParameter";
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType()
- {
- return null;
- }
- // UIComponent attributes --> already implemented in UIComponentTagBase
-
- // UIParameter attributes
- // value already implemented in UIComponentTagBase
- private String _name;
- private String _assignTo;
- private String _converter;
- private String _noEscape;
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setStringProperty(component, "name", _name);
- setBooleanProperty(component, "noEscape", _noEscape);
-
- //Find parent UIComponentTag
- UIComponentTag componentTag =
UIComponentTag.getParentUIComponentTag(pageContext);
- if (componentTag == null)
- {
- throw new
IllegalArgumentException(Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"ActionParameterTag"));
- }
-
- if (componentTag.getCreated())
- {
- //Component was just created, so we add the Listener
- UIComponent parentComponent = componentTag.getComponentInstance();
- if (parentComponent instanceof ActionSource)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Application application = facesContext.getApplication();
- if (_assignTo != null) {
- if (!UIComponentTag.isValueReference(_assignTo)) throw new
IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR_2,
_assignTo));
- UIActionParameter al = (UIActionParameter)component;
- al.setAssignToBinding(application.createValueBinding(_assignTo));
- if (_converter != null)
- {
- Converter converter = application.createConverter(_converter);
- al.setConverter(converter);
- }
- ((ActionSource)parentComponent).addActionListener(al);
- }
- }
- }
-
- }
-
- public void setName(String name)
- {
- _name = name;
- }
-
- /**
- * @param converter The converter to set.
- */
- public void setConverter(String converter)
- {
- this._converter = converter;
- }
-
- /**
- * @param noEscape The noEscape to set.
- */
- public void setNoEscape(String noEscape)
- {
- this._noEscape = noEscape;
- }
-
- /**
- * @param property The property to set.
- */
- public void setAssignTo(String property)
- {
- this._assignTo = property;
- }
-
- /* (non-Javadoc)
- * @see org.apache.myfaces.taglib.UIComponentTagBase#release()
- */
- public void release()
- {
- _name = null;
- _assignTo = null;
- _converter = null;
- _noEscape = null;
- super.release();
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import org.ajax4jsf.ajax.UIAjaxForm;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
-
-
-/**
- * Tag for creating Ajax version of HTML Form.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:32 $
- *
- */
-public class AjaxFormTag extends UIComponentTagBase
-{
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType()
- {
- // TODO Auto-generated method stub
- return UIAjaxForm.COMPONENT_TYPE;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType()
- {
- // TODO Auto-generated method stub
- return "javax.faces.Form";
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,127 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ReferenceSyntaxException;
-import javax.faces.el.ValueBinding;
-import javax.faces.webapp.UIComponentTag;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.Tag;
-import javax.servlet.jsp.tagext.TagSupport;
-
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.ajax.AjaxListenerHelper;
-import org.ajax4jsf.framework.ajax.AjaxSource;
-import org.ajax4jsf.framework.util.message.Messages;
-
-
-/**
- * @author shura
- *
- * Custom tag for append AJAX request listeners to AjaxContainer.
- *
- */
-public class AjaxListenerTag extends TagSupport {
-
- /**
- *
- */
- private static final long serialVersionUID = 2576519366310474212L;
- /**
- * class name for ajax events listener.
- */
- private String type = null;
-
- private String binding = null;
-
- /**
- *
- */
- public AjaxListenerTag() {
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * @param binding the binding to set
- */
- public void setBinding(String binding) {
- this.binding = binding;
- }
-
- public int doStartTag() throws JspException {
- if (type == null) {
- throw new
JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
- }
-
- //Find parent UIComponentTag
- UIComponentTag componentTag = UIComponentTag
- .getParentUIComponentTag(pageContext);
- if (componentTag == null) {
- throw new JspException(
- Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"AjaxListenerTag"));
- }
-
- if (componentTag.getCreated()) {
- //Component was just created, so we add the Listener
- UIComponent component = componentTag.getComponentInstance();
- if (component instanceof AjaxSource) {
- AjaxListener listener;
- if(null != binding){
- ValueBinding valueBinding;
- try {
- valueBinding =
FacesContext.getCurrentInstance().getApplication().createValueBinding(binding);
- } catch (ReferenceSyntaxException e) {
- throw new JspException(e);
- }
- listener = new AjaxListenerHelper(valueBinding);
- } else {
- String className;
- if (UIComponentTag.isValueReference(type)) {
- FacesContext facesContext = FacesContext
- .getCurrentInstance();
- ValueBinding valueBinding = facesContext.getApplication()
- .createValueBinding(type);
- className = (String) valueBinding.getValue(facesContext);
- } else {
- className = type;
- }
- try {
- listener = (AjaxListener) Class.forName(className).newInstance();
- } catch (Exception e) {
- throw new
JspException(Messages.getMessage(Messages.INSTANTIATE_LISTENER_ERROR, className,
component.getId()), e);
- }
- }
- ((AjaxSource) component).addAjaxListener(listener);
- } else {
- throw new
JspException(Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR,
component.getId()));
- }
- }
-
- return Tag.SKIP_BODY;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,87 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.renderkit.html.AjaxPageRenderer;
-
-
-/**
- * @author shura
- *
- * Other variant of AJAX View - render full html page with root <html>,
- * <head> ( filled from "head" facet ) and <body> areas.
- *
- */
-public class AjaxPageTag extends AjaxRegionTag {
-
- private String onload;
- private String onunload;
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType() {
- return AjaxPageRenderer.RENDERER_TYPE;
- }
- /* (non-Javadoc)
- * @see javax.servlet.jsp.tagext.Tag#release()
- */
- public void release() {
- this.onload = null;
- this.onunload = null;
- super.release();
- }
- /* (non-Javadoc)
- * @see
javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
- setStringProperty(component, "onload", this.onload);
- setStringProperty(component, "onunload", this.onunload);
- }
- /**
- * @return Returns the onload.
- */
- public String getOnload() {
- return onload;
- }
- /**
- * @return Returns the onunload.
- */
- public String getOnunload() {
- return onunload;
- }
- /**
- * @param onload The onload to set.
- */
- public void setOnload(String onload) {
- this.onload = onload;
- }
- /**
- * @param onunload The onunload to set.
- */
- public void setOnunload(String onunload) {
- this.onunload = onunload;
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,162 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.component.UIComponent;
-import javax.faces.el.MethodBinding;
-
-import org.ajax4jsf.ajax.UIAjaxRegion;
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.ajax4jsf.renderkit.html.AjaxRegionRenderer;
-
-
-/**
- * @author shura
- * Tag for create root Ajax component. must be immediate in produced html/body.
- * Example use in jsp:
- *
- * For produce correct html code in any ( ajax and non-ajax requests ),
- * better result with <ajax:page> tag.
- */
-public class AjaxRegionTag extends UIComponentTagBase {
-
- private String ajaxListener = null;
-
- private String reRender = null;
-
- private String immediate = null;
-
- private String selfRendered = null;
-
- private String javascriptLocation = null;
-
- /**
- *
- */
- public AjaxRegionTag() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType() {
- return UIAjaxRegion.COMPONENT_TYPE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType() {
- return AjaxRegionRenderer.RENDERER_TYPE;
- }
-
- // set component properties
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.jsp.tagext.Tag#release()
- */
- public void release() {
- // release reources properties
- super.release();
- this.reRender = null;
- this.ajaxListener = null;
- this.immediate = null;
- this.selfRendered = null;
- this.javascriptLocation = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
- setBooleanProperty(component, "immediate", this.immediate);
- setStringProperty(component, "ajaxAreas", this.reRender);
- setBooleanProperty(component,"selfRendered",this.selfRendered);
- setStringProperty(component, "javascriptLocation",
this.javascriptLocation);
- if (ajaxListener != null) {
- if (!(component instanceof AjaxContainer)) {
- throw new
IllegalArgumentException(Messages.getMessage(Messages.NOT_AJAX_CONTAINER_ERROR,
component.getClientId(getFacesContext())));
- }
- if (isValueReference(ajaxListener)) {
- MethodBinding mb = getFacesContext().getApplication()
- .createMethodBinding(ajaxListener,
- AjaxListener.AJAX_LISTENER_ARGS);
- ((AjaxContainer) component).setAjaxListener(mb);
- } else {
-
getFacesContext().getExternalContext().log(Messages.getMessage(Messages.INVALID_EXPRESSION,
ajaxListener));
- }
-
- }
- }
-
- /**
- * @param ajaxAreas
- * The ajaxAreas to set.
- */
- public void setReRender(String ajaxAreas) {
- this.reRender = ajaxAreas;
- }
-
- /**
- * @param ajaxListener
- * The ajaxListener to set.
- */
- public void setAjaxListener(String ajaxListener) {
- this.ajaxListener = ajaxListener;
- }
-
- /**
- * @param immediate
- * The immediate to set.
- */
- public void setImmediate(String immediate) {
- this.immediate = immediate;
- }
-
- /**
- * @param selfRendered The selfRendered to set.
- */
- public void setSelfRendered(String selfRendered) {
- this.selfRendered = selfRendered;
- }
-
-// public String getJavascriptLocation() {
-// return javascriptLocation;
-// }
-//
- public void setJavascriptLocation(String javascriptLocation) {
- this.javascriptLocation = javascriptLocation;
- }
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,189 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.ajax.UIAjaxStatus;
-import org.ajax4jsf.framework.taglib.HtmlComponentTagBase;
-import org.ajax4jsf.renderkit.html.AjaxStatusRenderer;
-
-
-/**
- *
- * Jsp Tag for create request state component.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:30 $
- *
- */
-public class AjaxStatusTag extends HtmlComponentTagBase
-{
-
- private String _for = null;
- /**
- * Text to output on start request
- */
- private String _startText = null;
- /**
- * Text to display on complete request
- */
- private String _stopText = null;
-
- /**
- * Style for display on start request
- */
- private String _startStyle = null;
- /**
- * Style for displaying on complete
- */
- private String _stopStyle = null;
- /**
- * Style class for display on request
- */
- private String _startStyleClass = null;
- /**
- * Style class for display on complete request
- */
- private String _stopStyleClass = null;
-
- /**
- * Force id to render in Html as is
- */
- private String _forceId = null;
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType()
- {
- // TODO Auto-generated method stub
- return UIAjaxStatus.COMPONENT_TYPE;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType()
- {
- // TODO Auto-generated method stub
- return AjaxStatusRenderer.RENDERER_TYPE;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlComponentTagBase#release()
- */
- public void release()
- {
- super.release();
- this._for = null;
- this._startStyle = null;
- this._startStyleClass = null;
- this._startText = null;
- this._stopStyle = null;
- this._stopStyleClass = null;
- this._stopText = null;
- this._forceId = null;
-
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.components.taglib.html.HtmlComponentTagBase#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setStringProperty(component, "for", _for);
- setStringProperty(component, "startText", _startText);
- setStringProperty(component, "stopText", _stopText);
- setStringProperty(component, "startStyle", _startStyle);
- setStringProperty(component, "stopStyle", _stopStyle);
- setStringProperty(component, "startStyleClass", _startStyleClass);
- setStringProperty(component, "stopStyleClass", _stopStyleClass);
- setBooleanProperty(component, "forceId", _forceId);
-
- }
-
-
- /**
- * @param _for The _for to set.
- */
- public void setFor(String _for)
- {
- this._for = _for;
- }
-
- /**
- * @param style The _startStyle to set.
- */
- public void setStartStyle(String style)
- {
- _startStyle = style;
- }
-
- /**
- * @param styleClass The _startStyleClass to set.
- */
- public void setStartStyleClass(String styleClass)
- {
- _startStyleClass = styleClass;
- }
-
- /**
- * @param text The _startText to set.
- */
- public void setStartText(String text)
- {
- _startText = text;
- }
-
- /**
- * @param stopText The stopText to set.
- */
- public void setStopText(String stopText)
- {
- this._stopText = stopText;
- }
-
- /**
- * @param style The _stopStyle to set.
- */
- public void setStopStyle(String style)
- {
- _stopStyle = style;
- }
-
- /**
- * @param styleClass The _stopStyleClass to set.
- */
- public void setStopStyleClass(String styleClass)
- {
- _stopStyleClass = styleClass;
- }
-
- /**
- * @param forceId The forceId to set.
- */
- public void setForceId(String forceId)
- {
- this._forceId = forceId;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,283 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.component.UIComponent;
-import javax.faces.webapp.UIComponentTag;
-
-import org.ajax4jsf.ajax.UIAjaxSupport;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
-import org.ajax4jsf.framework.util.message.Messages;
-
-
-/**
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:32 $
- *
- */
-public class AjaxSupportTag extends UIComponentTagBase {
-
- static final String[] EVENT_HANDLER_ATTRIBUTES =
- {
- HTML.ondblclick_ATTRIBUTE,
- HTML.onmousedown_ATTRIBUTE,
- HTML.onmouseup_ATTRIBUTE,
- HTML.onmouseover_ATTRIBUTE,
- HTML.onmousemove_ATTRIBUTE,
- HTML.onmouseout_ATTRIBUTE,
- HTML.onkeypress_ATTRIBUTE,
- HTML.onkeydown_ATTRIBUTE,
- HTML.onkeyup_ATTRIBUTE,
- HTML.onclick_ATTRIBUTE,
- HTML.onchange_ATTRIBUTE,
- HTML.onblur_ATTRIBUTE,
- HTML.onfocus_ATTRIBUTE,
- HTML.onselect_ATTRIBUTE
- };
-
- public static final String AJAX_SUPPORT_FACET = "org.ajax4jsf.ajax.SUPPORT";
- /**
- * Id ( in form of findComponent method param ) of JSF component,
- * updated by this component ( parnt tag ) action.
- */
- private String reRender = null;
-
- /**
- * Generate script for given event ( onclick, onenter ... )
- */
- private String event = null;
-
-
- /**
- * Id of request status component.
- */
- private String status = null;
-
- /**
- * JavaScript function for call after request completed.
- */
- private String oncomplete = null ;
-
- private String action = null;
- private String actionListener = null;
- private String limitToList = null;
- private String disableDefault = null;
- private String value = null;
- private String immediate = null;
- private String ajaxSingle = null;
-
-
-
-
- /**
- * @param type The type to set.
- */
- public void setDisableDefault(String ajaxType)
- {
- this.disableDefault = ajaxType;
- }
-
- /**
- * @param reRender
- * The targetId to set.
- */
- public void setReRender(String ajaxId) {
- this.reRender = ajaxId;
- }
-
-
- /**
- * @param event The event to set.
- */
- public void setEvent(String event)
- {
- this.event = event;
- }
-
- /**
- * @param oncomplete The oncomplete to set.
- */
- public void setOncomplete(String oncomplete)
- {
- this.oncomplete = oncomplete;
- }
-
- /**
- * @param status The status to set.
- */
- public void setStatus(String status)
- {
- this.status = status;
- }
-
- /**
- * @param limitToList The submitForm to set.
- */
- public void setLimitToList(String limitToList)
- {
- this.limitToList = limitToList;
- }
-
- /**
- * @param action The action to set.
- */
- public void setAction(String action)
- {
- this.action = action;
- }
-
- /**
- * @param actionListener The actionListener to set.
- */
- public void setActionListener(String actionListener)
- {
- this.actionListener = actionListener;
- }
-
- protected void setParentProperties(UIAjaxSupport uiComponent) {
-
- //Find parent UIComponentTag
- UIComponentTag componentTag = null;
- try {
- componentTag = UIComponentTag.getParentUIComponentTag(pageContext);
- if (componentTag == null) {
- throw new IllegalArgumentException(
- Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"AjaxSupportTag"));
- }
-
- if (componentTag.getCreated()) {
- //Component was just created, so we add the Listener
- UIComponent component = componentTag.getComponentInstance();
- uiComponent.setParentProperties(component);
- }
- } catch (ClassCastException e) {
- // JSF 1.2 - tags have other parent.
- }
-
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.jsp.tagext.Tag#release()
- */
- public void release() {
- this.reRender = null;
- this.oncomplete = null;
- this.event = null;
- this.status =null;
- this.action = null;
- this.actionListener = null;
- this.limitToList = null;
- this.disableDefault = null;
- this.value = null;
- this.immediate=null;
- this.ajaxSingle = null;
- super.release();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType()
- {
-
- return UIAjaxSupport.COMPONENT_TYPE;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType()
- {
-
- return UIAjaxSupport.DEFAULT_RENDERER_TYPE;
- }
-
- /**
- * @param value The value to set.
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * @param immediate The immediate to set.
- */
- public void setImmediate(String immediate) {
- this.immediate = immediate;
- }
-
- /**
- * @param ajaxSingle The ajaxSingle to set.
- */
- public void setAjaxSingle(String ajaxSingle) {
- this.ajaxSingle = ajaxSingle;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.components.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setStringProperty(component, "event", event);
- setReRenderProperty(component);
- setStringProperty(component, "status", status);
- setStringProperty(component, "oncomplete", oncomplete);
- setBooleanProperty(component, "disableDefault", disableDefault );
- setBooleanProperty(component, "limitToList", limitToList);
- setActionProperty(component, action);
- setActionListenerProperty(component, actionListener);
- setValueProperty(component,value);
- setBooleanProperty(component,"immediate",immediate);
- setBooleanProperty(component,"ajaxSingle",ajaxSingle);
-
- setParentProperties((UIAjaxSupport) component);
- }
-
- private void setReRenderProperty(UIComponent component) {
- if (reRender != null) {
- if (isValueReference(reRender)) {
- setStringProperty(component, "reRender", reRender);
- } else {
- ((UIAjaxSupport) component).setReRender(
AjaxRendererUtils.asSet(reRender));
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getFacetName()
- */
- protected String getFacetName() {
- // TODO Auto-generated method stub
- if (null != event) {
- return AJAX_SUPPORT_FACET + event;
- } else {
- return AJAX_SUPPORT_FACET;
- }
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,243 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.JspWriter;
-
-import org.ajax4jsf.ajax.UIInclude;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
-import org.ajax4jsf.framework.taglib.UIComponentTagBase;
-
-/**
- * @author shura
- *
- */
-public class IncludeTag extends UIComponentTagBase {
-
- /**
- * @author shura
- *
- */
- private static final class NullJspWriter extends JspWriter {
-
-
- /**
- * @param arg0
- * @param arg1
- */
- private NullJspWriter() {
- super(1024, false);
- }
-
- public void clear() throws IOException {
- }
-
- public void clearBuffer() throws IOException {
- }
-
- public void close() throws IOException {
- }
-
- public void flush() throws IOException {
- }
-
- public int getRemaining() {
- return 0;
- }
-
- public void newLine() throws IOException {
- }
-
- public void print(boolean arg0) throws IOException {
- }
-
- public void print(char arg0) throws IOException {
- }
-
- public void print(int arg0) throws IOException {
- }
-
- public void print(long arg0) throws IOException {
- }
-
- public void print(float arg0) throws IOException {
- }
-
- public void print(double arg0) throws IOException {
- }
-
- public void print(char[] arg0) throws IOException {
- }
-
- public void print(String arg0) throws IOException {
- }
-
- public void print(Object arg0) throws IOException {
- }
-
- public void println() throws IOException {
- }
-
- public void println(boolean arg0) throws IOException {
- }
-
- public void println(char arg0) throws IOException {
- }
-
- public void println(int arg0) throws IOException {
- }
-
- public void println(long arg0) throws IOException {
- }
-
- public void println(float arg0) throws IOException {
- }
-
- public void println(double arg0) throws IOException {
- }
-
- public void println(char[] arg0) throws IOException {
- }
-
- public void println(String arg0) throws IOException {
- }
-
- public void println(Object arg0) throws IOException {
- }
-
- public void write(char[] cbuf, int off, int len) throws IOException {
- }
- }
-
- private String viewId;
-
- /**
- * @param viewId
- * the viewId to set
- */
- public void setViewId(String viewId) {
- this.viewId = viewId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.taglib.UIComponentTagBase#release()
- */
- public void release() {
- super.release();
- viewId = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
- setStringProperty(component, "viewId", viewId);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.webapp.UIComponentTag#doEndTag()
- */
- public int doEndTag() throws JspException {
- int i = super.doEndTag();
- return i;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.webapp.UIComponentTag#doStartTag()
- */
- public int doStartTag() throws JspException {
- int i = super.doStartTag();
- String resourcePath;
- UIComponent component = getComponentInstance();
- UIInclude includeComponent = null;
- if (component instanceof UIInclude) {
- includeComponent = (UIInclude) component;
- resourcePath = includeComponent.getViewId();
- if(includeComponent.isWasNavigation()){
- component.getChildren().clear();
- }
- } else {
- resourcePath = (String) component.getAttributes().get("viewId");
- }
- JspWriter out;
- if (component.isRendered()) {
- out = this.pageContext.getOut();
- } else {
- // All content of response will be skip.
- out = new NullJspWriter();
- }
- ServletRequest request = this.pageContext.getRequest();
- ServletResponse response = this.pageContext.getResponse();
- RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
- FacesContext facesContext = getFacesContext();
- if(null == rd){
- throw new JspException("UIInclude component
"+component.getClientId(facesContext)+ " could't include page with path
"+resourcePath);
- }
- try {
- ServletResponseWrapperInclude responseWrapper = new ServletResponseWrapperInclude(
- response, out);
- rd.include(request, responseWrapper);
- // Write buffered data, if any;
- responseWrapper.flushBuffer();
- } catch (Exception e) {
- throw new JspException(e);
- }
- return i;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType() {
- return UIInclude.COMPONENT_TYPE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType() {
- return null;
- }
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,122 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.webapp.UIComponentTag;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.Tag;
-import javax.servlet.jsp.tagext.TagSupport;
-
-import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
-import org.ajax4jsf.framework.util.message.Messages;
-
-/**
- * @author shura
- *
- */
-public class KeepAliveTag extends TagSupport {
-
- /**
- *
- */
- private static final long serialVersionUID = 4322021112358067548L;
-
- private String beanName = null;
-
- private String ajaxOnly = null;
-
- /**
- * @return the ajaxOnly
- */
- public String getAjaxOnly() {
- return ajaxOnly;
- }
-
- /**
- * @param ajaxOnly the ajaxOnly to set
- */
- public void setAjaxOnly(String ajaxOnly) {
- this.ajaxOnly = ajaxOnly;
- }
-
- /**
- * @return the name
- */
- public String getBeanName() {
- return beanName;
- }
-
- /**
- * @param name the name to set
- */
- public void setBeanName(String name) {
- this.beanName = name;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
- */
- public int doStartTag() throws JspException {
- if (beanName == null) {
- throw new
JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
- }
- if(UIComponentTag.isValueReference(beanName)){
- throw new JspException(Messages.getMessage(Messages.NAME_MUST_BE_LITERAL));
- }
- boolean isAjaxOnly = false;
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (null != ajaxOnly) {
- if (UIComponentTag.isValueReference(ajaxOnly))
- {
- ValueBinding vb =
facesContext.getApplication().createValueBinding(ajaxOnly);
- isAjaxOnly = Boolean.TRUE.equals(vb.getValue(facesContext));
- }
- else
- {
- //TODO: More sophisticated way to convert boolean value (yes/no, 1/0,
on/off, etc.)
- isAjaxOnly = Boolean.parseBoolean(ajaxOnly);
- }
-
- }
- // Get bean instance from EL expression.
- String beanExpression = "#{"+beanName+"}";
- ValueBinding valueBinding =
facesContext.getApplication().createValueBinding(beanExpression);
- Object bean = valueBinding.getValue(facesContext);
- // Put bean instance to ViewRoot.
- String beanAttributeName =
isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+beanName;
- facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
- return Tag.SKIP_BODY;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.jsp.tagext.TagSupport#release()
- */
- public void release() {
- beanName = null;
- ajaxOnly = null;
- super.release();
- }
-
-
-}
Deleted:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
===================================================================
---
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,189 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright 1999,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.taglib.html.jsp;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Locale;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-import javax.servlet.jsp.JspWriter;
-
-import org.ajax4jsf.io.FastBufferOutputStream;
-
-
-
-/**
- * ServletResponseWrapper used by the JSP 'include' action.
- *
- * This wrapper response object is passed to RequestDispatcher.include(), so
- * that the output of the included resource is appended to that of the including
- * page.
- *
- * @author Pierre Delisle
- */
-
-public class ServletResponseWrapperInclude extends HttpServletResponseWrapper {
-
- /**
- * PrintWriter which appends to the JspWriter of the including page.
- */
- private PrintWriter _printWriter;
-
- private FastBufferOutputStream _bytes ;
-
- private ServletOutputStream _servletStream;
-
- private JspWriter _jspWriter;
-
- private boolean useWriter = false;
-
- private boolean useStream = false;
-
- public ServletResponseWrapperInclude(ServletResponse response,
- JspWriter jspWriter) {
- super((HttpServletResponse) response);
- this._printWriter = new PrintWriter(jspWriter);
- this._jspWriter = jspWriter;
- }
-
- /**
- * Returns a wrapper around the JspWriter of the including page.
- */
- public PrintWriter getWriter() throws IOException {
- if (useStream) {
- throw new IllegalStateException();
- }
- useWriter = true;
- return _printWriter;
- }
-
- public ServletOutputStream getOutputStream() throws IOException {
- if(useWriter){
- throw new IllegalStateException();
- }
- if (!useStream) {
- _bytes = new FastBufferOutputStream(getBufferSize());
- _servletStream = new ServletOutputStream(){
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- public void flush() throws IOException {
- // TODO Auto-generated method stub
- super.flush();
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException {
- // TODO Auto-generated method stub
- _bytes.write(b, off, len);
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] b) throws IOException {
- // TODO Auto-generated method stub
- _bytes.write(b);
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(int)
- */
- public void write(int b) throws IOException {
- _bytes.write(b);
- }
-
- };
- useStream = true;
- }
- return _servletStream;
- }
-
- /**
- * Clears the output buffer of the JspWriter associated with the including
- * page.
- */
- public void resetBuffer() {
- try {
- _jspWriter.clearBuffer();
- useWriter = false;
- useStream = false;
- _bytes = null;
- } catch (IOException ioe) {
- }
- }
-
- public void reset() {
- // TODO Auto-generated method stub
- resetBuffer();
- }
-
- public void flushBuffer() throws IOException {
- if (useStream) {
- // TODO - detect encoding ?
- _bytes.writeTo(_jspWriter, getCharacterEncoding());
- _bytes = new FastBufferOutputStream(getBufferSize());
- }
- }
-
- // Override ignored methods.
- public void setBufferSize(int arg0) {
- }
-
- public void setContentLength(int arg0) {
- }
- public void setContentType(String arg0) {
- }
- public void setStatus(int arg0) {
- }
- public void setLocale(Locale arg0) {
- }
- public void sendRedirect(String arg0) throws IOException {
- throw new IllegalStateException();
- }
-// public void setStatus(int arg0, String arg1) {
-// }
-
-}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Selectable.java (from
rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Selectable.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Selectable.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import org.richfaces.model.selection.Selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selectable {
+ public Selection getSelection();
+ public void setSelection (Selection selection);
+}
Copied: branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Sortable.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Sortable.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/component/Sortable.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,23 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v
$
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.model.SortOrder;
+
+
+/**
+ * @author Maksim Kaszynski
+ * Base interface for sort capable components
+ */
+public interface Sortable {
+ public SortOrder getSortOrder();
+ public void setSortOrder(SortOrder sortOrder);
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
(from rev 1388,
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+
+//TODO by nick - denis - add addToggleListener method to component
+public interface ISimpleToggle2Listener extends FacesListener {
+
+ public void processToggle(SimpleToggle2Event event);
+
+}
\ No newline at end of file
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/SimpleToggle2Event.java
(from rev 1388,
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/SimpleToggle2Event.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/SimpleToggle2Event.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,76 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+public class SimpleToggle2Event extends ActionEvent {
+
+ private static final long serialVersionUID = 5582624805941635421L;
+ private boolean _opened;
+
+ /**
+ * @param source
+ * @param opened
+ */
+ public SimpleToggle2Event(UIComponent source, boolean opened) {
+ super(source);
+ this._opened = opened;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof ISimpleToggle2Listener;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((ISimpleToggle2Listener) listener).processToggle(this);
+ }
+
+ /**
+ * @return Returns the _state.
+ */
+ public boolean isIsOpen() {
+ return _opened;
+ }
+
+ /**
+ *
+ * @param opened The state to set
+ */
+ public void setIsOpen(boolean opened) {
+ this._opened = opened;
+ }
+}
\ No newline at end of file
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/scroll/ScrollEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package org.richfaces.event.scroll;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class ScrollEvent extends FacesEvent {
+
+ private static final long serialVersionUID = 3786221668771853810L;
+
+ private int rows;
+
+ private int first;
+
+ public ScrollEvent(UIComponent component, int rows, int first){
+ super(component);
+ this.rows = rows;
+ this.first = first;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ }
+
+ public int getFirst() {
+ return first;
+ }
+
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public int getRows() {
+ return rows;
+ }
+
+ public void setRows(int rows) {
+ this.rows = rows;
+ }
+
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortEvent.java (from
rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortEvent.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,95 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortEvent.java,v
$
+ * $Revision: 1.2 $
+ */
+
+package org.richfaces.event.sort;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ *
+ */
+public class SortEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -1453867412542792281L;
+
+ private int sortColumn;
+
+ private int startRow;
+
+ private int dataIndex;
+
+ private boolean asc;
+
+
+ public SortEvent(
+ UIComponent component, int sortColumn, int startRow, int dataIndex, boolean asc) {
+
+ super(component);
+ this.asc = asc;
+ this.sortColumn = sortColumn;
+ this.startRow = startRow;
+ this.dataIndex = dataIndex;
+
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof SortListener);
+ }
+
+ public void processListener(FacesListener listener) {
+ ((SortListener) listener).processSort(this);
+ }
+
+ /**
+ * @return the sortField
+ */
+ public int getSortColumn() {
+ return sortColumn;
+ }
+
+ /**
+ * @see java.util.EventObject#toString()
+ */
+ public String toString() {
+ return "SortEvent: {sortColumn: " + sortColumn + "}";
+ }
+
+ public boolean isAsc() {
+ return asc;
+ }
+
+ public void setAsc(boolean asc) {
+ this.asc = asc;
+ }
+
+ public int getDataIndex() {
+ return dataIndex;
+ }
+
+ public void setDataIndex(int dataIndex) {
+ this.dataIndex = dataIndex;
+ }
+
+ public int getStartRow() {
+ return startRow;
+ }
+
+ public void setStartRow(int startRow) {
+ this.startRow = startRow;
+ }
+
+ public void setSortColumn(int sortColumn) {
+ this.sortColumn = sortColumn;
+ }
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortListener.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortListener.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,21 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortListener.java,v
$
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.event.sort;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface SortListener extends FacesListener {
+ public void processSort(SortEvent e);
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortSource.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortSource.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/event/sort/SortSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,21 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortSource.java,v
$
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.event.sort;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface SortSource {
+ public void addSortListener(SortListener listener);
+ public void removeSortListener(SortListener listener);
+ public SortListener[] getSortListeners();
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/DataModelCache.java (from
rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/DataModelCache.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/DataModelCache.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,186 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.ajax4jsf.ajax.repeat.SerializableDataModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation stores last loaded data, so no additional requests to db will be
performed
+ * Acts as a proxy between the component and original data model
+ * @author Maksim Kaszynski
+ *
+ */
+public class DataModelCache extends GridDataModel {
+
+ private static Log log = LogFactory.getLog(DataModelCache.class);
+
+ private static class DataRange {
+ private int startRow;
+ private int endRow;
+ private SortOrder sortOrder;
+ private List loadedData;
+
+ public DataRange(int startRow, int endRow, SortOrder sortOrder,
+ List loadedData) {
+ super();
+ this.startRow = startRow;
+ this.endRow = endRow;
+ this.sortOrder = sortOrder;
+ this.loadedData = loadedData;
+ }
+
+ public boolean match(int s, int e, SortOrder sortOrder) {
+ return s == startRow
+ && e == endRow
+ && sortOrdersMatch(sortOrder, this.sortOrder);
+ }
+
+ private boolean sortOrdersMatch(SortOrder sortOrder1, SortOrder sortOrder2) {
+ boolean result = sortOrder1 == sortOrder2;
+
+ if (sortOrder1 != null && sortOrder2 != null) {
+ result = sortOrder1.equals(sortOrder2);
+ }
+
+ return result;
+ }
+
+ }
+
+ private Map secondaryMapping = new HashMap();
+
+ private DataRange dataRange;
+
+ private GridDataModel gridDataModel;
+
+ private int rowCount = Integer.MIN_VALUE;
+
+ public DataModelCache(GridDataModel gridDataModel) {
+ super();
+ this.gridDataModel = gridDataModel;
+
+ if (log.isTraceEnabled()) {
+ log.trace("initializing with " + gridDataModel);
+ }
+ }
+
+ public void addDataModelListener(DataModelListener listener) {
+ gridDataModel.addDataModelListener(listener);
+ }
+
+ public DataModelListener[] getDataModelListeners() {
+ return gridDataModel.getDataModelListeners();
+ }
+
+ public Object getObjectById(Object id) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Trying to get object by id" + id);
+ }
+ //First try to find data in inner cache
+ //If not found - get it from original model
+ Object cached = secondaryMapping.get(id);
+
+ if (cached == null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Cache miss " + id + " falling back to original
model");
+ }
+
+ cached = gridDataModel.getObjectById(id);
+ secondaryMapping.put(id, cached);
+
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("At last found element " + cached);
+ }
+
+ return cached;
+ }
+
+ public int getRowCount() {
+ if (rowCount == Integer.MIN_VALUE) {
+ rowCount = gridDataModel.getRowCount();
+ }
+ return rowCount;
+ }
+
+ public Object getRowData() {
+ Object secondaryMapped = secondaryMapping.get(getRowKey());
+
+ if (secondaryMapped == null) {
+ secondaryMapped = super.getRowData();
+ }
+ return secondaryMapped;
+ }
+
+ public int getRowIndex() {
+ return gridDataModel.getRowIndex();
+ }
+
+ public Object getRowKey() {
+ return gridDataModel.getRowKey();
+ }
+
+ public SerializableDataModel getSerializableModel(Range range) {
+ return gridDataModel.getSerializableModel(range);
+ }
+
+ public Object getWrappedData() {
+ return gridDataModel.getWrappedData();
+ }
+
+ public boolean isRowAvailable() {
+ return secondaryMapping.containsKey(getRowKey()) || super.isRowAvailable();
+ }
+
+ public List loadData(int startRow, int endRow, SortOrder sortOrder) {
+ if (dataRange == null || !dataRange.match(startRow, endRow, sortOrder)) {
+ List data = gridDataModel.loadData(startRow, endRow, sortOrder);
+ dataRange = new DataRange(startRow, endRow, sortOrder, data);
+ }
+ return dataRange.loadedData;
+ }
+
+ public void removeDataModelListener(DataModelListener listener) {
+ gridDataModel.removeDataModelListener(listener);
+ }
+
+ public void setRowIndex(int arg0) {
+ gridDataModel.setRowIndex(arg0);
+ }
+
+ public void setRowKey(Object key) {
+ gridDataModel.setRowKey(key);
+ super.setRowKey(key);
+ }
+
+ public void setWrappedData(Object arg0) {
+ gridDataModel.setWrappedData(arg0);
+ }
+
+ public Object getId(Object o) {
+ return gridDataModel.getId(o);
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ // TODO Auto-generated method stub
+ super.walk(context, visitor, range, argument);
+ }
+
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java (from
rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,208 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for data models
+ * Subclasses must implement {@link #loadData(int, int, SortOrder)}
+ * For certain features (like selection and sorting) to work correctly together,
+ * {@link #getId(Object)} and {@link #getObjectById(Object)}
+ * methods need to be overriden
+ *
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class GridDataModel extends ExtendedDataModel {
+
+ /**
+ * Simple implementation - index-based row key
+ * @author Maksim Kaszynski
+ *
+ */
+ private static class SimpleRowKey implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+ private int i;
+
+ public SimpleRowKey(int i) {
+ super();
+ this.i = i;
+ }
+
+ public int intValue() {
+ return i;
+ }
+
+ public String toString() {
+ return String.valueOf(i);
+ }
+ }
+
+
+ private static final Log log = LogFactory.getLog(GridDataModel.class);
+
+ private Object rowKey;
+
+ private Map mapping;
+
+ private SortOrder lastSortOrder;
+
+ /**
+ * Load range of data items from the source.
+ * Starting from startRow, and up to but excluding endRow
+ * @param startRow
+ * @param endRow
+ * @param sortOrder
+ * @return list of ordered data
+ */
+ public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
+
+
+ /**
+ * Load data range, and iterate over it
+ */
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+
+ if (log.isTraceEnabled()) {
+ log.trace("Starting walk");
+ }
+
+ ScrollableGridRange sequenceRange = (ScrollableGridRange) range;
+
+ int startIndex = sequenceRange.getFirst();
+ int last = sequenceRange.getLast();
+
+ lastSortOrder = sequenceRange.getSortOrder();
+
+ List objects = loadData(startIndex, last, lastSortOrder);
+
+ mapping = new HashMap();
+
+ for (int i = 0; i < objects.size(); i++,startIndex++) {
+ Object data = objects.get(i);
+ Object key = getId(data);
+
+ if (key == null) {
+ key = new SimpleRowKey(startIndex);
+ }
+
+ mapping.put(key, data);
+
+ visitor.process(context, key, argument);
+
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("Ending walk");
+ }
+
+ }
+
+
+ /**
+ * This method is the reverse of {@link #getId(Object)}
+ * If you override this method, you need to override {@link #getId(Object)} as well
+ * @param id
+ * @return
+ */
+ public Object getObjectById(Object id) {
+
+ if (id instanceof SimpleRowKey) {
+ int i = ((SimpleRowKey) id).intValue();
+
+ List l = loadData(i, i + 1, lastSortOrder);
+
+ return l.get(0);
+
+ }
+
+ return null;
+ }
+
+ /**
+ * To get rid of Entity interface, method is introduced
+ * Implementations may override it to provide domain-specific searches
+ * Id should be serializable
+ * Default implementation returns <code>null</code> anyway
+ * If you override this method, you need to override {@link #getObjectById(Object)} as
well
+ * @param o
+ * @return
+ */
+ public Object getId(Object o) {
+ return null;
+ }
+
+
+ public Object getRowData() {
+
+ if (mapping != null && mapping.containsKey(rowKey)) {
+ return mapping.get(rowKey);
+ } else {
+ return loadAndMap(rowKey);
+ }
+
+ }
+
+ /**
+ * Row indexes navigation is no longer supported
+ */
+ public int getRowIndex() {
+ throw new UnsupportedOperationException("getRowIndex");
+ }
+
+ /**
+ * Quite simple implementation - data will be cached, so the call will be cheap
+ */
+ public boolean isRowAvailable() {
+ return getRowData() != null;
+ }
+
+ /**
+ * Row indexes navigation is no longer supported
+ */
+ public void setRowIndex(int arg0) {
+ throw new UnsupportedOperationException("setRowIndex");
+ }
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public void setRowKey(Object key) {
+ rowKey = key;
+ }
+
+ private Object loadAndMap(Object id) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("loadAndMap " + id);
+ }
+
+ Object o = getObjectById(id);
+ if (o != null) {
+ if (mapping == null) {
+ mapping = new HashMap();
+ }
+ mapping.put(id, o);
+ }
+ return o;
+ }
+
+
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,93 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableGridRange.java,v
$
+ * $Revision: 1.7 $
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+import org.ajax4jsf.ajax.repeat.Range;
+
+
+
+/**
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ */
+public class ScrollableGridRange implements Range, Serializable{
+
+ private static final long serialVersionUID = -6675002421400464892L;
+
+ private int first = 0;
+ private int last = 0;
+ private SortOrder sortOrder;
+
+ public ScrollableGridRange(int first, int last, SortOrder sortOrder) {
+ super();
+ this.first = first;
+ this.last = last;
+ this.sortOrder = sortOrder;
+ }
+
+ /**
+ * @return the bufferSize
+ */
+ public int getLast() {
+ return last;
+ }
+ /**
+ * @param bufferSize the bufferSize to set
+ */
+ public void setLast(int lastRow) {
+ this.last = lastRow;
+ }
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return first;
+ }
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ public boolean equals(Object obj) {
+
+ if(!(obj instanceof ScrollableGridRange)){
+ return super.equals(obj);
+ }
+
+ ScrollableGridRange ref = (ScrollableGridRange)obj;
+
+ boolean ret = (this.first == ref.first)&&(this.last == ref.last );
+
+ if(this.sortOrder != null){
+ ret = ret && this.sortOrder.equals(ref.sortOrder);
+ } else {
+ ret = (ret && (ref.sortOrder == null));
+ }
+
+ return ret;
+ }
+
+ public int hashCode() {
+ return super.hashCode();
+ }
+}
Copied: branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java)
===================================================================
--- branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/SortOrder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,74 @@
+package org.richfaces.model;
+
+import java.io.Serializable;
+/**
+ *
+ * @author Maksim Kaszynski
+ *
+ *
+ */
+public class SortOrder implements Serializable {
+
+ private static final long serialVersionUID = 2423450561570551363L;
+
+ private boolean ascending;
+
+ private int sortColumn = -1;
+
+
+ public SortOrder( int sortColumn, boolean ascending) {
+ super();
+ this.sortColumn = sortColumn;
+ this.ascending = ascending;
+ }
+
+ public SortOrder() {
+ super();
+ }
+
+ public boolean isAscending() {
+ return ascending;
+ }
+
+ public void setAscending(boolean ascending) {
+ this.ascending = ascending;
+ }
+
+ public int getSortColumn() {
+ return sortColumn;
+ }
+
+ public void setSortColumn(int sortColumn) {
+ this.sortColumn = sortColumn;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "SortOrder: {field:" + sortColumn + ", ascending: " +
ascending
+ + "}";
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+
+ if (obj instanceof SortOrder) {
+ SortOrder sortOrder = (SortOrder) obj;
+ return sortColumn == sortOrder.sortColumn
+ && ascending == sortOrder.ascending;
+
+ }
+ return super.equals(obj);
+ }
+
+ public int hashCode() {
+ int c = (new Integer(sortColumn)).hashCode();
+ if (ascending) {
+ c = -c;
+ }
+ return c;
+ }
+}
\ No newline at end of file
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/ClientSelection.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/ClientSelection.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,129 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ClientSelection implements Serializable{
+
+ private static final long serialVersionUID = 5855157282287053681L;
+
+ public static final String FLAG_RESET = "x";
+
+ public static final String FLAG_ALL = "a";
+
+ private String selectionFlag;
+
+ private List ranges = new ArrayList();
+
+ public ClientSelection() {
+ }
+
+
+ public void addRange(SelectionRange range) {
+ ranges.add(range);
+ }
+
+ public boolean isSelected(int i) {
+ boolean result = false;
+ Iterator iterator = ranges.iterator();
+ while (iterator.hasNext() && !result) {
+ result |= ((SelectionRange) iterator.next()).within(i);
+ }
+ return result;
+ }
+
+ public List getRanges() {
+ return ranges;
+ }
+
+ public void addIndex(int j) {
+ if(this.isSelected(j)) return;
+
+
+
+ SelectionRange firstRange = null;
+
+ int s = ranges.size();
+
+ int insertPosition = 0;
+
+ for(int i = 0; i < s && insertPosition >= 0 ; i++) {
+
+ firstRange = (SelectionRange) ranges.get(i);
+
+ if (firstRange.getStartIndex() == j + 1) {
+
+ firstRange.setStartIndex(j);
+ insertPosition = -1;
+
+ } else if (firstRange.getEndIndex() == j - 1) {
+
+ firstRange.setEndIndex(j);
+
+ if (i + 1 < s) {
+ SelectionRange range2 = (SelectionRange) ranges.get(i + 1);
+
+ if (range2.getStartIndex() == j || range2.getStartIndex() == j + 1) {
+
+ ranges.remove(i + 1);
+
+ firstRange.setEndIndex(range2.getEndIndex());
+ }
+ }
+
+ insertPosition = -1;
+
+ } else if (firstRange.getStartIndex() > j) {
+ insertPosition = i;
+ }
+
+ }
+
+ if (insertPosition >= 0) {
+ firstRange = new SelectionRange(j,j);
+ ranges.add(insertPosition, firstRange);
+
+ return;
+ }
+
+
+ }
+
+ private boolean reset = false;
+ public boolean isReset() {
+ return reset;
+ }
+
+ private boolean selectAll = false;
+ public boolean isSelectAll() {
+ return selectAll;
+ }
+
+
+ public String getSelectionFlag() {
+ return selectionFlag;
+ }
+
+
+ public void setSelectionFlag(String selectionFlag) {
+ this.selectionFlag = selectionFlag;
+
+ reset = false;
+ selectAll = false;
+
+ if (FLAG_ALL.equals(selectionFlag)) {
+ selectAll = true;
+ } else if (FLAG_RESET.equals(selectionFlag)) {
+ reset = true;
+ }
+ }
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/Selection.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/Selection.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/Selection.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selection extends Serializable {
+
+ public Iterator getKeys();
+
+ public int size();
+
+ public boolean isSelected(Object rowKey);
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SelectionRange.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SelectionRange.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SelectionRange {
+ private int startIndex = -1;;
+ private int endIndex = -1;
+
+ public SelectionRange(int startIndex, int endIndex) {
+ super();
+ this.startIndex = startIndex;
+ this.endIndex = endIndex;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ public void setEndIndex(int endIndex) {
+ this.endIndex = endIndex;
+ }
+
+ public boolean within(int index) {
+ return startIndex <= index && endIndex >= index;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + endIndex;
+ result = prime * result + startIndex;
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SelectionRange other = (SelectionRange) obj;
+ if (endIndex != other.endIndex)
+ return false;
+ if (startIndex != other.startIndex)
+ return false;
+ return true;
+ }
+
+
+}
Copied:
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
(from rev 1388,
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java)
===================================================================
---
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
(rev 0)
+++
branches/refactor1/sandbox/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SimpleSelection implements Selection {
+
+ private static final long serialVersionUID = 1L;
+
+ private Set keys = new HashSet();
+
+ public boolean addKey(Object rowKey) {
+ return keys.add(rowKey);
+ }
+
+ public boolean removeKey(Object rowKey) {
+ return keys.remove(rowKey);
+ }
+
+ public Iterator getKeys() {
+ return keys.iterator();
+ }
+
+ public int size() {
+ return keys.size();
+ }
+
+ public boolean isSelected(Object rowKey) {
+ return keys.contains(rowKey);
+ }
+
+ public void clear() {
+ keys.clear();
+ }
+}
Deleted:
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModel.java
===================================================================
---
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.component;
-
-import java.util.Date;
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-public interface CalendarDataModel {
-
- /**
- * @return array of CalendarDataModelItems for selected dates.
- * This method will be called every time when components will need next block of
CalendarDataItems.
- * That may happens when calendar rendered, or when user navigate to next(previous)
month or in any other case when calendar renders.
- * This method will be called in Ajax mode when Calendar renders new page.
- * */
- public CalendarDataModelItem[] getData(Date[] dateArray);
-
- /**
- * @return tool tip when it's used in "single" mode
- * This method used when tool tips are displayed in "single" mode
- * */
- public Object getToolTip(Date date);
-}
Deleted:
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModelItem.java
===================================================================
---
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModelItem.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/calendar/src/main/java/org/richfaces/component/CalendarDataModelItem.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,65 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.component;
-
-import java.util.Date;
-
-
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-
-public interface CalendarDataModelItem {
-
- /**
- * @return date that this item for, default implementation return Date
- * */
- public Date getDate();
-
- /**
- *@return true if date is �selectable� on calendar, default implementation return true
- **/
- public boolean isEnabled();
-
- /**
- * @return String that will be appended to style class for that date span.
- * For example it may be �relevant holyday� � that mean class will be like �rich-cal-day
relevant holyday�.
- * Default implementation return empty string.
- * */
- public String getStyleClass();
-
- /**
- * @return any additional payload that must be JSON-serialazable object.
- * May be used in custom date representation on calendar (inside custom facet).*/
- public Object getData();
-
- /**
- * @return true if given date has an associated with it tooltip data.
- * Default implementation return false.*/
- public boolean hasToolTip();
-
- /**
- *@return tool tip data that will be used in �batch� tooltip loading mode.
- **/
- public Object getToolTip();
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,15 +0,0 @@
-/**
- *
- */
-package org.richfaces.component;
-
-import org.richfaces.model.selection.Selection;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface Selectable {
- public Selection getSelection();
- public void setSelection (Selection selection);
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,23 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v
$
- * $Revision: 1.1 $
- */
-
-package org.richfaces.component;
-
-import org.richfaces.model.SortOrder;
-
-
-/**
- * @author Maksim Kaszynski
- * Base interface for sort capable components
- */
-public interface Sortable {
- public SortOrder getSortOrder();
- public void setSortOrder(SortOrder sortOrder);
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,51 +0,0 @@
-/**
- *
- */
-package org.richfaces.event.scroll;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Anton Belevich
- *
- */
-public class ScrollEvent extends FacesEvent {
-
- private static final long serialVersionUID = 3786221668771853810L;
-
- private int rows;
-
- private int first;
-
- public ScrollEvent(UIComponent component, int rows, int first){
- super(component);
- this.rows = rows;
- this.first = first;
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return false;
- }
-
- public void processListener(FacesListener listener) {
- }
-
- public int getFirst() {
- return first;
- }
-
- public void setFirst(int first) {
- this.first = first;
- }
-
- public int getRows() {
- return rows;
- }
-
- public void setRows(int rows) {
- this.rows = rows;
- }
-
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,95 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortEvent.java,v
$
- * $Revision: 1.2 $
- */
-
-package org.richfaces.event.sort;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Maksim Kaszynski
- * @modified by Anton Belevich
- *
- */
-public class SortEvent extends FacesEvent {
-
- private static final long serialVersionUID = -1453867412542792281L;
-
- private int sortColumn;
-
- private int startRow;
-
- private int dataIndex;
-
- private boolean asc;
-
-
- public SortEvent(
- UIComponent component, int sortColumn, int startRow, int dataIndex, boolean asc) {
-
- super(component);
- this.asc = asc;
- this.sortColumn = sortColumn;
- this.startRow = startRow;
- this.dataIndex = dataIndex;
-
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return (listener instanceof SortListener);
- }
-
- public void processListener(FacesListener listener) {
- ((SortListener) listener).processSort(this);
- }
-
- /**
- * @return the sortField
- */
- public int getSortColumn() {
- return sortColumn;
- }
-
- /**
- * @see java.util.EventObject#toString()
- */
- public String toString() {
- return "SortEvent: {sortColumn: " + sortColumn + "}";
- }
-
- public boolean isAsc() {
- return asc;
- }
-
- public void setAsc(boolean asc) {
- this.asc = asc;
- }
-
- public int getDataIndex() {
- return dataIndex;
- }
-
- public void setDataIndex(int dataIndex) {
- this.dataIndex = dataIndex;
- }
-
- public int getStartRow() {
- return startRow;
- }
-
- public void setStartRow(int startRow) {
- this.startRow = startRow;
- }
-
- public void setSortColumn(int sortColumn) {
- this.sortColumn = sortColumn;
- }
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,21 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortListener.java,v
$
- * $Revision: 1.1 $
- */
-
-package org.richfaces.event.sort;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface SortListener extends FacesListener {
- public void processSort(SortEvent e);
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,21 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortSource.java,v
$
- * $Revision: 1.1 $
- */
-
-package org.richfaces.event.sort;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface SortSource {
- public void addSortListener(SortListener listener);
- public void removeSortListener(SortListener listener);
- public SortListener[] getSortListeners();
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,186 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.Range;
-import org.ajax4jsf.ajax.repeat.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Implementation stores last loaded data, so no additional requests to db will be
performed
- * Acts as a proxy between the component and original data model
- * @author Maksim Kaszynski
- *
- */
-public class DataModelCache extends GridDataModel {
-
- private static Log log = LogFactory.getLog(DataModelCache.class);
-
- private static class DataRange {
- private int startRow;
- private int endRow;
- private SortOrder sortOrder;
- private List loadedData;
-
- public DataRange(int startRow, int endRow, SortOrder sortOrder,
- List loadedData) {
- super();
- this.startRow = startRow;
- this.endRow = endRow;
- this.sortOrder = sortOrder;
- this.loadedData = loadedData;
- }
-
- public boolean match(int s, int e, SortOrder sortOrder) {
- return s == startRow
- && e == endRow
- && sortOrdersMatch(sortOrder, this.sortOrder);
- }
-
- private boolean sortOrdersMatch(SortOrder sortOrder1, SortOrder sortOrder2) {
- boolean result = sortOrder1 == sortOrder2;
-
- if (sortOrder1 != null && sortOrder2 != null) {
- result = sortOrder1.equals(sortOrder2);
- }
-
- return result;
- }
-
- }
-
- private Map secondaryMapping = new HashMap();
-
- private DataRange dataRange;
-
- private GridDataModel gridDataModel;
-
- private int rowCount = Integer.MIN_VALUE;
-
- public DataModelCache(GridDataModel gridDataModel) {
- super();
- this.gridDataModel = gridDataModel;
-
- if (log.isTraceEnabled()) {
- log.trace("initializing with " + gridDataModel);
- }
- }
-
- public void addDataModelListener(DataModelListener listener) {
- gridDataModel.addDataModelListener(listener);
- }
-
- public DataModelListener[] getDataModelListeners() {
- return gridDataModel.getDataModelListeners();
- }
-
- public Object getObjectById(Object id) {
-
- if (log.isDebugEnabled()) {
- log.debug("Trying to get object by id" + id);
- }
- //First try to find data in inner cache
- //If not found - get it from original model
- Object cached = secondaryMapping.get(id);
-
- if (cached == null) {
-
- if (log.isDebugEnabled()) {
- log.debug("Cache miss " + id + " falling back to original
model");
- }
-
- cached = gridDataModel.getObjectById(id);
- secondaryMapping.put(id, cached);
-
- }
-
- if (log.isDebugEnabled()) {
- log.debug("At last found element " + cached);
- }
-
- return cached;
- }
-
- public int getRowCount() {
- if (rowCount == Integer.MIN_VALUE) {
- rowCount = gridDataModel.getRowCount();
- }
- return rowCount;
- }
-
- public Object getRowData() {
- Object secondaryMapped = secondaryMapping.get(getRowKey());
-
- if (secondaryMapped == null) {
- secondaryMapped = super.getRowData();
- }
- return secondaryMapped;
- }
-
- public int getRowIndex() {
- return gridDataModel.getRowIndex();
- }
-
- public Object getRowKey() {
- return gridDataModel.getRowKey();
- }
-
- public SerializableDataModel getSerializableModel(Range range) {
- return gridDataModel.getSerializableModel(range);
- }
-
- public Object getWrappedData() {
- return gridDataModel.getWrappedData();
- }
-
- public boolean isRowAvailable() {
- return secondaryMapping.containsKey(getRowKey()) || super.isRowAvailable();
- }
-
- public List loadData(int startRow, int endRow, SortOrder sortOrder) {
- if (dataRange == null || !dataRange.match(startRow, endRow, sortOrder)) {
- List data = gridDataModel.loadData(startRow, endRow, sortOrder);
- dataRange = new DataRange(startRow, endRow, sortOrder, data);
- }
- return dataRange.loadedData;
- }
-
- public void removeDataModelListener(DataModelListener listener) {
- gridDataModel.removeDataModelListener(listener);
- }
-
- public void setRowIndex(int arg0) {
- gridDataModel.setRowIndex(arg0);
- }
-
- public void setRowKey(Object key) {
- gridDataModel.setRowKey(key);
- super.setRowKey(key);
- }
-
- public void setWrappedData(Object arg0) {
- gridDataModel.setWrappedData(arg0);
- }
-
- public Object getId(Object o) {
- return gridDataModel.getId(o);
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- // TODO Auto-generated method stub
- super.walk(context, visitor, range, argument);
- }
-
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,208 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
-import org.ajax4jsf.ajax.repeat.Range;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for data models
- * Subclasses must implement {@link #loadData(int, int, SortOrder)}
- * For certain features (like selection and sorting) to work correctly together,
- * {@link #getId(Object)} and {@link #getObjectById(Object)}
- * methods need to be overriden
- *
- * @author Maksim Kaszynski
- *
- */
-public abstract class GridDataModel extends ExtendedDataModel {
-
- /**
- * Simple implementation - index-based row key
- * @author Maksim Kaszynski
- *
- */
- private static class SimpleRowKey implements Serializable{
-
- private static final long serialVersionUID = 1L;
- private int i;
-
- public SimpleRowKey(int i) {
- super();
- this.i = i;
- }
-
- public int intValue() {
- return i;
- }
-
- public String toString() {
- return String.valueOf(i);
- }
- }
-
-
- private static final Log log = LogFactory.getLog(GridDataModel.class);
-
- private Object rowKey;
-
- private Map mapping;
-
- private SortOrder lastSortOrder;
-
- /**
- * Load range of data items from the source.
- * Starting from startRow, and up to but excluding endRow
- * @param startRow
- * @param endRow
- * @param sortOrder
- * @return list of ordered data
- */
- public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
-
-
- /**
- * Load data range, and iterate over it
- */
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
-
- if (log.isTraceEnabled()) {
- log.trace("Starting walk");
- }
-
- ScrollableGridRange sequenceRange = (ScrollableGridRange) range;
-
- int startIndex = sequenceRange.getFirst();
- int last = sequenceRange.getLast();
-
- lastSortOrder = sequenceRange.getSortOrder();
-
- List objects = loadData(startIndex, last, lastSortOrder);
-
- mapping = new HashMap();
-
- for (int i = 0; i < objects.size(); i++,startIndex++) {
- Object data = objects.get(i);
- Object key = getId(data);
-
- if (key == null) {
- key = new SimpleRowKey(startIndex);
- }
-
- mapping.put(key, data);
-
- visitor.process(context, key, argument);
-
- }
-
- if (log.isTraceEnabled()) {
- log.trace("Ending walk");
- }
-
- }
-
-
- /**
- * This method is the reverse of {@link #getId(Object)}
- * If you override this method, you need to override {@link #getId(Object)} as well
- * @param id
- * @return
- */
- public Object getObjectById(Object id) {
-
- if (id instanceof SimpleRowKey) {
- int i = ((SimpleRowKey) id).intValue();
-
- List l = loadData(i, i + 1, lastSortOrder);
-
- return l.get(0);
-
- }
-
- return null;
- }
-
- /**
- * To get rid of Entity interface, method is introduced
- * Implementations may override it to provide domain-specific searches
- * Id should be serializable
- * Default implementation returns <code>null</code> anyway
- * If you override this method, you need to override {@link #getObjectById(Object)} as
well
- * @param o
- * @return
- */
- public Object getId(Object o) {
- return null;
- }
-
-
- public Object getRowData() {
-
- if (mapping != null && mapping.containsKey(rowKey)) {
- return mapping.get(rowKey);
- } else {
- return loadAndMap(rowKey);
- }
-
- }
-
- /**
- * Row indexes navigation is no longer supported
- */
- public int getRowIndex() {
- throw new UnsupportedOperationException("getRowIndex");
- }
-
- /**
- * Quite simple implementation - data will be cached, so the call will be cheap
- */
- public boolean isRowAvailable() {
- return getRowData() != null;
- }
-
- /**
- * Row indexes navigation is no longer supported
- */
- public void setRowIndex(int arg0) {
- throw new UnsupportedOperationException("setRowIndex");
- }
-
- public Object getRowKey() {
- return rowKey;
- }
-
- public void setRowKey(Object key) {
- rowKey = key;
- }
-
- private Object loadAndMap(Object id) {
-
- if (log.isTraceEnabled()) {
- log.trace("loadAndMap " + id);
- }
-
- Object o = getObjectById(id);
- if (o != null) {
- if (mapping == null) {
- mapping = new HashMap();
- }
- mapping.put(id, o);
- }
- return o;
- }
-
-
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,93 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableGridRange.java,v
$
- * $Revision: 1.7 $
- */
-
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-import org.ajax4jsf.ajax.repeat.Range;
-
-
-
-/**
- * @author Maksim Kaszynski
- * @modified by Anton Belevich
- */
-public class ScrollableGridRange implements Range, Serializable{
-
- private static final long serialVersionUID = -6675002421400464892L;
-
- private int first = 0;
- private int last = 0;
- private SortOrder sortOrder;
-
- public ScrollableGridRange(int first, int last, SortOrder sortOrder) {
- super();
- this.first = first;
- this.last = last;
- this.sortOrder = sortOrder;
- }
-
- /**
- * @return the bufferSize
- */
- public int getLast() {
- return last;
- }
- /**
- * @param bufferSize the bufferSize to set
- */
- public void setLast(int lastRow) {
- this.last = lastRow;
- }
- /**
- * @return the first
- */
- public int getFirst() {
- return first;
- }
- /**
- * @param first the first to set
- */
- public void setFirst(int first) {
- this.first = first;
- }
-
- public SortOrder getSortOrder() {
- return sortOrder;
- }
-
- public void setSortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
- }
-
- public boolean equals(Object obj) {
-
- if(!(obj instanceof ScrollableGridRange)){
- return super.equals(obj);
- }
-
- ScrollableGridRange ref = (ScrollableGridRange)obj;
-
- boolean ret = (this.first == ref.first)&&(this.last == ref.last );
-
- if(this.sortOrder != null){
- ret = ret && this.sortOrder.equals(ref.sortOrder);
- } else {
- ret = (ret && (ref.sortOrder == null));
- }
-
- return ret;
- }
-
- public int hashCode() {
- return super.hashCode();
- }
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,74 +0,0 @@
-package org.richfaces.model;
-
-import java.io.Serializable;
-/**
- *
- * @author Maksim Kaszynski
- *
- *
- */
-public class SortOrder implements Serializable {
-
- private static final long serialVersionUID = 2423450561570551363L;
-
- private boolean ascending;
-
- private int sortColumn = -1;
-
-
- public SortOrder( int sortColumn, boolean ascending) {
- super();
- this.sortColumn = sortColumn;
- this.ascending = ascending;
- }
-
- public SortOrder() {
- super();
- }
-
- public boolean isAscending() {
- return ascending;
- }
-
- public void setAscending(boolean ascending) {
- this.ascending = ascending;
- }
-
- public int getSortColumn() {
- return sortColumn;
- }
-
- public void setSortColumn(int sortColumn) {
- this.sortColumn = sortColumn;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "SortOrder: {field:" + sortColumn + ", ascending: " +
ascending
- + "}";
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
-
- if (obj instanceof SortOrder) {
- SortOrder sortOrder = (SortOrder) obj;
- return sortColumn == sortOrder.sortColumn
- && ascending == sortOrder.ascending;
-
- }
- return super.equals(obj);
- }
-
- public int hashCode() {
- int c = (new Integer(sortColumn)).hashCode();
- if (ascending) {
- c = -c;
- }
- return c;
- }
-}
\ No newline at end of file
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,129 +0,0 @@
-/**
- *
- */
-package org.richfaces.model.selection;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ClientSelection implements Serializable{
-
- private static final long serialVersionUID = 5855157282287053681L;
-
- public static final String FLAG_RESET = "x";
-
- public static final String FLAG_ALL = "a";
-
- private String selectionFlag;
-
- private List ranges = new ArrayList();
-
- public ClientSelection() {
- }
-
-
- public void addRange(SelectionRange range) {
- ranges.add(range);
- }
-
- public boolean isSelected(int i) {
- boolean result = false;
- Iterator iterator = ranges.iterator();
- while (iterator.hasNext() && !result) {
- result |= ((SelectionRange) iterator.next()).within(i);
- }
- return result;
- }
-
- public List getRanges() {
- return ranges;
- }
-
- public void addIndex(int j) {
- if(this.isSelected(j)) return;
-
-
-
- SelectionRange firstRange = null;
-
- int s = ranges.size();
-
- int insertPosition = 0;
-
- for(int i = 0; i < s && insertPosition >= 0 ; i++) {
-
- firstRange = (SelectionRange) ranges.get(i);
-
- if (firstRange.getStartIndex() == j + 1) {
-
- firstRange.setStartIndex(j);
- insertPosition = -1;
-
- } else if (firstRange.getEndIndex() == j - 1) {
-
- firstRange.setEndIndex(j);
-
- if (i + 1 < s) {
- SelectionRange range2 = (SelectionRange) ranges.get(i + 1);
-
- if (range2.getStartIndex() == j || range2.getStartIndex() == j + 1) {
-
- ranges.remove(i + 1);
-
- firstRange.setEndIndex(range2.getEndIndex());
- }
- }
-
- insertPosition = -1;
-
- } else if (firstRange.getStartIndex() > j) {
- insertPosition = i;
- }
-
- }
-
- if (insertPosition >= 0) {
- firstRange = new SelectionRange(j,j);
- ranges.add(insertPosition, firstRange);
-
- return;
- }
-
-
- }
-
- private boolean reset = false;
- public boolean isReset() {
- return reset;
- }
-
- private boolean selectAll = false;
- public boolean isSelectAll() {
- return selectAll;
- }
-
-
- public String getSelectionFlag() {
- return selectionFlag;
- }
-
-
- public void setSelectionFlag(String selectionFlag) {
- this.selectionFlag = selectionFlag;
-
- reset = false;
- selectAll = false;
-
- if (FLAG_ALL.equals(selectionFlag)) {
- selectAll = true;
- } else if (FLAG_RESET.equals(selectionFlag)) {
- reset = true;
- }
- }
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,20 +0,0 @@
-/**
- *
- */
-package org.richfaces.model.selection;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface Selection extends Serializable {
-
- public Iterator getKeys();
-
- public int size();
-
- public boolean isSelected(Object rowKey);
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,64 +0,0 @@
-/**
- *
- */
-package org.richfaces.model.selection;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SelectionRange {
- private int startIndex = -1;;
- private int endIndex = -1;
-
- public SelectionRange(int startIndex, int endIndex) {
- super();
- this.startIndex = startIndex;
- this.endIndex = endIndex;
- }
-
- public int getStartIndex() {
- return startIndex;
- }
-
- public void setStartIndex(int startIndex) {
- this.startIndex = startIndex;
- }
-
- public int getEndIndex() {
- return endIndex;
- }
-
- public void setEndIndex(int endIndex) {
- this.endIndex = endIndex;
- }
-
- public boolean within(int index) {
- return startIndex <= index && endIndex >= index;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + endIndex;
- result = prime * result + startIndex;
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final SelectionRange other = (SelectionRange) obj;
- if (endIndex != other.endIndex)
- return false;
- if (startIndex != other.startIndex)
- return false;
- return true;
- }
-
-
-}
Deleted:
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
---
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,43 +0,0 @@
-/**
- *
- */
-package org.richfaces.model.selection;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SimpleSelection implements Selection {
-
- private static final long serialVersionUID = 1L;
-
- private Set keys = new HashSet();
-
- public boolean addKey(Object rowKey) {
- return keys.add(rowKey);
- }
-
- public boolean removeKey(Object rowKey) {
- return keys.remove(rowKey);
- }
-
- public Iterator getKeys() {
- return keys.iterator();
- }
-
- public int size() {
- return keys.size();
- }
-
- public boolean isSelected(Object rowKey) {
- return keys.contains(rowKey);
- }
-
- public void clear() {
- keys.clear();
- }
-}
Deleted:
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
===================================================================
---
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Created on 11.07.2006
- */
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author igels
- */
-
-//TODO by nick - denis - add addToggleListener method to component
-public interface ISimpleToggle2Listener extends FacesListener {
-
- public void processToggle(SimpleToggle2Event event);
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java
===================================================================
---
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/sandbox/ui/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,76 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Created on 11.07.2006
- */
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author igels
- */
-public class SimpleToggle2Event extends ActionEvent {
-
- private static final long serialVersionUID = 5582624805941635421L;
- private boolean _opened;
-
- /**
- * @param source
- * @param opened
- */
- public SimpleToggle2Event(UIComponent source, boolean opened) {
- super(source);
- this._opened = opened;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof ISimpleToggle2Listener;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- ((ISimpleToggle2Listener) listener).processToggle(this);
- }
-
- /**
- * @return Returns the _state.
- */
- public boolean isIsOpen() {
- return _opened;
- }
-
- /**
- *
- * @param opened The state to set
- */
- public void setIsOpen(boolean opened) {
- this._opened = opened;
- }
-}
\ No newline at end of file
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/ForceRender.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/ForceRender.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/ForceRender.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/ForceRender.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,57 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxRenderEvent;
+import org.ajax4jsf.framework.ajax.AjaxRenderListener;
+
+/**
+ * @author shura
+ *
+ */
+public class ForceRender implements AjaxListener, AjaxRenderListener {
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxListener#processAjax(org.ajax4jsf.framework.ajax.AjaxEvent)
+ */
+ public void processAjax(AjaxEvent event) {
+ UIComponent component = event.getComponent();
+ AjaxRenderEvent renderEvent = new AjaxRenderEvent(component);
+ renderEvent.setPhaseId(event.getPhaseId());
+ component.queueEvent(renderEvent);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxRenderListener#processAjaxRender(org.ajax4jsf.framework.ajax.AjaxRenderEvent)
+ */
+ public void processAjaxRender(AjaxRenderEvent event) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ AjaxContext.getCurrentInstance(facesContext).renderSubmittedAjaxRegion(facesContext,false);
+ }
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIActionParameter.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,237 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+import org.ajax4jsf.framework.ajax.JavaScriptParameter;
+import org.ajax4jsf.framework.util.message.Messages;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/01 15:31:55 $
+ *
+ */
+public class UIActionParameter extends UIParameter implements ActionListener,
+ JavaScriptParameter {
+
+ public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.UIActionParameter";
+
+ /***************************************************************************
+ * Binding for update on ActionEvent
+ */
+ private ValueBinding _assignToBinding = null;
+
+ public void setAssignToBinding(ValueBinding propertyBinding) {
+ this._assignToBinding = propertyBinding;
+ }
+
+ public ValueBinding getAssignToBinding() {
+ return _assignToBinding;
+ }
+
+ /** ********************************************************* */
+
+ /***************************************************************************
+ * Converter for update value with this parameter
+ */
+ private Converter _converter = null;
+
+ public void setConverter(Converter converter) {
+ this._converter = converter;
+ }
+
+ public Converter getConverter() {
+ return _converter;
+ }
+
+ /** ********************************************************* */
+
+ /***************************************************************************
+ * Skip quota escaping of parameter value - for substitute JavaScript
+ * exspression on submit
+ */
+ private Boolean _noEscape = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.JavaScriptParameter#setNoEscape(boolean)
+ */
+ public void setNoEscape(boolean noEscape) {
+ this._noEscape = Boolean.valueOf(noEscape);
+ }
+
+ private static String NO_ESCAPE_ATTR = "noEscape";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.JavaScriptParameter#isNoEscape()
+ */
+ public boolean isNoEscape() {
+ return isValueOrBinding(_noEscape, NO_ESCAPE_ATTR);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIParameter#getName()
+ */
+ public String getName() {
+ String name = super.getName();
+ // If name not set - use clientId. be Careful !
+ if (null == name) {
+ name = getClientId(FacesContext.getCurrentInstance());
+ }
+ return name;
+ }
+
+ public Object getValue() {
+ Object value = super.getValue();
+ // TODO - perform conversion if converter is present.
+ if (null != value) {
+ Class type = value.getClass();
+ FacesContext context = getFacesContext();
+ Converter converter = createConverter(context, type);
+ if (null != converter) {
+ value = converter.getAsString(context, this, value);
+
+ }
+
+ }
+ return value;
+ }
+
+ /** ********************************************************* */
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.event.ActionListener#processAction(javax.faces.event.ActionEvent)
+ */
+ public void processAction(ActionEvent actionEvent)
+ throws AbortProcessingException {
+ FacesContext context = FacesContext.getCurrentInstance();
+ ValueBinding updateBinding = getAssignToBinding();
+ if (updateBinding != null && (!updateBinding.isReadOnly(context))) {
+ Object requestValue = context.getExternalContext()
+ .getRequestParameterMap().get(getName());
+ if (requestValue != null && requestValue instanceof String) {
+ Class type = updateBinding.getType(context);
+ Converter converter = createConverter(context, type);
+ if (null != converter) {
+ requestValue = converter.getAsObject(context, this,
+ (String) requestValue);
+
+ }
+ }
+ if (null != requestValue) {
+ updateBinding.setValue(context, requestValue);
+
+ }
+ }
+ }
+
+ /**
+ * @param context
+ * @param type
+ * @return
+ * @throws FacesException
+ */
+ private Converter createConverter(FacesContext context, Class type)
+ throws FacesException {
+ Converter converter = getConverter();
+ if (converter == null && type != null && !type.equals(String.class)
+ && !type.equals(Object.class)) {
+ try {
+ converter = context.getApplication().createConverter(type);
+ } catch (Exception e) {
+ throw new FacesException(Messages.getMessage(
+ Messages.NO_CONVERTER_REGISTERED, type.getName()), e);
+ }
+ }
+ return converter;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ // restore fields values
+ _assignToBinding = (ValueBinding) UIComponentBase.restoreAttachedState(
+ context, values[1]);
+ _noEscape = (Boolean) values[2];
+ _converter = (Converter) UIComponentBase.restoreAttachedState(context,
+ values[3]);
+ ;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[4];
+ values[0] = super.saveState(context);
+ // save fields values
+ values[1] = UIComponentBase
+ .saveAttachedState(context, _assignToBinding);
+ values[2] = _noEscape;
+ values[3] = UIComponentBase.saveAttachedState(context, _converter);
+ return ((Object) (values));
+ }
+
+ /**
+ * @param field -
+ * value of field to get.
+ * @param name -
+ * name of field, to get from ValueBinding
+ * @return boolean value, based on field or valuebinding.
+ */
+ private boolean isValueOrBinding(Boolean field, String name) {
+ if (null != field) {
+ return field.booleanValue();
+ }
+ ValueBinding vb = getValueBinding(name);
+ if (null != vb) {
+ return ((Boolean) vb.getValue(getFacesContext())).booleanValue();
+ } else {
+ return false;
+ }
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandButton.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:28 $
+ *
+ */
+public abstract class UIAjaxCommandButton extends AjaxActionComponent {
+ public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.CommandButton";
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxCommandLink.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
+ *
+ */
+public abstract class UIAjaxCommandLink extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.CommandLink";
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxForm.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,176 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+import org.ajax4jsf.framework.ajax.AjaxComponent;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxSource;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+
+
+/**
+ * Quite different from default <code>HtmlForm</code> - process child
components
+ * not only for submitted form, but if submitted parent
<code>AjaxContainer</code>
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:22 $
+ *
+ */
+public abstract class UIAjaxForm extends UIForm implements AjaxComponent, AjaxSource
+{
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Form";
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponent#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(javax.faces.context.FacesContext context)
+ {
+ if (context == null) {
+ throw new NullPointerException("context");
+ }
+ decode(context);
+ if (mustProcessed(context))
+ {
+ for (Iterator it = getFacetsAndChildren(); it.hasNext();)
+ {
+ UIComponent childOrFacet = (UIComponent) it.next();
+ childOrFacet.processDecodes(context);
+ }
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponent#processValidators(javax.faces.context.FacesContext)
+ */
+ public void processValidators(javax.faces.context.FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (mustProcessed(context))
+ {
+ for (Iterator it = getFacetsAndChildren(); it.hasNext();)
+ {
+ UIComponent childOrFacet = (UIComponent) it.next();
+ childOrFacet.processValidators(context);
+ }
+ }
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponent#processUpdates(javax.faces.context.FacesContext)
+ */
+ public void processUpdates(javax.faces.context.FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (mustProcessed(context))
+ {
+ for (Iterator it = getFacetsAndChildren(); it.hasNext();)
+ {
+ UIComponent childOrFacet = (UIComponent) it.next();
+ childOrFacet.processUpdates(context);
+ }
+ }
+ }
+
+ /**
+ * Test for condition processing decoders/validators/updates
+ * @param context current <code>FacesContext</code>
+ * @return true if submitted parent AjaxContainer or current form.
+ */
+ private boolean mustProcessed(FacesContext context)
+ {
+// if ( !AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
+ if (!isSubmitted() ) {
+ return false;
+ }
+// }
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // perform default
+ super.broadcast(event);
+ if (event instanceof AjaxEvent) {
+ // complete re-Render fields. AjaxEvent deliver before render response.
+ setupReRender();
+ }
+ }
+
+
+ /**
+ * Template methods for fill set of resions to render in subclasses.
+ */
+ protected void setupReRender() {
+ FacesContext context = getFacesContext();
+ AjaxContext.getCurrentInstance(context).addRegionsFromComponent(this);
+ }
+
+
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
+ */
+ public AjaxListener[] getAjaxListeners() {
+ AjaxListener al[] = (AjaxListener [])
+ getFacesListeners(AjaxListener.class);
+ return (al);
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ public abstract boolean isAjaxSubmit();
+
+ public abstract void setAjaxSubmit(boolean ajax);
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxFunction.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:04 $
+ *
+ */
+public abstract class UIAjaxFunction extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Function";
+
+ public abstract String getName();
+
+ public abstract void setName(String name);
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxLog.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UIAjaxLog extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Log";
+
+ public abstract String getHotkey();
+
+ public abstract void setHotkey(String newvalue);
+
+ public abstract String getName();
+ public abstract void setName(String newvalue);
+
+ public abstract String getWidth();
+ public abstract void setWidth(String newvalue);
+
+ public abstract String getHeight();
+ public abstract void setHeight(String newvalue);
+
+ public abstract String getLevel();
+ public abstract void setLevel(String newvalue);
+
+ public abstract boolean isPopup();
+ public abstract void setPopup(boolean popup);
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxOutputPanel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import javax.faces.component.UIPanel;
+
+import org.ajax4jsf.framework.ajax.AjaxOutput;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
+ *
+ */
+public abstract class UIAjaxOutputPanel extends UIPanel implements AjaxOutput {
+
+ public static final String COMPONENT_TYPE =
"org.ajax4jsf.ajax.OutputPanel";
+ /**
+ * @return
+ */
+ public abstract String getLayout();
+
+ public abstract void setLayout(String layout);
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,249 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxRegionBrige;
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+import org.ajax4jsf.framework.ajax.InvokerCallback;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:06 $
+ *
+ */
+public abstract class UIAjaxRegion extends UIPanel implements AjaxContainer {
+
+ private AjaxRegionBrige brige;
+
+ public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.AjaxRegion";
+
+ /**
+ *
+ */
+ public UIAjaxRegion() {
+ brige = new AjaxRegionBrige(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
+ */
+// public void encodeBegin(FacesContext context) throws IOException {
+// UIViewRoot root = context.getViewRoot();
+// if (root instanceof AjaxViewRoot) {
+// ((AjaxViewRoot) root).addAjaxRegion(this);
+// }
+// super.encodeBegin(context);
+// }
+
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ try {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ ajax.encodeAjax(context);
+ } else {
+ // Container not found, use Root for encode.
+ encodeAjax(context);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ try {
+ encodeAjax(context);
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
+ */
+ public void encodeChildren(FacesContext context) throws IOException {
+ // If this region is single child of ViewRoot, encode Ajax response for
+ // submitted container.
+ UIViewRoot viewRoot = context.getViewRoot();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if ( (getParent() == viewRoot) &&
+ (viewRoot instanceof AjaxViewRoot) &&
+ ((AjaxViewRoot) viewRoot).isHavePage() &&
+ (ajaxContext.isAjaxRequest())) {
+ AjaxContext.invokeOnRegionOrRoot((AjaxViewRoot) viewRoot, context, _ajaxInvoker);
+ } else {
+ super.encodeChildren(context);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ brige.broadcast(event);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
+ */
+ public MethodBinding getAjaxListener() {
+ return brige.getAjaxListener();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
+ */
+ public boolean isImmediate() {
+ return brige.isImmediate();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
+ */
+ public boolean isSubmitted() {
+ return brige.isSubmitted();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ Object[] mystate = (Object[]) state;
+ super.restoreState(context, mystate[0]);
+ brige.restoreState(context, mystate[1]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[2];
+ state[0] = super.saveState(context);
+ state[1] = brige.saveState(context);
+ return state;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
+ */
+ public void setAjaxListener(MethodBinding ajaxListener) {
+ brige.setAjaxListener(ajaxListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+ brige.setImmediate(immediate);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
+ */
+ public void setSubmitted(boolean submitted) {
+ brige.setSubmitted(submitted);
+ }
+
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
+
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
+ */
+ public boolean isSelfRendered() {
+ return brige.isSelfRendered();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
+ */
+ public void setSelfRendered(boolean selfRendered) {
+ brige.setSelfRendered(selfRendered);
+ }
+
+ public void encodeAjax(FacesContext context) throws IOException {
+ String rendererType = getRendererType();
+ if (rendererType != null) {
+ ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
+ this);
+ }
+
+ }
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxStatus.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,379 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.Serializable;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.message.Messages;
+
+
+/**
+ *
+ * Component for create request state status area.
+ * can create 2 output text areas ( <span> ) with different text and
styles.
+ * if defined "start" or/and "stop" facets, it's use as conttent
+ * for different state.
+ * By default, "start" text/facet rendered with display = none style.
+ * On client side, display style changed for elements on
+ * start-stop request.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:25 $
+ *
+ */
+public class UIAjaxStatus extends UIComponentBase
+{
+
+ private static final String COMPONENT_FAMILY = "javax.faces.Output";
+ public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.AjaxStatus";
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * id of form for wich status will displayed
+ */
+ private String _for = null;
+
+ /**
+ *
+ * @param new value of id of form for wich status will displayed to set
+ */
+ public void setFor(String _for)
+ {
+ this._for = _for;
+ }
+
+ /**
+ * @return value or result of valueBinding of id of form for wich status will
displayed
+ *
+ */
+ public String getFor()
+ {
+ return (String) getValueOrBinding(_for, "for");
+ }
+
+ /**
+ * Text to output on start request
+ */
+ private String _startText = null;
+
+ /**
+ * setter method for property
+ * @param new value of Text to output on start request to set
+ */
+ public void setStartText(String startText)
+ {
+ this._startText = startText;
+ }
+
+ /**
+ * @return value or result of valueBinding of Text to output on start request
+ */
+ public String getStartText()
+ {
+ return (String) getValueOrBinding(_startText, "startText");
+ }
+
+ /**
+ * Text to display on complete request
+ */
+ private String _stopText = null;
+
+ /**
+ * setter method for property
+ * @param new value of Text to display on complete request to set
+ */
+ public void setStopText(String stopText)
+ {
+ this._stopText = stopText;
+ }
+
+ /**
+ * @return value or result of valueBinding of Text to display on complete request
+ */
+ public String getStopText()
+ {
+ return (String) getValueOrBinding(_stopText, "stopText");
+ }
+ /**
+ * Style for display on start request
+ */
+ private String _startStyle = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style for display on start request to set
+ */
+ public void setStartStyle(String startStyle)
+ {
+ this._startStyle = startStyle;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style for display on start request
+ */
+ public String getStartStyle()
+ {
+ return (String) getValueOrBinding(_startStyle, "startStyle");
+ }
+ /**
+ * Style for displaying on complete
+ */
+ private String _stopStyle = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style for displaying on complete to set
+ */
+ public void setStopStyle(String stopStyle)
+ {
+ this._stopStyle = stopStyle;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style for displaying on complete
+ */
+ public String getStopStyle()
+ {
+ return (String) getValueOrBinding(_stopStyle, "stopStyle");
+ }
+ /**
+ * Style class for display on request
+ */
+ private String _startStyleClass = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style class for display on request to set
+ */
+ public void setStartStyleClass(String startStyleClass)
+ {
+ this._startStyleClass = startStyleClass;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style class for display on request
+ */
+ public String getStartStyleClass()
+ {
+ return (String) getValueOrBinding(_startStyleClass,
"startStyleClass");
+ }
+ /**
+ * Style class for display on complete request
+ */
+ private String _stopStyleClass = null;
+
+ /**
+ * setter method for property
+ * @param new value of Style class for display on complete request to set
+ */
+ public void setStopStyleClass(String stopStyleClass)
+ {
+ this._stopStyleClass = stopStyleClass;
+ }
+
+
+ /**
+ * Force id to render in Html as is
+ */
+ private boolean _forceId = false;
+ private boolean _forceIdSet = false;
+
+ /**
+ * setter method for property
+ * @param new value of Force id to render in Html as is to set
+ */
+ public void setForceId(boolean forceId)
+ {
+ this._forceId = forceId;
+ this._forceIdSet = true;
+ }
+
+ /**
+ * @return value or result of valueBinding of Force id to render in Html as is
+ */
+ public boolean isForceId()
+ {
+ return isValueOrBinding(_forceId, _forceIdSet, "forceId");
+ }
+
+
+
+
+ private String _clientId = null;
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#getClientId(javax.faces.context.FacesContext)
+ */
+ public String getClientId(FacesContext context) {
+ if (null == _clientId) {
+ String forValue = getFor();
+ UIComponent container;
+ if (null != forValue) {
+ container = findComponent(forValue);
+ // 'for' attribute must be pointed to real container in view tree
+ if (null == container || !(container instanceof AjaxContainer)) {
+ throw new FacesException(
+ Messages.getMessage(Messages.FOR_TARGETS_NO_AJAX_CONTAINER, getId()));
+ }
+ _clientId = container.getClientId(context) + ":status";
+
+ } else if (isForceId()) {
+ _clientId = getRenderer(context).convertClientId(context,
+ this.getId());
+ } else if (null !=(container = (UIComponent)
AjaxRendererUtils.findAjaxContainer(context,this))) {
+ _clientId = container.getClientId(context) + ":status";
+ } else {
+ _clientId = super.getClientId(context);
+ }
+ }
+ return _clientId;
+ }
+
+
+ /* (non-Javadoc)
+ * reset clientId for calculate
+ * @see javax.faces.component.UIComponentBase#setId(java.lang.String)
+ */
+ public void setId(String arg0) {
+ super.setId(arg0);
+ _clientId = null;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state)
+ {
+ State myState = (State) state;
+ _for = myState._for;
+ _startText = myState._startText;
+ _stopText = myState._stopText;
+ _startStyle = myState._startStyle;
+ _stopStyle = myState._stopStyle;
+ _startStyleClass = myState._startStyleClass;
+ _stopStyleClass = myState._stopStyleClass;
+ _forceId = myState._forceId;
+ _forceIdSet = myState._forceIdSet;
+ super.restoreState(context, myState.superState);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context)
+ {
+ State state = new State();
+ state._for = _for;
+ state._startText = _startText;
+ state._stopText = _stopText;
+ state._startStyle = _startStyle;
+ state._stopStyle = _stopStyle;
+ state._startStyleClass = _startStyleClass;
+ state._stopStyleClass = _stopStyleClass;
+ state._forceId = _forceId;
+ state._forceIdSet = _forceIdSet;
+ state.superState = super.saveState(context);
+ return state;
+ }
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:25 $
+ * Memento pattern state class for save-restore component.
+ */
+ public static class State implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 317266574102385358L;
+ Object superState;
+ String _for;
+ String _startText;
+ String _stopText;
+ String _startStyle;
+ String _stopStyle;
+ String _startStyleClass;
+ String _stopStyleClass;
+ boolean _forceIdSet;
+ boolean _forceId;
+ }
+
+ /**
+ * @return value or result of valueBinding of Style class for display on complete
request
+ */
+ public String getStopStyleClass()
+ {
+ return (String) getValueOrBinding(_stopStyleClass, "stopStyleClass");
+ }
+
+ /**
+ * @param field - value of field to get.
+ * @param name - name of field, to get from ValueBinding
+ * @return field or value of binding expression.
+ */
+ private Object getValueOrBinding(Object field, String name){
+ if( null != field){
+ return field;
+ }
+ ValueBinding vb = getValueBinding(name);
+ if (null != vb) {
+ return vb.getValue(getFacesContext());
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * @param field - value of field to get.
+ * @param name - name of field, to get from ValueBinding
+ * @return boolean value, based on field or valuebinding.
+ */
+ private boolean isValueOrBinding(boolean field, boolean fieldSet, String name){
+ if( fieldSet ){
+ return field;
+ }
+ ValueBinding vb = getValueBinding(name);
+ if (null != vb) {
+ return ((Boolean)vb.getValue(getFacesContext())).booleanValue();
+ } else {
+ return false;
+ }
+
+ }
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,233 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.Serializable;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxSupport;
+import org.ajax4jsf.framework.ajax.EventValueBinding;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Component for append ajax functions to any control component.
+ * Append action functionality to non-action control,
+ * setup javascript events for parent component,
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:52 $
+ *
+ */
+public abstract class UIAjaxSupport extends AjaxActionComponent implements AjaxSupport
+{
+
+ //~ Static fields/initializers ---------------------------------------------
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Support";
+ public static final String COMPONENT_FAMILY = "javax.faces.Command";
+ public static final String DEFAULT_RENDERER_TYPE =
"org.ajax4jsf.components.AjaxSupportRenderer";
+ public static final String AJAX_SUPPORT_SET =
"com.exadel.components.ajax.support.";
+ private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
+
+ /**
+ * Name of JavaScript function, called before submit Ajax request
+ * description
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getOnsubmit();
+
+ /**
+ * @param newOnsubmit the value to set
+ */
+ public abstract void setOnsubmit(String newOnsubmit);
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String,
javax.faces.el.ValueBinding)
+ */
+ public void setValueBinding(String arg0, ValueBinding arg1) {
+ // var - not allowed name. must be literal.
+ if("var".equals(arg0)){
+ throw new FacesException(
+ Messages.getMessage(Messages.VAR_MUST_BE_LITERAL, getClientId(getFacesContext())));
+ }
+ if("event".equals(arg0)){
+ throw new FacesException(
+ Messages.getMessage(Messages.EVENT_MUST_BE_LITERAL,
getClientId(getFacesContext())));
+ }
+ super.setValueBinding(arg0, arg1);
+ }
+
+ /**
+ * Create Special <code>ValueBinding</code> for build JavaScrept
+ * event code in parent component from this.
+ * @return <code>EventValueBinding</code> based on properties of current
component
+ */
+ private ValueBinding getEventValueBinding()
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT, getId()));
+ }
+ return new EventValueBinding(this);
+ }
+
+ /**
+ * @return JavaScript eventString. Rebuild on every call, since
+ * can be in loop ( as in dataTable ) with different parameters.
+ */
+ public String getEventString()
+ {
+ StringBuffer buildOnEvent = new StringBuffer();
+ String onsubmit = getOnsubmit();
+ // Insert script to call before submit ajax request.
+ if (null != onsubmit) {
+ buildOnEvent.append(onsubmit).append(";");
+ }
+ // Due to JSF RI 1.1 bug, clear cached clientId
+ setId(getId());
+ buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(),
+ getEvent()));
+ String script = buildOnEvent.toString();
+ return script;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
+ */
+ public void decode(FacesContext context) {
+ // Due to JSF RI 1.1 bug, clear cached clientId
+ setId(getId());
+ super.decode(context);
+ }
+
+ /**
+ * After nornal setting <code>parent</code> property in case of
+ * created component set Ajax properties for parent.
+ * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
+ */
+ public void setParent(UIComponent parent)
+ {
+ super.setParent(parent);
+ if (null != parent && parent.getFamily() != null ) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
parent.getClass().getName()));
+ }
+ // TODO If this comopnent configured, set properties for parent component.
+ // NEW created component have parent, restored view - null in My faces.
+ // and SUN RI not call at restore saved view.
+ // In other case - set in restoreState method.
+ // if (parent.getParent() != null)
+ {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
+ }
+ setParentProperties(parent);
+
+ }
+ }
+ }
+
+ public void setParentProperties(UIComponent parent) {
+ ValueBinding valueBinding;
+// Map parentAttributes = parent.getAttributes();
+/* if (parent instanceof ActionSource && null == getEvent())
+ {
+ log.debug("Set properties for parent as ActionSource");
+ // Translate AJAX properties to parent component.
+ if (_reRender != null)
+ {
+ parentAttributes
+ .put(AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
+ _reRender);
+ }
+ else if ((valueBinding = getValueBinding("reRender")) != null)
+ {
+ parent.setValueBinding(
+ AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
+ valueBinding);
+ }
+ if (_oncomplete != null)
+ {
+ parentAttributes
+ .put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
+ _oncomplete);
+ }
+ else if ((valueBinding = getValueBinding("oncomplete")) != null)
+ {
+ parent.setValueBinding(
+ AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
+ valueBinding);
+ }
+ if (_status != null)
+ {
+ parentAttributes.put(AjaxRendererUtils.STATUS_ATTR_NAME,
+ _status);
+ }
+ else if ((valueBinding = getValueBinding("status")) != null)
+ {
+ parent.setValueBinding(AjaxRendererUtils.STATUS_ATTR_NAME,
+ valueBinding);
+ }
+ if (_limitToListSet)
+ {
+ parentAttributes.put(
+ AjaxRendererUtils.LIMITTOLIST_ATTR_NAME, Boolean
+ .valueOf(_limitToList));
+ }
+ else if ((valueBinding = getValueBinding("limitToList")) != null)
+ {
+ parent.setValueBinding(
+ AjaxRendererUtils.LIMITTOLIST_ATTR_NAME,
+ valueBinding);
+ }
+ // Add Listener for all supported types.
+ AjaxRegionListener listener = new AjaxRegionListener();
+ ((ActionSource) parent).addActionListener(listener);
+ }
+ else*/ if (null != getEvent())
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(Messages.getMessage(Messages.SET_VALUE_BINDING_FOR_EVENT,
getEvent()));
+ }
+ // for non action/data components, or for non-default events - build listener
for this instance.
+ valueBinding = getEventValueBinding();
+ // test for valid event attribute name.
+ // TODO - test for compability with concrete element.
+ parent.setValueBinding(getEvent(), valueBinding);
+ }
+
+ }
+
+ protected UIComponent getSingleComponent() {
+ return getParent();
+ }
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIInclude.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIInclude.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIInclude.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIInclude.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,304 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.Serializable;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxOutput;
+import org.ajax4jsf.framework.ajax.ViewIdHolder;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UIInclude extends UIComponentBase implements
+ ViewIdHolder, NamingContainer, AjaxOutput {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Include";
+
+ public static final String LAYOUT_NONE ="none";
+
+ public static final String LAYOUT_BLOCK ="block";
+ public static final String LAYOUT_INLINE ="inline";
+
+ private boolean wasNavigation = false;
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.ViewIdHolder#skipNavigation(java.lang.String)
+ */
+ public boolean skipNavigation(String ViewId) {
+ wasNavigation = true;
+ return true;
+ }
+
+ private String _viewId = null;
+
+ /*
+ * viewId for included page. Setter for viewId @param viewId - new value
+ */
+ public void setViewId(String __viewId) {
+ ValueBinding vb = getValueBinding("viewId");
+ FacesContext facesContext = getFacesContext();
+ if (null != vb && (!vb.isReadOnly(facesContext))) {
+ // Change value of viewId in backed bean, if possible.
+ vb.setValue(facesContext, __viewId);
+ } else {
+ this._viewId = __viewId;
+ }
+ }
+
+ /*
+ * viewId for included page. Getter for viewId @return viewId value from
+ * local variable or value bindings
+ */
+ public String getViewId() {
+ if (null != this._viewId) {
+ return this._viewId;
+ }
+ ValueBinding vb = getValueBinding("viewId");
+ if (null != vb) {
+ return (String) vb.getValue(getFacesContext());
+ } else {
+ return null;
+ }
+ }
+
+ private String _layout = null;
+
+ /**
+ * @return the layout
+ */
+ public String getLayout() {
+ if (null != this._layout) {
+ return this._layout;
+ }
+ ValueBinding vb = getValueBinding("layout");
+ if (null != vb) {
+ return (String) vb.getValue(getFacesContext());
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @param layout the layout to set
+ */
+ public void setLayout(String layout) {
+ _layout = layout;
+ }
+
+
+ public boolean isAjaxRendered() {
+ return (!LAYOUT_NONE.equals(getLayout())) && wasNavigation;
+ }
+
+ public void setAjaxRendered(boolean ajaxRendered) {
+ // unsupported
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof EventWrapper) {
+ FacesEvent wrapped = ((EventWrapper) event).getWrapped();
+ FacesContext context = getFacesContext();
+ ViewIdHolder holder = setupNavigation(context);
+ wrapped.getComponent().broadcast(wrapped);
+ restoreNavigation(context, holder);
+ } else {
+ super.broadcast(event);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(FacesContext context) {
+ wasNavigation = false;
+ ViewIdHolder holder = setupNavigation(context);
+ super.processDecodes(context);
+ restoreNavigation(context, holder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#processUpdates(javax.faces.context.FacesContext)
+ */
+ public void processUpdates(FacesContext context) {
+ ViewIdHolder holder = setupNavigation(context);
+ super.processUpdates(context);
+ restoreNavigation(context, holder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#processValidators(javax.faces.context.FacesContext)
+ */
+ public void processValidators(FacesContext context) {
+ ViewIdHolder holder = setupNavigation(context);
+ super.processValidators(context);
+ restoreNavigation(context, holder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ EventWrapper wrapper = new EventWrapper(this, event);
+ super.queueEvent(wrapper);
+ }
+
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ Object[] componentState = (Object[]) state;
+ super.restoreState(context, componentState[0]);
+ this._viewId = (String) componentState[1];
+ this._layout = (String) componentState[2];
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] componentState = new Object[3];
+ componentState[0] = super.saveState(context);
+ componentState[1] = _viewId;
+ componentState[2] = _layout;
+ return componentState;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ private ViewIdHolder setupNavigation(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ViewIdHolder viewIdHolder = ajaxContext.getViewIdHolder();
+ ajaxContext.setViewIdHolder(this);
+ return viewIdHolder;
+ }
+
+ private void restoreNavigation(FacesContext context, ViewIdHolder viewIdHolder) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.setViewIdHolder(viewIdHolder);
+// if (wasNavigation) {
+// // Clear children to avoid have different components with same id
+// getChildren().clear();
+// }
+ }
+
+ private static class EventWrapper extends FacesEvent {
+
+ private FacesEvent wrapped;
+
+ public EventWrapper(UIComponent component, FacesEvent wrapped) {
+ super(component);
+ this.wrapped = wrapped;
+ }
+
+ /**
+ * @return
+ * @see javax.faces.event.FacesEvent#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return wrapped.getPhaseId();
+ }
+
+ /**
+ * @param listener
+ * @return
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return wrapped.isAppropriateListener(listener);
+ }
+
+ /**
+ * @param listener
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ wrapped.processListener(listener);
+ }
+
+ /**
+ *
+ * @see javax.faces.event.FacesEvent#queue()
+ */
+ public void queue() {
+ wrapped.queue();
+ }
+
+ /**
+ * @param phaseId
+ * @see javax.faces.event.FacesEvent#setPhaseId(javax.faces.event.PhaseId)
+ */
+ public void setPhaseId(PhaseId phaseId) {
+ wrapped.setPhaseId(phaseId);
+ }
+
+ /**
+ * @return the wrapped
+ */
+ public FacesEvent getWrapped() {
+ return wrapped;
+ }
+ }
+
+ /**
+ * @return the wasNavigation
+ */
+ public boolean isWasNavigation() {
+ return wasNavigation;
+ }
+
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,127 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UILoadBundle extends UIComponentBase {
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Bundle";
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Bundle";
+
+ private static final Log _log = LogFactory.getLog(UILoadBundle.class);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FAMILY;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
+ */
+ public void encodeBegin(FacesContext context) throws IOException {
+ loadBundle(context);
+
+ }
+
+ public void decode(FacesContext context) {
+ loadBundle(context);
+ }
+ /**
+ * @param context
+ */
+ public void loadBundle(FacesContext context) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ Locale locale = viewRoot.getLocale();
+ if (locale == null) {
+ locale = context.getApplication().getDefaultLocale();
+ }
+
+ ResourceBundle bundle;
+ try {
+ bundle = ResourceBundle.getBundle(getBasename(), locale, Thread
+ .currentThread().getContextClassLoader());
+ } catch (MissingResourceException e) {
+ _log.error(Messages.getMessage(Messages.COULD_NOT_LOAD_RESOURCE_BUNDLE,
getBasename()));
+ return;
+ }
+
+ context.getExternalContext().getRequestMap().put(getVar(),
+ new ResourceBundleMap(bundle));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getRendererType()
+ */
+ public String getRendererType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @return Returns the basename.
+ */
+ public abstract String getBasename();
+
+ /**
+ * @param basename
+ * The basename to set.
+ */
+ public abstract void setBasename(String basename);
+
+ /**
+ * @return Returns the var.
+ */
+ public abstract String getVar();
+
+ /**
+ * @param var
+ * The var to set.
+ */
+ public abstract void setVar(String var);
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPoll.java (from rev
1388, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPoll.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPoll.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPoll.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,76 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+
+/**
+ * Component for periodically call AJAX events on server ( poll actions )
+ * @author shura
+ *
+ */
+public abstract class UIPoll extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Poll";
+
+
+ private transient boolean _submitted = false;
+
+ /**
+ * @return the submitted
+ */
+ public boolean isSubmitted() {
+ return _submitted;
+ }
+
+
+ /**
+ * @param submitted the submitted to set
+ */
+ public void setSubmitted(boolean submitted) {
+ _submitted = submitted;
+ }
+
+ /**
+ * @return time in mc for polling interval.
+ */
+ public abstract int getInterval();
+
+ /**
+ * @param interval time in mc for polling interval.
+ */
+ public abstract void setInterval(int interval);
+
+ public abstract boolean isEnabled();
+
+ public abstract void setEnabled(boolean enable);
+
+ protected void setupReRender(FacesContext facesContext) {
+ super.setupReRender(facesContext);
+ AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(this);
+ }
+
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPortlet.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPortlet.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPortlet.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPortlet.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.ajax4jsf.ajax;
+
+import java.lang.reflect.Method;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class UIPortlet extends UIComponentBase implements NamingContainer {
+
+ private static final Log _log = LogFactory.getLog(UIPortlet.class);
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Portlet";
+
+
+ /**
+ * <p>The standard component family for this component.</p>
+ */
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Portlet";
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FAMILY;
+ }
+
+ private String portletId = null;
+
+ // ----------------------------------------------------- UIComponent Methods
+ public String getClientId(FacesContext context) {
+ if (portletId == null) {
+ Object response = context.getExternalContext().getResponse();
+ Class portletResponseClass = response.getClass();
+ // Class.forName is used instead of instanceof to account for the case
+ // where the porletPage tag is used in a webapp and portlet.jar is not
+ // in classpath. In that scenario it will prevent ClassNotFoundException.
+ try {
+ Method method = portletResponseClass.getMethod("getNamespace", new
Class[]{});
+ portletId = (String) method.invoke(response, new Object[]{});
+ } catch (Exception e) {
+ if(_log.isDebugEnabled()){
+ _log.debug("Response is not a portlet RenderResponse");
+ }
+ }
+ if(null == portletId){
+ return super.getClientId(context);
+ }
+ }
+ return portletId;
+ }
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPush.java (from rev
1388, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIPush.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPush.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIPush.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,111 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.IOException;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.servlet.http.HttpSession;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.xmlfilter.PollEventsManager;
+
+/**
+ * Component for periodically call AJAX events on server ( poll actions )
+ * @author shura
+ *
+ */
+public abstract class UIPush extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Push";
+
+
+ private transient boolean _submitted = false;
+
+ /**
+ * @return the submitted
+ */
+ public boolean isSubmitted() {
+ return _submitted;
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException {
+ MethodBinding producer = getEventProducer();
+ // Subscribe events producer to push status listener.
+ if(null != producer){
+ producer.invoke(context, new Object[]{getListener(context)});
+ }
+ super.encodeBegin(context);
+ }
+
+ private PushEventsCounter getListener(FacesContext context){
+ PollEventsManager eventsManeger = (PollEventsManager)
context.getExternalContext().getApplicationMap().get(PollEventsManager.EVENTS_MANAGER_KEY);
+ return eventsManeger.getListener(getListenerId(context));
+ }
+
+ public String getListenerId(FacesContext context){
+ Object session = context.getExternalContext().getSession(false);
+ StringBuffer id = new StringBuffer();
+ if(null != session && session instanceof HttpSession){
+ HttpSession httpSession = (HttpSession) session;
+ id.append(httpSession.getId());
+ }
+ id.append(context.getViewRoot().getViewId());
+ id.append(NamingContainer.SEPARATOR_CHAR);
+ id.append(getClientId(context));
+ return id.toString();
+ }
+ /**
+ * @param submitted the submitted to set
+ */
+ public void setSubmitted(boolean submitted) {
+ _submitted = submitted;
+ }
+
+ public abstract MethodBinding getEventProducer();
+
+ public abstract void setEventProducer(MethodBinding producer);
+ /**
+ * @return time in mc for polling interval.
+ */
+ public abstract int getInterval();
+
+ /**
+ * @param interval time in mc for polling interval.
+ */
+ public abstract void setInterval(int interval);
+
+ public abstract boolean isEnabled();
+
+ public abstract void setEnabled(boolean enable);
+
+ protected void setupReRender(FacesContext facesContext) {
+ super.setupReRender(facesContext);
+// AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(this);
+ //getListener(facesContext).processed();
+ }
+
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIResource.java (from
rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UIResource.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIResource.java
(rev 0)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UIResource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * JSF component class
+ *
+ */
+public abstract class UIResource extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Resource";
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Resource";
+
+ /**
+ * Get name of script to load
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract Object getSrc();
+
+ /**
+ * @param newSrc the value to set
+ */
+ public abstract void setSrc(Object newSrc);
+
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UIRepeat.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,136 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.sql.ResultSet;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.ArrayDataModel;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.ResultDataModel;
+import javax.faces.model.ResultSetDataModel;
+import javax.faces.model.ScalarDataModel;
+import javax.servlet.jsp.jstl.sql.Result;
+/**
+ * @author shura
+ *
+ */
+public class UIRepeat extends UIDataAdaptor {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createComponentState()
+ */
+ protected DataComponentState createComponentState() {
+ // Create component state based on this instance.
+ return new DataComponentState(){
+
+ public Range getRange() {
+ return new SequenceRange(getFirst(),getRows());
+ }
+
+ public boolean isTransient() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void restoreState(FacesContext arg0, Object arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object saveState(FacesContext arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setTransient(boolean arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createDataModel()
+ */
+ protected ExtendedDataModel createDataModel() {
+ return (ExtendedDataModel) getDataModel();
+ }
+
+ protected DataModel getDataModel(){
+ // Synthesize a DataModel around our current value if possible
+ // TODO - for jsf 1.2 use method from superclass ?
+ Object current = getValue();
+ DataModel model;
+ if (current == null) {
+ model = new SequenceDataModel(new ListDataModel(Collections.EMPTY_LIST));
+ } else if (current instanceof ExtendedDataModel) {
+ model = (DataModel) current;
+ } else if (current instanceof DataModel) {
+ model = new SequenceDataModel((DataModel) current);
+ } else if (current instanceof List) {
+ model = new SequenceDataModel(new ListDataModel((List) current));
+ } else if (Object[].class.isAssignableFrom(current.getClass())) {
+ model = new SequenceDataModel(new ArrayDataModel((Object[]) current));
+ } else if (current instanceof ResultSet) {
+ model = new SequenceDataModel(new ResultSetDataModel((ResultSet) current));
+ } else if (current instanceof Result) {
+ model = new SequenceDataModel(new ResultDataModel((Result) current));
+ } else {
+ model = new SequenceDataModel(new ScalarDataModel(current));
+ }
+ return (model);
+ }
+
+ protected void setDataModel(DataModel model) {
+ ExtendedDataModel iterableModel;
+ if( null == model){
+ iterableModel = null;
+ } else if (model instanceof ExtendedDataModel) {
+ iterableModel = (ExtendedDataModel) model;
+ } else {
+ iterableModel = new SequenceDataModel(model);
+ }
+ setExtendedDataModel(iterableModel);
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#dataChildren()
+ */
+ protected Iterator dataChildren() {
+ // TODO Auto-generated method stub
+ return getChildren().iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#fixedChildren()
+ */
+ protected Iterator fixedChildren() {
+ // TODO Auto-generated method stub
+ return getFacets().values().iterator();
+ }
+
+}
Copied: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/repeat/UISelector.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,114 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.repeat;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
+import org.apache.commons.beanutils.PropertyUtils;
+
+/**
+ * Base class for component, performed AJAX encoding on selected values in
+ * iterable components ( UIData, trees etc )
+ *
+ * @author shura
+ *
+ */
+public abstract class UISelector extends UIComponentBase implements
+ AjaxDataEncoder {
+
+ private static final AjaxChildrenRenderer childrenRenderer = new AjaxChildrenRenderer()
{
+
+ protected Class getComponentClass() {
+ return UISelector.class;
+ }
+
+ };
+
+ /**
+ * Name of serRow ( or simple ) method for setup current value in iterable
+ * component
+ *
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getIterationProperty();
+
+ /**
+ * @param newSelectMethod
+ * the value to set
+ */
+ public abstract void setIterationProperty(String newSelectMethod);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
+ * java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxChild(FacesContext context, String path, Set ids,
+ Set renderedAreas) throws IOException {
+ if (getChildCount() != 1) {
+ throw new FacesException(
+ "Selector component must have one, and only one, child");
+ }
+ UIComponent child = (UIComponent) getChildren().get(0);
+ Set ajaxKeys = getAjaxKeys();
+ if (null != ajaxKeys) {
+ String iterationProperty = getIterationProperty();
+ try {
+ Object savedKey = PropertyUtils.getProperty(child,
+ iterationProperty);
+ for (Iterator iter = ajaxKeys.iterator(); iter.hasNext();) {
+ Object key = (Object) iter.next();
+ PropertyUtils.setProperty(child, iterationProperty, key);
+ if (true) {
+ childrenRenderer.encodeAjaxChildren(context, this, path,
+ ids, renderedAreas);
+ }
+
+ }
+ PropertyUtils.setProperty(child, iterationProperty, savedKey);
+
+ } catch (IllegalAccessException e) {
+ throw new FacesException(
+ "Illegal access to iteration selection property "+iterationProperty+"
on component "+child.getClientId(context),e);
+ } catch (InvocationTargetException e) {
+ throw new FacesException(
+ "Error in iteration selection property "+iterationProperty+" on
component "+child.getClientId(context),e.getCause());
+ } catch (NoSuchMethodException e) {
+ throw new FacesException(
+ "No iteration selection property "+iterationProperty+" on component
"+child.getClientId(context),e);
+ }
+ }
+
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,121 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.resource;
+
+import java.util.Date;
+
+import javax.faces.el.MethodBinding;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:13 $
+ *
+ */
+public interface ResourceComponent {
+
+ /**
+ * Get Mime-type for target .
+ * @return
+ */
+ public abstract String getMimeType();
+
+ /**
+ * Set Mime-type for target .
+ * @param newvalue
+ */
+ public abstract void setMimeType(String newvalue);
+
+
+ /**
+ * Get Last modified date for target .
+ * @return
+ */
+ public abstract Date getLastModified();
+
+ /**
+ * Set Last modified for target .
+ * @param newvalue
+ */
+ public abstract void setLastModified(Date newvalue);
+
+
+ /**
+ * Get Expiration time for target .
+ * @return
+ */
+ public abstract Date getExpires();
+
+ /**
+ * Set Expiration time for target .
+ * @param newvalue
+ */
+ public abstract void setExpires(Date newvalue);
+
+
+ /**
+ * Get caching flag for resource.
+ * @return
+ */
+ public abstract boolean isCacheable();
+
+ /**
+ * Set caching flag for resource.
+ * @param newvalue
+ */
+ public abstract void setCacheable(boolean newvalue);
+
+ /**
+ * Get session-avare flag for resource.
+ * @return true if resource depend of client session. If false, no JSESSIONID encoded in
URI
+ */
+ public abstract boolean isSession();
+
+ /**
+ * Set session-avare flag for resource.
+ * @param newvalue
+ */
+ public abstract void setSession(boolean newvalue);
+
+ /**
+ * Get Data object, encoded in uri and passed to "send" method for generate
resource content.
+ * @return
+ */
+ public abstract Object getValue();
+
+ /**
+ * Set Data object, encoded in uri and passed to "send" method for generate
resource content.
+ * @param newvalue
+ */
+ public abstract void setValue(Object newvalue);
+
+ /**
+ * Get El binding to method in user bean to send resource. Method will called with two
parameters - restored data object and servlet output stream.
+ * @return
+ */
+ public abstract MethodBinding getCreateContent();
+
+ /**
+ * Set El binding to method in user bean to send resource. Method will called with two
parameters - restored data object and servlet output stream.
+ * @param newvalue
+ */
+ public abstract void setCreateContent(MethodBinding newvalue);
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/UIMediaOutput.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.resource;
+
+import javax.faces.component.UIOutput;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UIMediaOutput extends UIOutput implements ResourceComponent {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.MMedia";
+
+ /**
+ * Get URI attribute for resource ( src for images, href for links etc ).
+ * @return
+ */
+ public abstract String getUriAttribute();
+
+ /**
+ * Set URI attribute for resource ( src for images, href for links etc ).
+ * @param newvalue
+ */
+ public abstract void setUriAttribute(String newvalue);
+
+ /**
+ * Get Element name for rendering ( imj , a , object, applet ).
+ * @return
+ */
+ public abstract String getElement();
+
+ /**
+ * Set Element name for rendering ( imj , a , object, applet ).
+ * @param newvalue
+ */
+ public abstract void setElement(String newvalue);
+
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,137 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.ajax.resource.ResourceComponent;
+
+/**
+ * @author shura
+ *
+ */
+public class UserResource extends InternetResourceBase {
+
+ private String contentType;
+ /**
+ *
+ */
+ public UserResource(boolean cacheable, boolean session, String mime) {
+ super();
+ setCacheable(cacheable);
+ setSessionAware(session);
+ setContentType(mime);
+ }
+ /**
+ * @return Returns the contentType.
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return contentType;
+ }
+ /**
+ * @param contentType The contentType to set.
+ */
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public Object getDataToStore(FacesContext context, Object data) {
+ UriData dataToStore = null;
+ if (data instanceof ResourceComponent) {
+ ResourceComponent resource = (ResourceComponent) data;
+ dataToStore = new UriData();
+ dataToStore.value = resource.getValue();
+ dataToStore.createContent =
UIComponentBase.saveAttachedState(context,resource.getCreateContent());
+ if (data instanceof UIComponent) {
+ UIComponent component = (UIComponent) data;
+ ValueBinding expires = component.getValueBinding("expires");
+ if (null != expires) {
+ dataToStore.expires = UIComponentBase.saveAttachedState(context,expires);
+ }
+ ValueBinding lastModified = component.getValueBinding("lastModified");
+ if (null != lastModified) {
+ dataToStore.modified = UIComponentBase.saveAttachedState(context,lastModified);
+ }
+ }
+ }
+ return dataToStore;
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.resource.InternetResourceBase#send(org.ajax4jsf.framework.resource.ResourceContext)
+ */
+ public void send(ResourceContext context) throws IOException {
+ UriData data = (UriData) restoreData(context);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != data && null != facesContext ) {
+ // Send headers
+ if(data.expires != null){
+ ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.expires);
+ Date expires = (Date) binding.getValue(facesContext);
+ context.setDateHeader("Expires",expires.getTime());
+ }
+ if(data.modified != null){
+ ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.modified);
+ Date modified = (Date) binding.getValue(facesContext);
+ context.setDateHeader("Last-Modified",modified.getTime());
+ }
+ // Send content
+ OutputStream out = context.getOutputStream();
+ MethodBinding send = (MethodBinding)
UIComponentBase.restoreAttachedState(facesContext,data.createContent);
+ send.invoke(facesContext,new Object[]{out,data.value});
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.InternetResourceBase#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public static class UriData implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1258987L;
+
+ private Object value;
+
+ private Object createContent;
+
+ private Object expires;
+
+ private Object modified;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,115 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
+import javax.faces.component.html.HtmlCommandButton;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
+ *
+ */
+public abstract class AjaxCommandRendererBase extends AjaxComponentRendererBase {
+
+ protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
+
+ //super.decode must not be called, because value is handled here
+ if ( isSubmitted(facesContext, uiComponent))
+ {
+ Map attributes = uiComponent.getAttributes();
+ Object type = attributes.get("type");
+ if (! "reset".equalsIgnoreCase((String)type) ) {
+ ActionEvent event;
+ event = new ActionEvent(uiComponent);
+ uiComponent.queueEvent(event);
+ }
+ uiComponent.queueEvent( new AjaxEvent(uiComponent));
+//
org.ajax4jsf.framework.ajax.AjaxRegionListener.addRegionsFromComponent(uiComponent,
facesContext);
+ }
+ }
+
+ public String getOnClick(FacesContext context, UIComponent component) {
+ StringBuffer onClick;
+ if ( !getUtils().isBooleanAttribute(component,"disabled")) {
+ onClick = AjaxRendererUtils.buildOnClick(component, context);
+ if (!"reset".equals(component.getAttributes().get("type"))) {
+ onClick.append(";return false;");
+ }
+ } else {
+ onClick = new StringBuffer("return false;");
+ }
+ return onClick.toString();
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ renderChildren(context, component);
+ }
+
+ public Object getValue(UIComponent uiComponent) {
+ if (uiComponent instanceof ValueHolder) {
+ return ((ValueHolder) uiComponent).getValue();
+ }
+ return uiComponent.getAttributes().get("value");
+ }
+
+ public String getType(UIComponent uiComponent) {
+ String type;
+ if (uiComponent instanceof HtmlCommandButton) {
+ type = ((HtmlCommandButton) uiComponent).getType();
+ } else {
+ type = (String) uiComponent.getAttributes().get("type");
+ }
+ if (type == null) {
+ type = "button";
+ }
+ return type;
+ }
+
+
+ protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
+ // Componet accept only ajax requests.
+ if ( !AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(facesContext)) {
+ return false;
+ }
+ if(getUtils().isBooleanAttribute(uiComponent,"disabled")){
+ return false;
+ }
+ String clientId = uiComponent.getClientId(facesContext);
+ Map paramMap = facesContext.getExternalContext().getRequestParameterMap();
+ Object value = paramMap.get( clientId );
+ return null != value;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.UIAjaxFunction;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+import org.ajax4jsf.framework.util.javascript.ScriptUtils;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getFunction(FacesContext context, UIAjaxFunction component) {
+ StringBuffer script = new StringBuffer();
+ JSFunctionDefinition func = new JSFunctionDefinition();
+ func.setName(component.getName());
+ // Create AJAX Submit function.
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
+ component, context,AjaxRendererUtils.AJAX_FUNCTION_NAME);
+ Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ Map parameters = (Map) options.get("parameters");
+ if (null == parameters) {
+ parameters = new HashMap();
+ options.put("parameters", parameters);
+ }
+ ajaxFunction.addParameter(JSReference.NULL);
+ ajaxFunction.addParameter(options);
+ // Fill parameters.
+ for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = (UIComponent) it.next();
+ if (child instanceof UIParameter) {
+ UIParameter parameter = ((UIParameter) child);
+ String name = parameter.getName();
+ func.addParameter(name);
+ // Put parameter name to AJAX.Submit parameter, with default value.
+ JSReference reference = new JSReference(name);
+ if (null != parameter.getValue()) {
+ reference = new JSReference(name + "||"
+ + ScriptUtils.toScript(parameters.get(name)));
+
+ }
+ // Replace parameter value to reference.
+ parameters.put(name, reference);
+ }
+ }
+ func.addToBody(ajaxFunction.toScript());
+ func.appendScript(script);
+ return script.toString();
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.util.LinkedHashSet;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.UIResource;
+import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
+import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.resource.InternetResource;
+
+/**
+ * @author shura
+ *
+ */
+public class LoadResourceRendererBase extends RendererBase implements
HeaderResourceProducer {
+
+ private static final String
SCRIPT_COMPONENT_FAMILY="org.ajax4jsf.LoadScript";
+ private static final String STYLE_COMPONENT_FAMILY="org.ajax4jsf.LoadStyle";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
+ UIResource resource = (UIResource) component;
+ if (SCRIPT_COMPONENT_FAMILY.equals(resource.getFamily())) {
+ return getResources(context, resource);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public LinkedHashSet getHeaderStyles(FacesContext context, UIComponent component) {
+ UIResource resource = (UIResource) component;
+ if (STYLE_COMPONENT_FAMILY.equals(resource.getFamily())) {
+ return getResources(context, resource);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ return UIResource.class;
+ }
+
+ private LinkedHashSet getResources(FacesContext context, UIResource resource) {
+ Object src = resource.getSrc();
+ if(null == src){
+ throw new FacesException("Source for resource is null for component
"+resource.getClientId(context));
+ }
+ LinkedHashSet set = new LinkedHashSet(1);
+ String uri ;
+ if(src instanceof InternetResource){
+ uri=((InternetResource)src).getUri(context, resource);
+ } else {
+ // Process as ordinary url, same as for h:graphicsImage.
+ uri=context.getApplication().getViewHandler().
+ getResourceURL(context, src.toString());
+ uri=context.getExternalContext().encodeResourceURL(uri);
+ }
+ set.add(uri);
+ return set;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,382 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIAjaxForm;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.resource.InternetResource;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxFormRenderer extends AjaxComponentRendererBase {
+
+ public static final String FORM_SUBMIT_FUNCTION_NAME = "_JSFFormSubmit";
+
+ public static final String FORM_CLEAR_FUNCTION_NAME =
"_clearJSFFormParameters";
+
+ private static final String FORM_HAS_COMMAND_LINK_ATTR =
"com.sun.faces.FORM_HAS_COMMAND_LINK_ATTR";
+
+ private static final String NO_COMMAND_LINK_FOUND_VALUE =
"com.sun.faces.NO_COMMAND_LINK_FOUND";
+
+ public static final String CONTENT_TYPE_IS_XHTML = "com.sun.faces"
+ + "ContentTypeIsXHTML";
+
+ public static final String HIDDEN_FIELD_SUFFIX = NamingContainer.SEPARATOR_CHAR
+ + UIViewRoot.UNIQUE_ID_PREFIX + "cl";
+
+ private static final String HIDDEN_COMMAND_INPUTS_SET_ATTR = UIForm.class
+ .getName()
+ + ".org.apache.myfaces.HIDDEN_COMMAND_INPUTS_SET";
+
+ private static final String MYFACES_HIDDEN_FIELD_SUFFIX =
NamingContainer.SEPARATOR_CHAR
+ + "_link_hidden_";
+
+ private InternetResource[] _scripts = { getResource("scripts/form.js") };
+
+ private static final String[] exclusions = { "onsubmit" };
+
+ public static final String AJAX_FORM_FUNCTION_NAME = "A4J.AJAX.SubmitForm";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doDecode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+ UIForm form = (UIForm) component;
+ boolean submitted = context.getExternalContext()
+ .getRequestParameterMap().containsKey(
+ component.getClientId(context));
+ form.setSubmitted(submitted);
+ if (component instanceof UIAjaxForm) {
+ UIAjaxForm ajaxForm = (UIAjaxForm) component;
+ if (submitted && ajaxForm.isAjaxSubmit()) {
+ component.queueEvent(new AjaxEvent(component));
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase#getScripts()
+ */
+ protected InternetResource[] getAdditionalScripts() {
+ // TODO Auto-generated method stub
+ return _scripts;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ String clientId = component.getClientId(context);
+ writer.startElement(HTML.FORM_ELEMENT, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
+ getUtils().encodeAttribute(context, component, "style");
+ getUtils().encodeAttribute(context, component, "class");
+ getUtils().encodePassThru(context, component);
+ context.getExternalContext().getRequestMap().put(
+ FORM_HAS_COMMAND_LINK_ATTR, clientId);
+ if (component instanceof UIAjaxForm) {
+ UIAjaxForm form = (UIAjaxForm) component;
+ if (form.isAjaxSubmit()) {
+ StringBuffer onSubmit = new StringBuffer("javascript:");
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
+ component, context,
+ AJAX_FORM_FUNCTION_NAME);
+ ajaxFunction.addParameter(AjaxRendererUtils.buildEventOptions(
+ context, component));
+ ajaxFunction.appendScript(onSubmit);
+ writer.writeURIAttribute("action", onSubmit, "action");
+ } else {
+ encodeSubmitAction(writer, context);
+ }
+ } else {
+ encodeSubmitAction(writer, context);
+ }
+ }
+
+ /**
+ * @param writer
+ * @param context
+ * @throws IOException
+ */
+ private void encodeSubmitAction(ResponseWriter writer, FacesContext context)
+ throws IOException {
+ String actionURL = getUtils().getActionUrl(context);
+ String encodedActionURL = context.getExternalContext().encodeActionURL(
+ actionURL);
+ writer.writeURIAttribute("action", encodedActionURL, "action");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ // Encode form submitting flag hidden field.
+ String clientId = component.getClientId(context);
+ renderHiddenInputField(writer, clientId, clientId);
+ renderHiddenInputField(writer, "autoScroll", null);
+ // MyFaces compability - render hidden field and Script.
+ // render hidden command inputs
+ Set hiddenFields = new HashSet();
+ hiddenFields.add(clientId + HIDDEN_FIELD_SUFFIX);
+ hiddenFields.add(clientId + MYFACES_HIDDEN_FIELD_SUFFIX);
+ Set set = (Set) component.getAttributes().get(
+ HIDDEN_COMMAND_INPUTS_SET_ATTR);
+ if (set != null) {
+ hiddenFields.addAll(set);
+ }
+ set = (Set) context.getExternalContext().getRequestMap().get(
+ getHiddenCommandInputsSetName(context, component));
+ if (set != null) {
+ hiddenFields.addAll(set);
+ }
+ renderHiddenCommandFormParams(writer, hiddenFields);
+ String target;
+ if (component instanceof HtmlForm) {
+ target = ((HtmlForm) component).getTarget();
+ } else {
+ target = (String) component.getAttributes().get(
+ HTML.target_ATTRIBUTE);
+ }
+ renderClearHiddenCommandFormParamsFunction(writer, clientId, hiddenFields, target);
+ // Script
+ if (component instanceof UIAjaxForm) {
+ UIAjaxForm form = (UIAjaxForm) component;
+ if (form.isAjaxSubmit()) {
+ renderAjaxFormSetupScript(writer, clientId);
+ }
+ }
+ // writeFormSubmitScript(context, writer);
+ getUtils().encodeEndForm(context, writer);
+ context.getExternalContext().getRequestMap().put(
+ FORM_HAS_COMMAND_LINK_ATTR, NO_COMMAND_LINK_FOUND_VALUE);
+ }
+
+ private static String getHiddenCommandInputsSetName(
+ FacesContext facesContext, UIComponent form) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(HIDDEN_COMMAND_INPUTS_SET_ATTR);
+ buf.append("_");
+ buf.append(form.getClientId(facesContext));
+ return buf.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIForm.class;
+ }
+
+ // For MyFaces compability - create hidden firlds and script. Code got from
+ // project to simulate same functionality.
+ public void renderHiddenCommandFormParams(ResponseWriter writer,
+ Set formParams) throws IOException {
+ for (Iterator it = formParams.iterator(); it.hasNext();) {
+ Object name = it.next();
+ renderHiddenInputField(writer, name, "");
+ }
+ }
+
+ public void renderHiddenInputField(ResponseWriter writer, Object name,
+ Object value) throws IOException {
+ writer.startElement(HTML.INPUT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, name, null);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, value != null?value:"", null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+
+ public void renderAjaxFormSetupScript(ResponseWriter writer, String formName) throws
IOException {
+ writer.startElement(HTML.SCRIPT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.writeText("A4J.setupForm('"+formName+"');", null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * Render the javascript function that is called on a click on a commandLink
+ * to clear the hidden inputs. This is necessary because on a browser back,
+ * each hidden input still has it's old value (browser cache!) and therefore
+ * a new submit would cause the according action once more!
+ *
+ * @param writer
+ * @param formName
+ * @param dummyFormParams
+ * @param formTarget
+ * @throws IOException
+ */
+ public void renderClearHiddenCommandFormParamsFunction(
+ ResponseWriter writer, String formName, Set dummyFormParams,
+ String formTarget) throws IOException {
+ // render the clear hidden inputs javascript function
+ String functionName = getClearHiddenCommandFormParamsFunctionName(formName);
+ writer.startElement(HTML.SCRIPT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+
+ // Using writeComment instead of write with <!-- tag
+ StringBuffer script = new StringBuffer();
+ script.append("function ");
+ script.append(functionName);
+ script.append("() {\n");
+ script.append(FORM_CLEAR_FUNCTION_NAME);
+ script.append("('");
+ script.append(formName);
+ script.append("','");
+ if (formTarget != null && formTarget.length() > 0) {
+ script.append(formTarget);
+ }
+ script.append("'");
+ if (dummyFormParams != null) {
+ script.append(",[");
+ for (Iterator it = dummyFormParams.iterator(); it.hasNext();) {
+ script.append('\'');
+ script.append((String) it.next());
+ script.append('\'');
+ if (it.hasNext()) {
+ script.append(',');
+ }
+ }
+ script.append("]");
+ }
+ script.append(");");
+ script.append("\n}");
+ script.append("\n");
+ script.append("function
").append("clearFormHiddenParams_").append(
+ getValidJavascriptName(formName));
+ script.append("(){").append(functionName).append("();}\n");
+ // MyFaces 1.1.5 clear form function name
+ script.append("function
").append("clearFormHiddenParams_").append(
+ formName.replace("-", "$_").replace(':', '_'));
+ script.append("(){").append(functionName).append("();}\n");
+ // Just to be sure we call this clear method on each load.
+ // Otherwise in the case, that someone submits a form by pressing Enter
+ // within a text input, the hidden inputs won't be cleared!
+ script.append(functionName);
+ script.append("();");
+
+ writer.writeText(script.toString(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * Prefixes the given String with "clear_" and removes special characters
+ *
+ * @param formName
+ * @return String
+ */
+ public String getClearHiddenCommandFormParamsFunctionName(String formName) {
+ return "clear_" + getValidJavascriptName(formName);
+ }
+
+ public String getValidJavascriptName(String s) {
+
+ StringBuffer buf = null;
+ for (int i = 0, len = s.length(); i < len; i++) {
+ char c = s.charAt(i);
+
+ if (Character.isLetterOrDigit(c)||c=='_' ) {
+ // allowed char
+ if (buf != null)
+ buf.append(c);
+ } else {
+ if (buf == null) {
+ buf = new StringBuffer(s.length() + 10);
+ buf.append(s.substring(0, i));
+ }
+
+ buf.append('_');
+ if (c < 16) {
+ // pad single hex digit values with '0' on the left
+ buf.append('0');
+ }
+
+ if (c < 128) {
+ // first 128 chars match their byte representation in UTF-8
+ buf.append(Integer.toHexString(c).toUpperCase());
+ } else {
+ byte[] bytes;
+ try {
+ bytes = Character.toString(c).getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+
+ for (int j = 0; j < bytes.length; j++) {
+ int intVal = bytes[j];
+ if (intVal < 0) {
+ // intVal will be >= 128
+ intVal = 256 + intVal;
+ } else if (intVal < 16) {
+ // pad single hex digit values with '0' on the left
+ buf.append('0');
+ }
+ buf.append(Integer.toHexString(intVal).toUpperCase());
+ }
+ }
+ }
+
+ }
+
+ return buf == null ? s : buf.toString();
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,97 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIInclude;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:25 $
+ *
+ */
+public class AjaxIncludeRenderer extends RendererBase {
+
+ private final String[] STYLE_ATTRIBUTES = new String[] { "style",
"class" };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIInclude.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ UIInclude panel = (UIInclude) component;
+ if (!UIInclude.LAYOUT_NONE.equals(panel.getLayout())) {
+ writer.startElement(getTag(panel), panel);
+ getUtils().encodeId(context, component);
+ getUtils().encodePassThru(context, component);
+ getUtils().encodeAttributesFromArray(context, component,
+ STYLE_ATTRIBUTES);
+
+ }
+ }
+
+ /**
+ * @param panel
+ * @return
+ */
+ private String getTag(UIInclude panel) {
+ // TODO Auto-generated method stub
+ return UIInclude.LAYOUT_BLOCK.equals(panel.getLayout()) ? HTML.DIV_ELEM
+ : HTML.SPAN_ELEM;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+ UIInclude panel = (UIInclude) component;
+ if (!UIInclude.LAYOUT_NONE.equals(panel.getLayout())) {
+ writer.endElement(getTag(panel));
+
+ }
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,148 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIAjaxOutputPanel;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:27 $
+ *
+ */
+public class AjaxOutputPanelRenderer extends RendererBase {
+
+ private final String[] STYLE_ATTRIBUTES = new
String[]{"style","class"};
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ //
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if ("none".equals(panel.getLayout())) {
+ if (component.getChildCount() > 0) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ boolean ajaxRequest = ajaxContext.isAjaxRequest();
+ Set ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
+ for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = (UIComponent) it.next();
+ String childId = child.getClientId(context);
+ if (child.isRendered()) {
+ renderChild(context, child);
+ } else {
+ // Render "dummy" span.
+ ResponseWriter out = context.getResponseWriter();
+ out.startElement(HTML.SPAN_ELEM,child);
+ out.writeAttribute(HTML.id_ATTRIBUTE,childId,HTML.id_ATTRIBUTE);
+ out.writeAttribute(HTML.style_ATTRIBUTE,"display:
none;","style");
+ out.endElement(HTML.SPAN_ELEM);
+ }
+ // register child as rendered
+ if(ajaxRequest && null != ajaxRenderedAreas) {
+ ajaxRenderedAreas.add(childId);
+ }
+ }
+ }
+
+ } else {
+ renderChildren(context,component);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIAjaxOutputPanel.class;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (!"none".equals(panel.getLayout())) {
+ writer.startElement(getTag(panel), panel);
+ getUtils().encodeId(context, component);
+ getUtils().encodePassThru(context, component);
+ getUtils().encodeAttributesFromArray(context,component,STYLE_ATTRIBUTES);
+ }
+ }
+
+ /**
+ * @param panel
+ * @return
+ */
+ private String getTag(UIAjaxOutputPanel panel) {
+ // TODO Auto-generated method stub
+ return "block".equals(panel.getLayout())?HTML.DIV_ELEM:HTML.SPAN_ELEM;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (!"none".equals(panel.getLayout())) {
+ writer.endElement(getTag(panel));
+ }
+ if (panel.isKeepTransient()) {
+ markNoTransient(component);
+ }
+ }
+
+ /**
+ * Set "transient" flag to false for component and all its children (
recursive ).
+ * @param component
+ */
+ private void markNoTransient(UIComponent component) {
+ for (Iterator iter = component.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent element = (UIComponent) iter.next();
+ markNoTransient(element);
+ element.setTransient(false);
+ }
+
+ }
+
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,228 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+
+/**
+ * @author shura
+ *
+ * Render full Html page for AJAX view. Facet "head" rendered in
<head> of
+ * page.
+ */
+public class AjaxPageRenderer extends AjaxContainerRenderer {
+
+ public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxPageRenderer";
+
+ private static final Map doctypes ;
+
+ static {
+ // Fill doctype, content-type and namespace map for different formats.
+ doctypes = new HashMap();
+ doctypes
+ .put(
+ "html-transitional",
+ new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n",
+ "text/html", null });
+ doctypes.put("html", new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n"
+ + "\"http://www.w3.org/TR/html4/strict.dtd\">\n",
+ "text/html", null });
+ doctypes.put("html-frameset", new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Frameset//EN\"\n"
+ + "\"http://www.w3.org/TR/html4/frameset.dtd\">\n",
+ "text/html", null });
+ doctypes
+ .put(
+ "xhtml",
+ new String[] {
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Strict//EN\"\n"
+ +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n",
+ "application/xhtml+xml",
+ "http://www.w3.org/1999/xhtml" });
+ doctypes
+ .put(
+ "xhtml-transitional",
+ new String[] {
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"\n"
+ +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n",
+ "application/xhtml+xml",
+ "http://www.w3.org/1999/xhtml" });
+ doctypes
+ .put(
+ "xhtml-frameset",
+ new String[] {
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Frameset//EN\"\n"
+ +
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n",
+ "application/xhtml+xml",
+ "http://www.w3.org/1999/xhtml" });
+ doctypes.put("html-3.2", new String[] {
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2
Final//EN\">\n",
+ "text/html", null });
+ }
+
+ // private PreparedTemplate pageStyles =
+ //
HtmlCompiler.compileResource("com/exadel/vcp/renderers/templates/ajax/page-styles.xml");
+ protected void preEncodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ // Scripts must be encoded in component, not before html element
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void doEncodeBegin(ResponseWriter out, FacesContext context,
+ UIComponent component) throws IOException {
+ AjaxContainer ajax = (AjaxContainer) component;
+ // ServletResponse response = (ServletResponse)
+ // context.getExternalContext().getResponse();
+ Map attributes = component.getAttributes();
+ String format = (String) attributes.get("format");
+ String contentType = null;
+ String namespace = null;
+ // String characterEncoding = out.getCharacterEncoding();
+ if (null != format) {
+ String[] docType = (String[]) doctypes.get(format);
+ if (null != docType) {
+ contentType = docType[1];
+ namespace = docType[2];
+ out.write(docType[0]);
+ }
+ }
+ if (null == contentType) {
+ contentType = (String) attributes.get("contentType");
+ }
+ if (null != contentType) {
+ // response.setContentType(contentType /*+ ";charset=" +
+ // characterEncoding*/);
+ }
+ // TODO - create "format" attribute and insert properly DOCTYPE
+ // declaratiom
+ out.startElement("html", component);
+ if (null == namespace) {
+ namespace = (String) attributes.get("namespace");
+ }
+ if (null != namespace) {
+ out.writeAttribute("xmlns", namespace, "namespace");
+ }
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ if (!AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
+ out.startElement("head", component);
+ // Out title - requied html element.
+ Object title = attributes.get("pageTitle");
+ String viewId = context.getViewRoot().getViewId();
+ if (null == title) {
+ title = viewId;// use viewId for empty title
+ }
+ out.startElement(HTML.title_ELEM, component);
+ out.writeText(title, "pageTitle");
+ out.endElement(HTML.title_ELEM);
+ // Page base - set to current view action url.
+ // String pageBase =
+ // context.getApplication().getViewHandler().getActionURL(context,
+ // viewId);
+ // out.startElement("base", component);
+ // out.writeURIAttribute("href", pageBase, "pageBase");
+ // out.endElement("base");
+ // pageStyles.encode(this, context, component);
+ UIComponent headFacet = component.getFacet("head");
+ if (headFacet != null) {
+ // context.getExternalContext().log("Render head facet in AJAX
+ // Page");
+ renderChild(context, headFacet);
+ }
+ if (null != contentType) {
+ out.startElement("meta", component);
+ out.writeAttribute("http-equiv", "Content-Type", null);
+ out.writeAttribute("content",
+ contentType /* + ";charset=" + characterEncoding */,
+ null);
+ out.endElement("meta");
+ }
+ if ((null == context.getExternalContext().getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))) {
+ // Filter not used - encode scripts and CSS before component.
+ encodeResourcesArray(context, component, getScripts());
+ encodeResourcesArray(context, component, getStyles());
+ }
+ out.endElement("head");
+ }
+ out.startElement("body", component);
+ getUtils().encodePassThru(context, component);
+ getUtils().encodeAttributesFromArray(context, component,
+ HTML.PASS_THRU_STYLES);
+ // TODO - special body attributes :
+ getUtils().encodeAttribute(context, component, "onload");
+ getUtils().encodeAttribute(context, component, "onunload");
+ // onload, onunload
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void doEncodeEnd(ResponseWriter out, FacesContext context,
+ UIComponent component) throws IOException {
+ out.endElement("body");
+ out.endElement("html");
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode end");
+ }
+
+ /*
+ * (non-Javadoc) For ajax requests, ViewRoot render childrens directly.
+ *
+ * @see org.ajax4jsf.framework.renderer.AjaxContainerRenderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
+ // Ajax Request. Control all output.
+ return true;
+ }
+ // For non Ajax request, view root not render children
+ return false;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,100 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIPoll;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxPollRenderer extends AjaxCommandRendererBase {
+
+
+
+ private static final String AJAX_POLL_FUNCTION = "A4J.AJAX.Poll";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIPoll poll = (UIPoll) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
+ getUtils().encodeId(context, component);
+ // polling script.
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if(poll.isEnabled()){
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_POLL_FUNCTION);
+ Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ Integer interval = new Integer(poll.getInterval());
+ options.put("pollinterval", interval);
+ options.put("pollId", component.getClientId(context));
+ Object onsubmit = component.getAttributes().get("onsubmit");
+ if (null != onsubmit) {
+ JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
+ onsubmitFunction.addToBody(onsubmit);
+ options.put("onsubmit", onsubmitFunction);
+ }
+
+// options.put("timeout", interval);
+ function.addParameter(options);
+ function.appendScript(script);
+ } else {
+ script.append("A4J.AJAX.StopPoll('").append(component.getClientId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(),null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // only poll component is allowed.
+ return UIPoll.class;
+ }
+
+ protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
+ boolean submitted = super.isSubmitted(facesContext, uiComponent);
+ UIPoll poll = (UIPoll) uiComponent;
+ poll.setSubmitted(submitted);
+ return submitted;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,118 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIPush;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxPushRenderer extends AjaxCommandRendererBase {
+
+ public static final String PUSH_INTERVAL_PARAMETER =
"A4J.AJAX.Push.INTERVAL";
+
+ public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
+
+ public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
+
+ public static final int DEFAULT_PUSH_INTERVAL = 1000;
+
+ public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
+
+ private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIPush push = (UIPush) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
+ getUtils().encodeId(context, component);
+ getUtils().encodeBeginFormIfNessesary(context, component);
+ // pushing script.
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if(push.isEnabled()){
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_PUSH_FUNCTION);
+ // Set dummy form id, if nessesary.
+ Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ options.put("dummyForm",
component.getClientId(context)+RendererUtils.DUMMY_FORM_ID);
+ int interval = push.getInterval();
+ if(interval == Integer.MIN_VALUE){
+ String intervalInitParameter =
context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
+ if(null != intervalInitParameter){
+ interval = Integer.parseInt(intervalInitParameter);
+ } else {
+ interval = DEFAULT_PUSH_INTERVAL;
+ }
+ }
+ options.put("pushinterval", new Integer(interval));
+ options.put("pushId", push.getListenerId(context));
+ String pushUrl = context.getExternalContext().getInitParameter(PUSH_URL_PARAMETER);
+ if(null != pushUrl){
+ options.put("pushUrl", pushUrl);
+ }
+ // options.put("timeout", interval);
+ function.addParameter(options);
+ function.appendScript(script);
+ } else {
+ script.append("A4J.AJAX.StopPush('").append(push.getListenerId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(),null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ getUtils().encodeEndFormIfNessesary(context, component);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // only push component is allowed.
+ return UIPush.class;
+ }
+
+ protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
+ boolean submitted = super.isSubmitted(facesContext, uiComponent);
+ UIPush push = (UIPush) uiComponent;
+ push.setSubmitted(submitted);
+ return submitted;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:28 $
+ *
+ */
+public class AjaxRegionRenderer extends AjaxContainerRenderer {
+
+ public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxRegionRenderer";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+// AjaxRendererUtils.encodeClientScript(context,component);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+// if (((AjaxContainer) component).isAjaxRequest()) {
+// AjaxRendererUtils.encodeAreas(context,component);
+// }
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,167 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIAjaxStatus;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/19 11:17:10 $
+ *
+ * Render status component as two span's, one for start request,
+ * one for complete.
+ */
+public class AjaxStatusRenderer extends RendererBase
+{
+ /**
+ *
+ */
+ public static final String RENDERER_TYPE =
"org.ajax4jsf.components.AjaxStatusRenderer";
+
+ /**
+ *
+ */
+ public static final String START_STYLE = "display: none";
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException
+ {
+ // find form clientId for wich we render status.
+ String statusId = component.getClientId(context);
+ String tag = getTag(component);
+ writer.startElement(tag, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, statusId , null);
+ // render 2 span components for different states
+ encodeSpan(writer, context, component,statusId, "start", tag);
+ encodeSpan(writer, context, component,statusId, "stop", tag);
+ writer.endElement(tag);
+ }
+
+ /**
+ * Encode one span for start or stop status
+ * @param context - current context
+ * @param component - status component
+ * @param state - name of state ( start or stop ) for span.
+ * @param tag TODO
+ * @throws IOException
+ */
+ protected void encodeSpan(ResponseWriter writer, FacesContext context, UIComponent
component, String id, String state, String tag) throws IOException {
+ writer.startElement(tag, component);
+ String spanId = id+"."+state;
+ writer.writeAttribute(HTML.id_ATTRIBUTE, spanId , null);
+ // Styles for concrete state.
+ String style = getNamedAttribute(component, "Style", state);
+ // for start state rendered style always disable display of status
+ // ( since it will enabled by JavaScript on start request )
+ if("start".equals(state)) {
+ if(null == style) {
+ style = START_STYLE;
+ } else {
+ style += "; "+START_STYLE;
+ }
+ }
+// HtmlRendererUtils.renderHTMLAttribute(writer, "style",
"style", style );
+// HtmlRendererUtils.renderHTMLAttribute(writer, "styleClass",
"styleClass", getNamedAttribute(component, "StyleClass", state));
+ if (null != style) {
+ writer.writeAttribute("style", style, null);
+ }
+ String styleClass = getNamedAttribute(component, "StyleClass", state);
+ if(null != styleClass){
+ writer.writeAttribute("class", styleClass, null);
+ }
+// getUtils().encodeAttribute(context,component,"class");
+ getUtils().encodePassThru(context , component);
+ // render facet or text.
+ UIComponent facet = component.getFacet(state);
+ if(null != facet) {
+ renderChild(context, facet);
+ } else {
+ String namedAttribute = getNamedAttribute(component, "Text",
state);
+ if (null != namedAttribute) {
+ writer.writeText(namedAttribute, "text");
+ }
+// else {
+// throw new FacesException("Status component must have one of
'"+state+"' facet or '"+state+"Text' atribute");
+// }
+ }
+ writer.endElement(tag);
+ // ENCODE onstart/onstop javaScript.
+ Object eventHandler = component.getAttributes().get("on"+state);
+ if(null != eventHandler){
+ StringBuffer script = new StringBuffer("\n");
+
script.append("window.document.getElementById('").append(spanId).append("').on").append(state).append("=");
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addToBody(eventHandler).addToBody(";").appendScript(script);
+ script.append(";\n");
+ getUtils().writeScript(context, component, script);
+ }
+ }
+
+ /**
+ * @param component
+ * @param name name of attribute for current state
+ * @param state 'start' or 'stop' . all dublicated attributes foe
Ajax state
+ * have same syntax : startStyle/stopStyle ...
+ * @return value of attribute for name and state
+ */
+ protected String getNamedAttribute(UIComponent component, String name, String state)
+ {
+ String fullName = (new StringBuffer(state).append(name)).toString();
+ return (String) component.getAttributes().get(fullName);
+ }
+
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIAjaxStatus.class;
+ }
+
+ /**
+ * @param status
+ * @return
+ */
+ private String getTag(UIComponent status) {
+ // TODO Auto-generated method stub
+ return
"block".equals(status.getAttributes().get("layout"))?HTML.DIV_ELEM:HTML.SPAN_ELEM;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,57 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+
+/**
+ * Since <code>UIAjaxRegion</code> dont render itself ( only set apropriate
event to parent component )
+ * only <code>decode()</code> method implemented.
+ * In case of Ajax Request caused by event for a given component
+ * send action event.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:24 $
+ *
+ */
+public class AjaxSupportRenderer extends AjaxCommandRendererBase
+{
+ private static final Log log = LogFactory.getLog(AjaxSupportRenderer.class);
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren()
+ {
+
+ return false;
+ }
+
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return org.ajax4jsf.ajax.UIAjaxSupport.class;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,212 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIParameter;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * "Wrapped" standard {@link javax.faces.component.html.HtmlCommandLink}
renderer,
+ * to avoid common problem - If no commandLink's exist in initial rendered page,
{@link javax.faces.component.html.HtmlForm} renderer
+ * don't encode nessesary hidden fields for link and it's param. Our form-link
renderer can avoid this problem.
+ * @author shura
+ *
+ */
+public class HtmlCommandLinkRenderer extends RendererBase {
+
+ private static final Log _log = LogFactory.getLog(HtmlCommandLinkRenderer.class);
+
+ private static final String[] LINK_EXCLUSIONS =
{"onclick","target","href"};
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doDecode(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+ UIForm form = getUtils().getNestingForm(context,component);
+ if(null != form){
+ String hiddenFieldId =
form.getClientId(context)+AjaxFormRenderer.HIDDEN_FIELD_SUFFIX;
+ Object hiddenFieldValue;
+ if(null !=
(hiddenFieldValue=context.getExternalContext().getRequestParameterMap().get(hiddenFieldId))){
+ if(component.getClientId(context).equals(hiddenFieldValue)){
+ // Link submitted !
+ if(_log.isDebugEnabled()){
+ _log.debug(Messages.getMessage(Messages.COMMAND_LINK_SUBMIT_INFO,
component.getClientId(context)));
+ }
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ if(isDisabled(context,component)){
+ doEncodePassiveBegin(writer, context, component);
+ } else {
+ doEncodeActiveBegin(writer, context, component);
+ }
+ }
+
+ protected void doEncodeActiveBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.startElement(HTML.a_ELEMENT,component);
+ getUtils().encodeId(context,component);
+ getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
+ getUtils().encodePassThruWithExclusionsArray(context,component,LINK_EXCLUSIONS);
+ writer.writeAttribute("href","#",null);
+ UIForm form = getUtils().getNestingForm(context,component);
+ String clientId = component.getClientId(context);
+ if(null == form){
+ if(_log.isWarnEnabled()){
+ _log.warn(Messages.getMessage(Messages.COMMAND_LINK_NOT_IN_FORM_WARNING, clientId));
+ }
+ return;
+ }
+ // Encode onclick attribute.
+ Object click = component.getAttributes().get("onclick");
+ StringBuffer onclick = new StringBuffer(256);
+ if(null != click){
+ onclick.append(click).append(';');
+ }
+ JSFunction submit = new JSFunction(AjaxFormRenderer.FORM_SUBMIT_FUNCTION_NAME);
+ submit.addParameter(clientId);
+ submit.addParameter(form.getClientId(context));
+ submit.addParameter(component.getAttributes().get("target"));
+ Map parameters = new HashMap();
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
+ Object child = iter.next();
+ if (child instanceof UIParameter) {
+ UIParameter param = (UIParameter) child;
+ parameters.put(param.getName(),param.getValue());
+ }
+ }
+ submit.addParameter(parameters);
+ onclick.append("return ");
+ submit.appendScript(onclick);
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE,onclick,"onclick");
+ //
+ encodeValue(writer,context,component);
+ }
+
+ protected void doEncodePassiveBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.startElement(HTML.SPAN_ELEM,component);
+ getUtils().encodeId(context,component);
+ getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
+ getUtils().encodePassThru(context,component);
+ encodeValue(writer,context,component);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ // TODO Auto-generated method stub
+ renderChildren(context,component);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ if(isDisabled(context,component)){
+ doEncodePassiveEnd(writer, context, component);
+ } else {
+ doEncodeActiveEnd(writer, context, component);
+ }
+ }
+
+ protected void doEncodeActiveEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.endElement(HTML.a_ELEMENT);
+ }
+
+ protected void doEncodePassiveEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException{
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+/**
+ * Check for disabled component
+ * @param context
+ * @param command
+ * @return true if link is disabled.
+ */
+private boolean isDisabled(FacesContext context, UIComponent command){
+ if (command.getAttributes().get("disabled") != null) {
+ if ((command.getAttributes().get("disabled")).equals(Boolean.TRUE)) {
+ return true;
+ }
+ }
+ return false;
+}
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UICommand.class;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ protected void encodeValue(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException{
+ String valueString = null;
+ if (component instanceof UICommand) {
+ Object value = ((UICommand) component).getValue();
+ if (value != null) {
+ valueString = value.toString();
+ }
+ } else if (component instanceof ValueHolder) {
+ Object value = ((ValueHolder) component).getValue();
+ if (value != null) {
+ valueString = getUtils().formatValue(context,component,value);
+ }
+ }
+
+ if (null != valueString && valueString.length()>0) {
+ writer.write(valueString);
+ }
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,134 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.resource.UIMediaOutput;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.resource.InternetResource;
+import org.ajax4jsf.framework.resource.InternetResourceBuilder;
+import org.ajax4jsf.framework.util.message.Messages;
+
+/**
+ * @author shura
+ *
+ */
+public class MediaOutputRenderer extends RendererBase {
+
+ public static final String RENDERER_TYPE = "org.ajax4jsf.MMediaRenderer";
+
+ /**
+ * Associationd between element name and uri attributes
+ */
+ private static final Map uriAttributes;
+
+ static {
+ uriAttributes = new HashMap();
+ uriAttributes.put("a","href");
+ uriAttributes.put("img","src");
+ uriAttributes.put("object","data");
+ uriAttributes.put("link","href");
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIMediaOutput mmedia = (UIMediaOutput) component;
+ String element = mmedia.getElement();
+ if(null == element){
+ throw new
FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
+ }
+ writer.endElement(element);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIMediaOutput.class;
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIMediaOutput mmedia = (UIMediaOutput) component;
+ String element = mmedia.getElement();
+ if(null == element){
+ throw new
FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"element",component.getClientId(context)));
+ }
+ String uriAttribute = mmedia.getUriAttribute();
+ // Check for pre-defined attributes
+ if(null == uriAttribute){
+ uriAttribute = (String) uriAttributes.get(element);
+ if(null == uriAttribute){
+ throw new
FacesException(Messages.getMessage(Messages.NULL_ATTRIBUTE_ERROR,"uriAttribute",component.getClientId(context)));
+ }
+ }
+ writer.startElement(element,mmedia);
+ getUtils().encodeId(context,component);
+ InternetResourceBuilder internetResourceBuilder =
InternetResourceBuilder.getInstance();
+ InternetResource resource =
internetResourceBuilder.createUserResource(mmedia.isCacheable(),mmedia.isSession(),mmedia.getMimeType());
+ StringBuffer uri = new StringBuffer(resource.getUri(context,mmedia));
+ // Append parameters to resource Uri
+ boolean haveQestion = uri.indexOf("?")>=0;
+ Iterator kids = component.getChildren().iterator();
+ while (kids.hasNext()) {
+ UIComponent kid = (UIComponent) kids.next();
+
+ if (kid instanceof UIParameter) {
+ UIParameter uiParam = (UIParameter) kid;
+ String name = uiParam.getName();
+ Object value = uiParam.getValue();
+ if(null != value){
+ if(haveQestion){
+ uri.append('&');
+ } else {
+ uri.append('?');
+ haveQestion = true;
+ }
+ uri.append(name).append('=').append(value.toString());
+ }
+ }
+ }
+ writer.writeURIAttribute(uriAttribute,uri,"uri");
+ getUtils().encodeAttributesFromArray(context,component,HTML.PASS_THRU_STYLES);
+ getUtils().encodePassThru(context,mmedia);
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,81 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.UIRepeat;
+import org.ajax4jsf.framework.renderer.RendererBase;
+
+/**
+ * @author shura
+ *
+ */
+public class RepeatRenderer extends RendererBase {
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ final UIRepeat repeater = (UIRepeat) component;
+ repeater.captureOrigValue(context);
+ try {
+ DataVisitor visitor = new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey, Object argument) throws
IOException {
+ repeater.setRowKey(rowKey);
+ ListIterator childIterator = repeater.getChildren()
+ .listIterator();
+ while (childIterator.hasNext()) {
+ UIComponent child = (UIComponent) childIterator.next();
+ renderChild(context, child);
+ }
+
+ }
+
+ };
+ repeater.walk(context, visitor, null);
+
+ } finally {
+ repeater.restoreOrigValue(context);
+ repeater.setRowKey(null);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIRepeat.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,178 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import javax.faces.application.Application;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.ajax.UIActionParameter;
+import org.ajax4jsf.framework.util.message.Messages;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.LegacyValueBinding;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
+ *
+ */
+public class ActionParamHandler extends ComponentHandler {
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
+ *
+ */
+ public static class ActionParamMetaRule extends MetaRule {
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.tag.SuggestionHandler.SuggestionMetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
+ */
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIActionParameter.class)) {
+ if ("assignTo".equals(name)) {
+ return new AssignToValueBindingMetadata(attribute);
+ } else if ("converter".equals(name)) {
+ if (attribute.isLiteral()) {
+ return new LiteralConverterMetadata(attribute.getValue());
+ } else {
+ return new DynamicConverterMetadata(attribute);
+ }
+
+ }
+ }
+
+ return null;
+ }
+
+
+ }
+
+ final static class LiteralConverterMetadata extends Metadata {
+
+ private final String converterId;
+
+ public LiteralConverterMetadata(String converterId) {
+ this.converterId = converterId;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setConverter(ctx.getFacesContext()
+ .getApplication().createConverter(this.converterId));
+ }
+ }
+
+ final static class DynamicConverterMetadata extends Metadata {
+
+ private final TagAttribute attr;
+
+ public DynamicConverterMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setConverter((Converter) this.attr
+ .getObject(ctx, Converter.class));
+ }
+ }
+
+ final static class AssignToValueBindingMetadata extends Metadata {
+
+ private final TagAttribute attr;
+
+ public AssignToValueBindingMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIActionParameter) instance).setAssignToBinding(
+ new LegacyValueBinding(attr.getValueExpression(ctx,
+ Object.class)));
+ }
+ }
+
+
+ private TagAttribute _assignTo;
+ private TagAttribute _converter;
+
+ /**
+ * @param config
+ */
+ public ActionParamHandler(ComponentConfig config) {
+ super(config);
+ _assignTo = getAttribute("assignTo");
+ _converter = getAttribute("converter");
+ if(null != _assignTo) {
+ if (_assignTo.isLiteral()) {
+ throw new TagAttributeException(this.tag, this._assignTo,
Messages.getMessage(Messages.MUST_BE_EXPRESSION_ERROR));
+ }
+
+ }
+ // TODO Auto-generated constructor stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
{
+ if (parent instanceof ActionSource)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ if (_assignTo != null) {
+ UIActionParameter al = (UIActionParameter)c;
+ // TODO - in jsf 1.2 use ELValueExpression
+//
al.setAssignToBinding(application.createValueBinding(_assignTo.getValue()));
+// if (_converter != null) {
+// Converter converter =
application.createConverter(_converter.getValue(ctx));
+// al.setConverter(converter);
+// }
+ ((ActionSource)parent).addActionListener(al);
+ }
+ }
+ }
+
+ private static final ActionParamMetaRule actionParamMetaRule = new
ActionParamMetaRule();
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
+ */
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRules = super.createMetaRuleset(type);
+ metaRules.addRule(actionParamMetaRule);
+ return metaRules;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxActionsRule.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,99 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import javax.faces.component.ActionSource;
+import javax.faces.event.ActionEvent;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.LegacyMethodBinding;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:21 $
+ *
+ */
+public class AjaxActionsRule extends MetaRule {
+
+ public final static Class[] ACTION_SIG = new Class[0];
+
+ public final static Class[] ACTION_LISTENER_SIG = new Class[] { ActionEvent.class };
+
+ public final static class ActionMapper extends Metadata {
+
+ private final TagAttribute attr;
+
+ public ActionMapper(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((ActionSource) instance).setAction(new LegacyMethodBinding(
+ this.attr.getMethodExpression(ctx, String.class,
+ AjaxActionsRule.ACTION_SIG)));
+ }
+ }
+
+ public final static class ActionListenerMapper extends Metadata {
+
+ private final TagAttribute attr;
+
+ public ActionListenerMapper(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((ActionSource) instance)
+ .setActionListener(new LegacyMethodBinding(this.attr
+ .getMethodExpression(ctx, null,
+ AjaxActionsRule.ACTION_LISTENER_SIG)));
+ }
+
+ }
+
+ public final static AjaxActionsRule instance = new AjaxActionsRule();
+
+ public AjaxActionsRule() {
+ super();
+ }
+
+ public Metadata applyRule(String name, TagAttribute attribute,
+ MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(ActionSource.class)) {
+
+
+ if ("action".equals(name)) {
+ return new ActionMapper(attribute);
+ }
+
+ if ("actionListener".equals(name)) {
+ return new ActionListenerMapper(attribute);
+ }
+ }
+ return null;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxComponentHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import javax.faces.component.ActionSource;
+
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
+ *
+ */
+public class AjaxComponentHandler extends ComponentHandler {
+
+ /**
+ * @param config
+ */
+ public AjaxComponentHandler(ComponentConfig config) {
+ super(config);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.jsf.ComponentHandler#createMetaRuleset(java.lang.Class)
+ */
+ protected MetaRuleset createMetaRuleset(Class type) {
+ // TODO Auto-generated method stub
+ MetaRuleset metaRules = super.createMetaRuleset(type);
+ if (ActionSource.class.isAssignableFrom(type)) {
+ metaRules.addRule(AjaxActionsRule.instance);
+ }
+ metaRules.addRule(AjaxReRendrRule.instance);
+ return metaRules;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,119 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxListenerHelper;
+import org.ajax4jsf.framework.ajax.AjaxSource;
+import org.ajax4jsf.framework.util.message.Messages;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.el.LegacyValueBinding;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagException;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * Register an ActionListener instance on the UIComponent associated with the
+ * closest parent UIComponent custom action. <p/> See <a
target="_new"
+ *
href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f...
+ * documentation</a>.
+ *
+ * @see javax.faces.event.ActionListener
+ * @see javax.faces.component.AjaxContainer
+ * @author Jacob Hookom
+ * @version $Id: AjaxListenerHandler.java,v 1.1.2.1 2007/02/01 15:31:23 alexsmirnov Exp
$
+ */
+public final class AjaxListenerHandler extends TagHandler {
+
+ private Class listenerType;
+
+ private final TagAttribute type;
+
+ private final TagAttribute binding;
+
+ /**
+ * @param config
+ */
+ public AjaxListenerHandler(TagConfig config) {
+ super(config);
+ this.binding = this.getAttribute("binding");
+ this.type = this.getRequiredAttribute("type");
+ if (type != null) {
+ if (!type.isLiteral()) {
+ throw new TagAttributeException(this.tag, this.type,
Messages.getMessage(Messages.MUST_BE_LITERAL_ERROR));
+ }
+ try {
+ this.listenerType = Class.forName(type.getValue());
+ } catch (Exception e) {
+ throw new TagAttributeException(this.tag, this.type, e);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ if (parent instanceof AjaxSource) {
+ // only process if parent was just created
+ if (parent.getParent() == null) {
+ AjaxSource src = (AjaxSource) parent;
+ AjaxListener listener = null;
+ ValueExpression ve = null;
+ if (this.binding != null) {
+ ve = this.binding.getValueExpression(ctx,
+ AjaxListener.class);
+ // TODO - handle both JSF 1.2/1.1 cases.
+ listener = new AjaxListenerHelper(new LegacyValueBinding(ve));
+ }
+ if (listener == null) {
+ try {
+ listener = (AjaxListener) listenerType.newInstance();
+ } catch (Exception e) {
+ throw new TagAttributeException(this.tag, this.type,
e.getCause());
+ }
+ if (ve != null) {
+ ve.setValue(ctx, ve);
+ }
+ }
+ src.addAjaxListener(listener);
+ }
+ } else {
+ throw new TagException(this.tag,
Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR, parent));
+ }
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.util.Set;
+
+import org.ajax4jsf.framework.ajax.AjaxComponent;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+public class AjaxReRendrRule extends MetaRule {
+
+ public static final AjaxReRendrRule instance = new AjaxReRendrRule();
+ /**
+ *
+ */
+ public AjaxReRendrRule() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
+ */
+ public Metadata applyRule(String name, TagAttribute attribute,
+ MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AjaxComponent.class)) {
+ if ("reRender".equals(name)) {
+ if (attribute.isLiteral()) {
+ return new ReRendersSetMataData(attribute.getValue());
+ } else {
+ // Process as usual expression
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ static class ReRendersSetMataData extends Metadata{
+
+ private Set _reRender;
+ /**
+ * @param value
+ */
+ public ReRendersSetMataData(String value) {
+ _reRender = AjaxRendererUtils.asSet(value);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
java.lang.Object)
+ */
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AjaxComponent) instance).setReRender(_reRender);
+
+ }
+
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,97 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.ajax4jsf.taglib.html.jsp.AjaxSupportTag;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagHandler;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+
+/**
+ * "proxy" class for creating UIAjaxSupport component as facet for it's
parent.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+public class AjaxSupportHandler extends TagHandler {
+ /**
+ * A UIComponent for capturing a child UIComponent, representative of the
+ * desired Facet
+ *
+ * @author Jacob Hookom
+ *
+ */
+ private final static class UIFacet extends UIComponentBase {
+ public String getFamily() {
+ return null;
+ }
+ }
+
+ /**
+ * Real tag handler for create component.
+ */
+ private TagHandler _ajaxSupportHandler;
+
+ private TagAttribute _event;
+ /**
+ * @param config
+ */
+ public AjaxSupportHandler(ComponentConfig config) {
+ super(config);
+ _event = getRequiredAttribute("event");
+ _ajaxSupportHandler = new AjaxComponentHandler(config);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ UIComponent c;
+ // our id
+// String id = ctx.generateUniqueId(this.tagId);
+ UIFacet facet = new UIFacet();
+ // Find facet for support component
+ String facetName = AjaxSupportTag.AJAX_SUPPORT_FACET+_event.getValue();
+ c = parent.getFacet(facetName);
+ if (null != c) {
+ parent.getFacets().remove(facetName);
+ facet.getChildren().add(c);
+ }
+ this._ajaxSupportHandler.apply(ctx, facet);
+ c = (UIComponent) facet.getChildren().get(0);
+ parent.getFacets().put(facetName, c);
+ // Fix for possible incompabilites in different frameworks.
+// c.setParentProperties(parent);
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,94 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.ajax4jsf.framework.util.message.Messages;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagException;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * Register a named facet on the UIComponent associated with the closest parent
+ * UIComponent custom action. <p/> See <a target="_new"
+ *
href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/f...
+ * documentation</a>.
+ *
+ * @author Jacob Hookom
+ * @version $Id: FacetHandler.java,v 1.1.2.1 2007/02/01 15:31:21 alexsmirnov Exp $
+ */
+public final class FacetHandler extends TagHandler {
+
+ /**
+ * A UIComponent for capturing a child UIComponent, representative of the
+ * desired Facet
+ *
+ * @author Jacob Hookom
+ *
+ */
+ private final static class UIFacet extends UIComponentBase {
+ public String getFamily() {
+ return null;
+ }
+ }
+
+ protected final TagAttribute name;
+
+ public FacetHandler(TagConfig config) {
+ super(config);
+ this.name = this.getRequiredAttribute("name");
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ UIFacet facet = new UIFacet();
+ UIComponent c;
+ // Check for existing facet
+ String facetName = this.name.getValue(ctx);
+ c = parent.getFacet(facetName);
+ if (null != c) {
+ parent.getFacets().remove(facetName);
+ facet.getChildren().add(c);
+ }
+ this.nextHandler.apply(ctx, facet);
+ int childCount = facet.getChildCount();
+ if (childCount == 1) {
+ c = (UIComponent) facet.getChildren().get(0);
+ parent.getFacets().put(facetName, c);
+ } else {
+ throw new TagException(this.tag,
Messages.getMessage(Messages.FACET_TAG_MANY_CHILDREN_ERROR));
+ }
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,274 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.TemplateClient;
+
+/**
+ * @author shura
+ *
+ */
+public class IncludeFaceletContext extends FaceletContext {
+
+ private FaceletContext defaultContext;
+
+ private Map ids;
+
+ /**
+ * @param defaultContext
+ */
+ public IncludeFaceletContext(FaceletContext defaultContext) {
+ this.defaultContext = defaultContext;
+ this.ids = new HashMap();
+ }
+
+ /**
+ * @param client
+ * @see com.sun.facelets.FaceletContext#extendClient(com.sun.facelets.TemplateClient)
+ */
+ public void extendClient(TemplateClient client) {
+ this.defaultContext.extendClient(client);
+ }
+
+ /**
+ * @param base
+ * @return
+ * @see com.sun.facelets.FaceletContext#generateUniqueId(java.lang.String)
+ */
+ public String generateUniqueId(String base) {
+ Integer cnt = (Integer) this.ids.get(base);
+ if (cnt == null) {
+ this.ids.put(base, new Integer(0));
+ return base;
+ } else {
+ int i = cnt.intValue() + 1;
+ this.ids.put(base, new Integer(i));
+ return base + "_" + i;
+ }
+ }
+
+ /**
+ * @param name
+ * @return
+ * @see com.sun.facelets.FaceletContext#getAttribute(java.lang.String)
+ */
+ public Object getAttribute(String name) {
+ return this.defaultContext.getAttribute(name);
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see javax.el.ELContext#getContext(java.lang.Class)
+ */
+ public Object getContext(Class key) {
+ return this.defaultContext.getContext(key);
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getELResolver()
+ */
+ public ELResolver getELResolver() {
+ return this.defaultContext.getELResolver();
+ }
+
+ /**
+ * @return
+ * @see com.sun.facelets.FaceletContext#getExpressionFactory()
+ */
+ public ExpressionFactory getExpressionFactory() {
+ return this.defaultContext.getExpressionFactory();
+ }
+
+ /**
+ * @return
+ * @see com.sun.facelets.FaceletContext#getFacesContext()
+ */
+ public FacesContext getFacesContext() {
+ return this.defaultContext.getFacesContext();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getFunctionMapper()
+ */
+ public FunctionMapper getFunctionMapper() {
+ return this.defaultContext.getFunctionMapper();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getLocale()
+ */
+ public Locale getLocale() {
+ return this.defaultContext.getLocale();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getVariableMapper()
+ */
+ public VariableMapper getVariableMapper() {
+ return this.defaultContext.getVariableMapper();
+ }
+
+ /**
+ * @return
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return this.defaultContext.hashCode();
+ }
+
+ /**
+ * @param parent
+ * @param name
+ * @return
+ * @throws IOException
+ * @throws FaceletException
+ * @throws FacesException
+ * @throws ELException
+ * @see
com.sun.facelets.FaceletContext#includeDefinition(javax.faces.component.UIComponent,
java.lang.String)
+ */
+ public boolean includeDefinition(UIComponent parent, String name) throws IOException,
FaceletException, FacesException, ELException {
+ return this.defaultContext.includeDefinition(parent, name);
+ }
+
+ /**
+ * @param parent
+ * @param relativePath
+ * @throws IOException
+ * @throws FaceletException
+ * @throws FacesException
+ * @throws ELException
+ * @see
com.sun.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent,
java.lang.String)
+ */
+ public void includeFacelet(UIComponent parent, String relativePath) throws IOException,
FaceletException, FacesException, ELException {
+ this.defaultContext.includeFacelet(parent, relativePath);
+ }
+
+ /**
+ * @param parent
+ * @param absolutePath
+ * @throws IOException
+ * @throws FaceletException
+ * @throws FacesException
+ * @throws ELException
+ * @see
com.sun.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent,
java.net.URL)
+ */
+ public void includeFacelet(UIComponent parent, URL absolutePath) throws IOException,
FaceletException, FacesException, ELException {
+ this.defaultContext.includeFacelet(parent, absolutePath);
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#isPropertyResolved()
+ */
+ public boolean isPropertyResolved() {
+ return this.defaultContext.isPropertyResolved();
+ }
+
+ /**
+ * @param client
+ * @see com.sun.facelets.FaceletContext#popClient(com.sun.facelets.TemplateClient)
+ */
+ public void popClient(TemplateClient client) {
+ this.defaultContext.popClient(client);
+ }
+
+ /**
+ * @param client
+ * @see com.sun.facelets.FaceletContext#pushClient(com.sun.facelets.TemplateClient)
+ */
+ public void pushClient(TemplateClient client) {
+ this.defaultContext.pushClient(client);
+ }
+
+ /**
+ * @param key
+ * @param contextObject
+ * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
+ */
+ public void putContext(Class key, Object contextObject) {
+ this.defaultContext.putContext(key, contextObject);
+ }
+
+ /**
+ * @param name
+ * @param value
+ * @see com.sun.facelets.FaceletContext#setAttribute(java.lang.String,
java.lang.Object)
+ */
+ public void setAttribute(String name, Object value) {
+ this.defaultContext.setAttribute(name, value);
+ }
+
+ /**
+ * @param fnMapper
+ * @see com.sun.facelets.FaceletContext#setFunctionMapper(javax.el.FunctionMapper)
+ */
+ public void setFunctionMapper(FunctionMapper fnMapper) {
+ this.defaultContext.setFunctionMapper(fnMapper);
+ }
+
+ /**
+ * @param locale
+ * @see javax.el.ELContext#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ this.defaultContext.setLocale(locale);
+ }
+
+ /**
+ * @param resolved
+ * @see javax.el.ELContext#setPropertyResolved(boolean)
+ */
+ public void setPropertyResolved(boolean resolved) {
+ this.defaultContext.setPropertyResolved(resolved);
+ }
+
+ /**
+ * @param varMapper
+ * @see com.sun.facelets.FaceletContext#setVariableMapper(javax.el.VariableMapper)
+ */
+ public void setVariableMapper(VariableMapper varMapper) {
+ this.defaultContext.setVariableMapper(varMapper);
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,95 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.servlet.jsp.JspException;
+
+import org.ajax4jsf.ajax.UIInclude;
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.VariableMapperWrapper;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
+/**
+ * @author shura
+ *
+ */
+public class IncludeHandler extends ComponentHandler {
+
+ private TagAttribute viewId;
+
+ public IncludeHandler(ComponentConfig config) {
+ super(config);
+ this.viewId = getRequiredAttribute("viewId");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
com.sun.facelets.tag.jsf.ComponentHandler#onComponentCreated(com.sun.facelets.FaceletContext,
+ * javax.faces.component.UIComponent,
+ * javax.faces.component.UIComponent)
+ */
+ protected void onComponentCreated(FaceletContext ctx, UIComponent c,
+ UIComponent parent) {
+ // TODO Auto-generated method stub
+ super.onComponentCreated(ctx, c, parent);
+ }
+
+ protected void applyNextHandler(FaceletContext ctx, UIComponent component)
+ throws IOException, FacesException, ELException {
+ String path;
+ if (component instanceof UIInclude) {
+ UIInclude include = (UIInclude) component;
+ path = include.getViewId();
+ if(include.isWasNavigation()){
+ component.getChildren().clear();
+ }
+ } else {
+ path = (String) component.getAttributes().get("viewId");
+ }
+ VariableMapper orig = ctx.getVariableMapper();
+ ctx.setVariableMapper(new VariableMapperWrapper(orig));
+ try {
+ this.nextHandler.apply(ctx, component);
+ ctx.includeFacelet(component, path);
+ } catch (Exception e) {
+ throw new FacesException("UIInclude component "
+ + component.getClientId(ctx.getFacesContext())
+ + " could't include page with path " + path, e);
+ } finally {
+ ctx.setVariableMapper(orig);
+ }
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
+import org.ajax4jsf.framework.util.message.Messages;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributeException;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+/**
+ * @author shura
+ *
+ */
+public class KeepAliveHandler extends TagHandler {
+
+ private final TagAttribute beanName;
+
+ private final TagAttribute ajaxOnly;
+ /**
+ * @param config
+ */
+ public KeepAliveHandler(TagConfig config) {
+ super(config);
+ this.beanName = this.getRequiredAttribute("beanName");
+ if (beanName != null) {
+ if (!beanName.isLiteral()) {
+ throw new TagAttributeException(this.tag, this.beanName,
Messages.getMessage(Messages.MUST_BE_LITERAL_ERROR));
+ }
+ }
+ this.ajaxOnly = getAttribute("ajaxOnly");
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+ // Get bean instance from EL expression.
+ String name = beanName.getValue();
+ boolean isAjaxOnly = ajaxOnly!=null?ajaxOnly.getBoolean(ctx):false;
+ FacesContext facesContext = ctx.getFacesContext();
+ String beanExpression = "#{"+name+"}";
+ ValueBinding valueBinding =
facesContext.getApplication().createValueBinding(beanExpression);
+ Object bean = valueBinding.getValue(facesContext);
+ String beanAttributeName =
isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+name;
+ // Put bean instance to ViewRoot.
+ facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,121 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.io.OutputStream;
+
+import org.ajax4jsf.ajax.resource.UIMediaOutput;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.LegacyMethodBinding;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+public class MediaOutputHandler extends ComponentHandler {
+
+ private static final MetaRule mmediaMetaRule = new MMediaMetaRule();
+ /**
+ * @param config
+ */
+ public MediaOutputHandler(ComponentConfig config) {
+ super(config);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
+ */
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRules = super.createMetaRuleset(type);
+ metaRules.addRule(mmediaMetaRule);
+ return metaRules;
+ }
+
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+ static class MMediaMetaRule extends MetaRule{
+
+ /**
+ *
+ */
+ public MMediaMetaRule() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
+ */
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIMediaOutput.class)) {
+
+
+ if ("createContent".equals(name)) {
+ return new MMediaActionMapper(attribute);
+ }
+ }
+ return null;
+ }
+
+ }
+ /**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
+ *
+ */
+ static class MMediaActionMapper extends Metadata {
+
+ private static final Class[] MMEDIA_ACTION_SIG = new Class[]
{OutputStream.class,Object.class};
+
+ private final TagAttribute _send;
+ /**
+ * @param attribute
+ */
+ public MMediaActionMapper(TagAttribute attribute) {
+ _send = attribute;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
java.lang.Object)
+ */
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIMediaOutput) instance)
+ .setCreateContent(new LegacyMethodBinding(this._send
+ .getMethodExpression(ctx, null,
+ MMEDIA_ACTION_SIG)));
+ }
+
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ActionParamTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,146 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.application.Application;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.webapp.UIComponentTag;
+
+import org.ajax4jsf.ajax.UIActionParameter;
+import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.framework.util.message.Messages;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:31 $
+ *
+ */
+public class ActionParamTag extends UIComponentTagBase
+{
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ return "org.ajax4jsf.components.ActionParameter";
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ return null;
+ }
+ // UIComponent attributes --> already implemented in UIComponentTagBase
+
+ // UIParameter attributes
+ // value already implemented in UIComponentTagBase
+ private String _name;
+ private String _assignTo;
+ private String _converter;
+ private String _noEscape;
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "name", _name);
+ setBooleanProperty(component, "noEscape", _noEscape);
+
+ //Find parent UIComponentTag
+ UIComponentTag componentTag =
UIComponentTag.getParentUIComponentTag(pageContext);
+ if (componentTag == null)
+ {
+ throw new
IllegalArgumentException(Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"ActionParameterTag"));
+ }
+
+ if (componentTag.getCreated())
+ {
+ //Component was just created, so we add the Listener
+ UIComponent parentComponent = componentTag.getComponentInstance();
+ if (parentComponent instanceof ActionSource)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ if (_assignTo != null) {
+ if (!UIComponentTag.isValueReference(_assignTo)) throw new
IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_REFERENCE_ERROR_2,
_assignTo));
+ UIActionParameter al = (UIActionParameter)component;
+ al.setAssignToBinding(application.createValueBinding(_assignTo));
+ if (_converter != null)
+ {
+ Converter converter = application.createConverter(_converter);
+ al.setConverter(converter);
+ }
+ ((ActionSource)parentComponent).addActionListener(al);
+ }
+ }
+ }
+
+ }
+
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ /**
+ * @param converter The converter to set.
+ */
+ public void setConverter(String converter)
+ {
+ this._converter = converter;
+ }
+
+ /**
+ * @param noEscape The noEscape to set.
+ */
+ public void setNoEscape(String noEscape)
+ {
+ this._noEscape = noEscape;
+ }
+
+ /**
+ * @param property The property to set.
+ */
+ public void setAssignTo(String property)
+ {
+ this._assignTo = property;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.myfaces.taglib.UIComponentTagBase#release()
+ */
+ public void release()
+ {
+ _name = null;
+ _assignTo = null;
+ _converter = null;
+ _noEscape = null;
+ super.release();
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxFormTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import org.ajax4jsf.ajax.UIAjaxForm;
+import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+
+
+/**
+ * Tag for creating Ajax version of HTML Form.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:32 $
+ *
+ */
+public class AjaxFormTag extends UIComponentTagBase
+{
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ // TODO Auto-generated method stub
+ return UIAjaxForm.COMPONENT_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ // TODO Auto-generated method stub
+ return "javax.faces.Form";
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,127 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxListenerHelper;
+import org.ajax4jsf.framework.ajax.AjaxSource;
+import org.ajax4jsf.framework.util.message.Messages;
+
+
+/**
+ * @author shura
+ *
+ * Custom tag for append AJAX request listeners to AjaxContainer.
+ *
+ */
+public class AjaxListenerTag extends TagSupport {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2576519366310474212L;
+ /**
+ * class name for ajax events listener.
+ */
+ private String type = null;
+
+ private String binding = null;
+
+ /**
+ *
+ */
+ public AjaxListenerTag() {
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @param binding the binding to set
+ */
+ public void setBinding(String binding) {
+ this.binding = binding;
+ }
+
+ public int doStartTag() throws JspException {
+ if (type == null) {
+ throw new
JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
+ }
+
+ //Find parent UIComponentTag
+ UIComponentTag componentTag = UIComponentTag
+ .getParentUIComponentTag(pageContext);
+ if (componentTag == null) {
+ throw new JspException(
+ Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"AjaxListenerTag"));
+ }
+
+ if (componentTag.getCreated()) {
+ //Component was just created, so we add the Listener
+ UIComponent component = componentTag.getComponentInstance();
+ if (component instanceof AjaxSource) {
+ AjaxListener listener;
+ if(null != binding){
+ ValueBinding valueBinding;
+ try {
+ valueBinding =
FacesContext.getCurrentInstance().getApplication().createValueBinding(binding);
+ } catch (ReferenceSyntaxException e) {
+ throw new JspException(e);
+ }
+ listener = new AjaxListenerHelper(valueBinding);
+ } else {
+ String className;
+ if (UIComponentTag.isValueReference(type)) {
+ FacesContext facesContext = FacesContext
+ .getCurrentInstance();
+ ValueBinding valueBinding = facesContext.getApplication()
+ .createValueBinding(type);
+ className = (String) valueBinding.getValue(facesContext);
+ } else {
+ className = type;
+ }
+ try {
+ listener = (AjaxListener) Class.forName(className).newInstance();
+ } catch (Exception e) {
+ throw new
JspException(Messages.getMessage(Messages.INSTANTIATE_LISTENER_ERROR, className,
component.getId()), e);
+ }
+ }
+ ((AjaxSource) component).addAjaxListener(listener);
+ } else {
+ throw new
JspException(Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR,
component.getId()));
+ }
+ }
+
+ return Tag.SKIP_BODY;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxPageTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.renderkit.html.AjaxPageRenderer;
+
+
+/**
+ * @author shura
+ *
+ * Other variant of AJAX View - render full html page with root <html>,
+ * <head> ( filled from "head" facet ) and <body> areas.
+ *
+ */
+public class AjaxPageTag extends AjaxRegionTag {
+
+ private String onload;
+ private String onunload;
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ return AjaxPageRenderer.RENDERER_TYPE;
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release() {
+ this.onload = null;
+ this.onunload = null;
+ super.release();
+ }
+ /* (non-Javadoc)
+ * @see
javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ setStringProperty(component, "onload", this.onload);
+ setStringProperty(component, "onunload", this.onunload);
+ }
+ /**
+ * @return Returns the onload.
+ */
+ public String getOnload() {
+ return onload;
+ }
+ /**
+ * @return Returns the onunload.
+ */
+ public String getOnunload() {
+ return onunload;
+ }
+ /**
+ * @param onload The onload to set.
+ */
+ public void setOnload(String onload) {
+ this.onload = onload;
+ }
+ /**
+ * @param onunload The onunload to set.
+ */
+ public void setOnunload(String onunload) {
+ this.onunload = onunload;
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxRegionTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,162 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.component.UIComponent;
+import javax.faces.el.MethodBinding;
+
+import org.ajax4jsf.ajax.UIAjaxRegion;
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.ajax4jsf.renderkit.html.AjaxRegionRenderer;
+
+
+/**
+ * @author shura
+ * Tag for create root Ajax component. must be immediate in produced html/body.
+ * Example use in jsp:
+ *
+ * For produce correct html code in any ( ajax and non-ajax requests ),
+ * better result with <ajax:page> tag.
+ */
+public class AjaxRegionTag extends UIComponentTagBase {
+
+ private String ajaxListener = null;
+
+ private String reRender = null;
+
+ private String immediate = null;
+
+ private String selfRendered = null;
+
+ private String javascriptLocation = null;
+
+ /**
+ *
+ */
+ public AjaxRegionTag() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType() {
+ return UIAjaxRegion.COMPONENT_TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ return AjaxRegionRenderer.RENDERER_TYPE;
+ }
+
+ // set component properties
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release() {
+ // release reources properties
+ super.release();
+ this.reRender = null;
+ this.ajaxListener = null;
+ this.immediate = null;
+ this.selfRendered = null;
+ this.javascriptLocation = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ setBooleanProperty(component, "immediate", this.immediate);
+ setStringProperty(component, "ajaxAreas", this.reRender);
+ setBooleanProperty(component,"selfRendered",this.selfRendered);
+ setStringProperty(component, "javascriptLocation",
this.javascriptLocation);
+ if (ajaxListener != null) {
+ if (!(component instanceof AjaxContainer)) {
+ throw new
IllegalArgumentException(Messages.getMessage(Messages.NOT_AJAX_CONTAINER_ERROR,
component.getClientId(getFacesContext())));
+ }
+ if (isValueReference(ajaxListener)) {
+ MethodBinding mb = getFacesContext().getApplication()
+ .createMethodBinding(ajaxListener,
+ AjaxListener.AJAX_LISTENER_ARGS);
+ ((AjaxContainer) component).setAjaxListener(mb);
+ } else {
+
getFacesContext().getExternalContext().log(Messages.getMessage(Messages.INVALID_EXPRESSION,
ajaxListener));
+ }
+
+ }
+ }
+
+ /**
+ * @param ajaxAreas
+ * The ajaxAreas to set.
+ */
+ public void setReRender(String ajaxAreas) {
+ this.reRender = ajaxAreas;
+ }
+
+ /**
+ * @param ajaxListener
+ * The ajaxListener to set.
+ */
+ public void setAjaxListener(String ajaxListener) {
+ this.ajaxListener = ajaxListener;
+ }
+
+ /**
+ * @param immediate
+ * The immediate to set.
+ */
+ public void setImmediate(String immediate) {
+ this.immediate = immediate;
+ }
+
+ /**
+ * @param selfRendered The selfRendered to set.
+ */
+ public void setSelfRendered(String selfRendered) {
+ this.selfRendered = selfRendered;
+ }
+
+// public String getJavascriptLocation() {
+// return javascriptLocation;
+// }
+//
+ public void setJavascriptLocation(String javascriptLocation) {
+ this.javascriptLocation = javascriptLocation;
+ }
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxStatusTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,189 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.ajax.UIAjaxStatus;
+import org.ajax4jsf.framework.taglib.HtmlComponentTagBase;
+import org.ajax4jsf.renderkit.html.AjaxStatusRenderer;
+
+
+/**
+ *
+ * Jsp Tag for create request state component.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:30 $
+ *
+ */
+public class AjaxStatusTag extends HtmlComponentTagBase
+{
+
+ private String _for = null;
+ /**
+ * Text to output on start request
+ */
+ private String _startText = null;
+ /**
+ * Text to display on complete request
+ */
+ private String _stopText = null;
+
+ /**
+ * Style for display on start request
+ */
+ private String _startStyle = null;
+ /**
+ * Style for displaying on complete
+ */
+ private String _stopStyle = null;
+ /**
+ * Style class for display on request
+ */
+ private String _startStyleClass = null;
+ /**
+ * Style class for display on complete request
+ */
+ private String _stopStyleClass = null;
+
+ /**
+ * Force id to render in Html as is
+ */
+ private String _forceId = null;
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ // TODO Auto-generated method stub
+ return UIAjaxStatus.COMPONENT_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+ // TODO Auto-generated method stub
+ return AjaxStatusRenderer.RENDERER_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.components.taglib.html.HtmlComponentTagBase#release()
+ */
+ public void release()
+ {
+ super.release();
+ this._for = null;
+ this._startStyle = null;
+ this._startStyleClass = null;
+ this._startText = null;
+ this._stopStyle = null;
+ this._stopStyleClass = null;
+ this._stopText = null;
+ this._forceId = null;
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.components.taglib.html.HtmlComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "for", _for);
+ setStringProperty(component, "startText", _startText);
+ setStringProperty(component, "stopText", _stopText);
+ setStringProperty(component, "startStyle", _startStyle);
+ setStringProperty(component, "stopStyle", _stopStyle);
+ setStringProperty(component, "startStyleClass", _startStyleClass);
+ setStringProperty(component, "stopStyleClass", _stopStyleClass);
+ setBooleanProperty(component, "forceId", _forceId);
+
+ }
+
+
+ /**
+ * @param _for The _for to set.
+ */
+ public void setFor(String _for)
+ {
+ this._for = _for;
+ }
+
+ /**
+ * @param style The _startStyle to set.
+ */
+ public void setStartStyle(String style)
+ {
+ _startStyle = style;
+ }
+
+ /**
+ * @param styleClass The _startStyleClass to set.
+ */
+ public void setStartStyleClass(String styleClass)
+ {
+ _startStyleClass = styleClass;
+ }
+
+ /**
+ * @param text The _startText to set.
+ */
+ public void setStartText(String text)
+ {
+ _startText = text;
+ }
+
+ /**
+ * @param stopText The stopText to set.
+ */
+ public void setStopText(String stopText)
+ {
+ this._stopText = stopText;
+ }
+
+ /**
+ * @param style The _stopStyle to set.
+ */
+ public void setStopStyle(String style)
+ {
+ _stopStyle = style;
+ }
+
+ /**
+ * @param styleClass The _stopStyleClass to set.
+ */
+ public void setStopStyleClass(String styleClass)
+ {
+ _stopStyleClass = styleClass;
+ }
+
+ /**
+ * @param forceId The forceId to set.
+ */
+ public void setForceId(String forceId)
+ {
+ this._forceId = forceId;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,283 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.component.UIComponent;
+import javax.faces.webapp.UIComponentTag;
+
+import org.ajax4jsf.ajax.UIAjaxSupport;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.framework.util.message.Messages;
+
+
+/**
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:32 $
+ *
+ */
+public class AjaxSupportTag extends UIComponentTagBase {
+
+ static final String[] EVENT_HANDLER_ATTRIBUTES =
+ {
+ HTML.ondblclick_ATTRIBUTE,
+ HTML.onmousedown_ATTRIBUTE,
+ HTML.onmouseup_ATTRIBUTE,
+ HTML.onmouseover_ATTRIBUTE,
+ HTML.onmousemove_ATTRIBUTE,
+ HTML.onmouseout_ATTRIBUTE,
+ HTML.onkeypress_ATTRIBUTE,
+ HTML.onkeydown_ATTRIBUTE,
+ HTML.onkeyup_ATTRIBUTE,
+ HTML.onclick_ATTRIBUTE,
+ HTML.onchange_ATTRIBUTE,
+ HTML.onblur_ATTRIBUTE,
+ HTML.onfocus_ATTRIBUTE,
+ HTML.onselect_ATTRIBUTE
+ };
+
+ public static final String AJAX_SUPPORT_FACET = "org.ajax4jsf.ajax.SUPPORT";
+ /**
+ * Id ( in form of findComponent method param ) of JSF component,
+ * updated by this component ( parnt tag ) action.
+ */
+ private String reRender = null;
+
+ /**
+ * Generate script for given event ( onclick, onenter ... )
+ */
+ private String event = null;
+
+
+ /**
+ * Id of request status component.
+ */
+ private String status = null;
+
+ /**
+ * JavaScript function for call after request completed.
+ */
+ private String oncomplete = null ;
+
+ private String action = null;
+ private String actionListener = null;
+ private String limitToList = null;
+ private String disableDefault = null;
+ private String value = null;
+ private String immediate = null;
+ private String ajaxSingle = null;
+
+
+
+
+ /**
+ * @param type The type to set.
+ */
+ public void setDisableDefault(String ajaxType)
+ {
+ this.disableDefault = ajaxType;
+ }
+
+ /**
+ * @param reRender
+ * The targetId to set.
+ */
+ public void setReRender(String ajaxId) {
+ this.reRender = ajaxId;
+ }
+
+
+ /**
+ * @param event The event to set.
+ */
+ public void setEvent(String event)
+ {
+ this.event = event;
+ }
+
+ /**
+ * @param oncomplete The oncomplete to set.
+ */
+ public void setOncomplete(String oncomplete)
+ {
+ this.oncomplete = oncomplete;
+ }
+
+ /**
+ * @param status The status to set.
+ */
+ public void setStatus(String status)
+ {
+ this.status = status;
+ }
+
+ /**
+ * @param limitToList The submitForm to set.
+ */
+ public void setLimitToList(String limitToList)
+ {
+ this.limitToList = limitToList;
+ }
+
+ /**
+ * @param action The action to set.
+ */
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+ /**
+ * @param actionListener The actionListener to set.
+ */
+ public void setActionListener(String actionListener)
+ {
+ this.actionListener = actionListener;
+ }
+
+ protected void setParentProperties(UIAjaxSupport uiComponent) {
+
+ //Find parent UIComponentTag
+ UIComponentTag componentTag = null;
+ try {
+ componentTag = UIComponentTag.getParentUIComponentTag(pageContext);
+ if (componentTag == null) {
+ throw new IllegalArgumentException(
+ Messages.getMessage(Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR,
"AjaxSupportTag"));
+ }
+
+ if (componentTag.getCreated()) {
+ //Component was just created, so we add the Listener
+ UIComponent component = componentTag.getComponentInstance();
+ uiComponent.setParentProperties(component);
+ }
+ } catch (ClassCastException e) {
+ // JSF 1.2 - tags have other parent.
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.Tag#release()
+ */
+ public void release() {
+ this.reRender = null;
+ this.oncomplete = null;
+ this.event = null;
+ this.status =null;
+ this.action = null;
+ this.actionListener = null;
+ this.limitToList = null;
+ this.disableDefault = null;
+ this.value = null;
+ this.immediate=null;
+ this.ajaxSingle = null;
+ super.release();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+
+ return UIAjaxSupport.COMPONENT_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType()
+ {
+
+ return UIAjaxSupport.DEFAULT_RENDERER_TYPE;
+ }
+
+ /**
+ * @param value The value to set.
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @param immediate The immediate to set.
+ */
+ public void setImmediate(String immediate) {
+ this.immediate = immediate;
+ }
+
+ /**
+ * @param ajaxSingle The ajaxSingle to set.
+ */
+ public void setAjaxSingle(String ajaxSingle) {
+ this.ajaxSingle = ajaxSingle;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.components.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "event", event);
+ setReRenderProperty(component);
+ setStringProperty(component, "status", status);
+ setStringProperty(component, "oncomplete", oncomplete);
+ setBooleanProperty(component, "disableDefault", disableDefault );
+ setBooleanProperty(component, "limitToList", limitToList);
+ setActionProperty(component, action);
+ setActionListenerProperty(component, actionListener);
+ setValueProperty(component,value);
+ setBooleanProperty(component,"immediate",immediate);
+ setBooleanProperty(component,"ajaxSingle",ajaxSingle);
+
+ setParentProperties((UIAjaxSupport) component);
+ }
+
+ private void setReRenderProperty(UIComponent component) {
+ if (reRender != null) {
+ if (isValueReference(reRender)) {
+ setStringProperty(component, "reRender", reRender);
+ } else {
+ ((UIAjaxSupport) component).setReRender(
AjaxRendererUtils.asSet(reRender));
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getFacetName()
+ */
+ protected String getFacetName() {
+ // TODO Auto-generated method stub
+ if (null != event) {
+ return AJAX_SUPPORT_FACET + event;
+ } else {
+ return AJAX_SUPPORT_FACET;
+ }
+ }
+
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java)
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/IncludeTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,243 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+
+import org.ajax4jsf.ajax.UIInclude;
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+
+/**
+ * @author shura
+ *
+ */
+public class IncludeTag extends UIComponentTagBase {
+
+ /**
+ * @author shura
+ *
+ */
+ private static final class NullJspWriter extends JspWriter {
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ private NullJspWriter() {
+ super(1024, false);
+ }
+
+ public void clear() throws IOException {
+ }
+
+ public void clearBuffer() throws IOException {
+ }
+
+ public void close() throws IOException {
+ }
+
+ public void flush() throws IOException {
+ }
+
+ public int getRemaining() {
+ return 0;
+ }
+
+ public void newLine() throws IOException {
+ }
+
+ public void print(boolean arg0) throws IOException {
+ }
+
+ public void print(char arg0) throws IOException {
+ }
+
+ public void print(int arg0) throws IOException {
+ }
+
+ public void print(long arg0) throws IOException {
+ }
+
+ public void print(float arg0) throws IOException {
+ }
+
+ public void print(double arg0) throws IOException {
+ }
+
+ public void print(char[] arg0) throws IOException {
+ }
+
+ public void print(String arg0) throws IOException {
+ }
+
+ public void print(Object arg0) throws IOException {
+ }
+
+ public void println() throws IOException {
+ }
+
+ public void println(boolean arg0) throws IOException {
+ }
+
+ public void println(char arg0) throws IOException {
+ }
+
+ public void println(int arg0) throws IOException {
+ }
+
+ public void println(long arg0) throws IOException {
+ }
+
+ public void println(float arg0) throws IOException {
+ }
+
+ public void println(double arg0) throws IOException {
+ }
+
+ public void println(char[] arg0) throws IOException {
+ }
+
+ public void println(String arg0) throws IOException {
+ }
+
+ public void println(Object arg0) throws IOException {
+ }
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ }
+ }
+
+ private String viewId;
+
+ /**
+ * @param viewId
+ * the viewId to set
+ */
+ public void setViewId(String viewId) {
+ this.viewId = viewId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.taglib.UIComponentTagBase#release()
+ */
+ public void release() {
+ super.release();
+ viewId = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.taglib.UIComponentTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ setStringProperty(component, "viewId", viewId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#doEndTag()
+ */
+ public int doEndTag() throws JspException {
+ int i = super.doEndTag();
+ return i;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#doStartTag()
+ */
+ public int doStartTag() throws JspException {
+ int i = super.doStartTag();
+ String resourcePath;
+ UIComponent component = getComponentInstance();
+ UIInclude includeComponent = null;
+ if (component instanceof UIInclude) {
+ includeComponent = (UIInclude) component;
+ resourcePath = includeComponent.getViewId();
+ if(includeComponent.isWasNavigation()){
+ component.getChildren().clear();
+ }
+ } else {
+ resourcePath = (String) component.getAttributes().get("viewId");
+ }
+ JspWriter out;
+ if (component.isRendered()) {
+ out = this.pageContext.getOut();
+ } else {
+ // All content of response will be skip.
+ out = new NullJspWriter();
+ }
+ ServletRequest request = this.pageContext.getRequest();
+ ServletResponse response = this.pageContext.getResponse();
+ RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
+ FacesContext facesContext = getFacesContext();
+ if(null == rd){
+ throw new JspException("UIInclude component
"+component.getClientId(facesContext)+ " could't include page with path
"+resourcePath);
+ }
+ try {
+ ServletResponseWrapperInclude responseWrapper = new ServletResponseWrapperInclude(
+ response, out);
+ rd.include(request, responseWrapper);
+ // Write buffered data, if any;
+ responseWrapper.flushBuffer();
+ } catch (Exception e) {
+ throw new JspException(e);
+ }
+ return i;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType() {
+ return UIInclude.COMPONENT_TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ return null;
+ }
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
+import org.ajax4jsf.framework.util.message.Messages;
+
+/**
+ * @author shura
+ *
+ */
+public class KeepAliveTag extends TagSupport {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4322021112358067548L;
+
+ private String beanName = null;
+
+ private String ajaxOnly = null;
+
+ /**
+ * @return the ajaxOnly
+ */
+ public String getAjaxOnly() {
+ return ajaxOnly;
+ }
+
+ /**
+ * @param ajaxOnly the ajaxOnly to set
+ */
+ public void setAjaxOnly(String ajaxOnly) {
+ this.ajaxOnly = ajaxOnly;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getBeanName() {
+ return beanName;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setBeanName(String name) {
+ this.beanName = name;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
+ */
+ public int doStartTag() throws JspException {
+ if (beanName == null) {
+ throw new
JspException(Messages.getMessage(Messages.NULL_TYPE_ATTRIBUTE_ERROR));
+ }
+ if(UIComponentTag.isValueReference(beanName)){
+ throw new JspException(Messages.getMessage(Messages.NAME_MUST_BE_LITERAL));
+ }
+ boolean isAjaxOnly = false;
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != ajaxOnly) {
+ if (UIComponentTag.isValueReference(ajaxOnly))
+ {
+ ValueBinding vb =
facesContext.getApplication().createValueBinding(ajaxOnly);
+ isAjaxOnly = Boolean.TRUE.equals(vb.getValue(facesContext));
+ }
+ else
+ {
+ //TODO: More sophisticated way to convert boolean value (yes/no, 1/0,
on/off, etc.)
+ isAjaxOnly = Boolean.parseBoolean(ajaxOnly);
+ }
+
+ }
+ // Get bean instance from EL expression.
+ String beanExpression = "#{"+beanName+"}";
+ ValueBinding valueBinding =
facesContext.getApplication().createValueBinding(beanExpression);
+ Object bean = valueBinding.getValue(facesContext);
+ // Put bean instance to ViewRoot.
+ String beanAttributeName =
isAjaxOnly?AjaxPhaseListener.AJAX_BEAN_PREFIX:AjaxPhaseListener.VIEW_BEAN_PREFIX+beanName;
+ facesContext.getViewRoot().getAttributes().put(beanAttributeName, bean);
+ return Tag.SKIP_BODY;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.jsp.tagext.TagSupport#release()
+ */
+ public void release() {
+ beanName = null;
+ ajaxOnly = null;
+ super.release();
+ }
+
+
+}
Copied:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
(from rev 1388,
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java)
===================================================================
---
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
(rev 0)
+++
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -0,0 +1,189 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.taglib.html.jsp;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import javax.servlet.jsp.JspWriter;
+
+import org.ajax4jsf.io.FastBufferOutputStream;
+
+
+
+/**
+ * ServletResponseWrapper used by the JSP 'include' action.
+ *
+ * This wrapper response object is passed to RequestDispatcher.include(), so
+ * that the output of the included resource is appended to that of the including
+ * page.
+ *
+ * @author Pierre Delisle
+ */
+
+public class ServletResponseWrapperInclude extends HttpServletResponseWrapper {
+
+ /**
+ * PrintWriter which appends to the JspWriter of the including page.
+ */
+ private PrintWriter _printWriter;
+
+ private FastBufferOutputStream _bytes ;
+
+ private ServletOutputStream _servletStream;
+
+ private JspWriter _jspWriter;
+
+ private boolean useWriter = false;
+
+ private boolean useStream = false;
+
+ public ServletResponseWrapperInclude(ServletResponse response,
+ JspWriter jspWriter) {
+ super((HttpServletResponse) response);
+ this._printWriter = new PrintWriter(jspWriter);
+ this._jspWriter = jspWriter;
+ }
+
+ /**
+ * Returns a wrapper around the JspWriter of the including page.
+ */
+ public PrintWriter getWriter() throws IOException {
+ if (useStream) {
+ throw new IllegalStateException();
+ }
+ useWriter = true;
+ return _printWriter;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ if(useWriter){
+ throw new IllegalStateException();
+ }
+ if (!useStream) {
+ _bytes = new FastBufferOutputStream(getBufferSize());
+ _servletStream = new ServletOutputStream(){
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ // TODO Auto-generated method stub
+ super.flush();
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len) throws IOException {
+ // TODO Auto-generated method stub
+ _bytes.write(b, off, len);
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[])
+ */
+ public void write(byte[] b) throws IOException {
+ // TODO Auto-generated method stub
+ _bytes.write(b);
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(int)
+ */
+ public void write(int b) throws IOException {
+ _bytes.write(b);
+ }
+
+ };
+ useStream = true;
+ }
+ return _servletStream;
+ }
+
+ /**
+ * Clears the output buffer of the JspWriter associated with the including
+ * page.
+ */
+ public void resetBuffer() {
+ try {
+ _jspWriter.clearBuffer();
+ useWriter = false;
+ useStream = false;
+ _bytes = null;
+ } catch (IOException ioe) {
+ }
+ }
+
+ public void reset() {
+ // TODO Auto-generated method stub
+ resetBuffer();
+ }
+
+ public void flushBuffer() throws IOException {
+ if (useStream) {
+ // TODO - detect encoding ?
+ _bytes.writeTo(_jspWriter, getCharacterEncoding());
+ _bytes = new FastBufferOutputStream(getBufferSize());
+ }
+ }
+
+ // Override ignored methods.
+ public void setBufferSize(int arg0) {
+ }
+
+ public void setContentLength(int arg0) {
+ }
+ public void setContentType(String arg0) {
+ }
+ public void setStatus(int arg0) {
+ }
+ public void setLocale(Locale arg0) {
+ }
+ public void sendRedirect(String arg0) throws IOException {
+ throw new IllegalStateException();
+ }
+// public void setStatus(int arg0, String arg1) {
+// }
+
+}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,71 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.FacesListener;
-import javax.faces.event.FacesEvent;
-
-/**
- * @author Wesley Hales
- */
-public class DataFilterSliderEvent extends FacesEvent {
-
- private Integer oldSliderVal;
- private Integer newSliderVal;
-
- /**
- * Creates a new SliderEvent.
- *
- * @param component the source of the event
- * @param thisOldSliderVal the previously showing item identifier
- * @param thisNewSliderVal the currently showing item identifier
- */
- public DataFilterSliderEvent(UIComponent component, Integer thisOldSliderVal, Integer
thisNewSliderVal) {
- super(component);
- setPhaseId(PhaseId.INVOKE_APPLICATION);
- oldSliderVal = thisOldSliderVal;
- newSliderVal = thisNewSliderVal;
- }
-
- public Integer getOldSliderVal() {
- return oldSliderVal;
- }
-
- public Integer getNewSliderVal() {
- return newSliderVal;
- }
-
- public boolean isAppropriateListener(FacesListener listener){
- return (listener instanceof DataFilterSliderListener);
- }
-
- /**
- * Delivers this event to the SliderListener.
- *
- * @param listener the slider listener
- */
- public void processListener(FacesListener listener){
- ((DataFilterSliderListener) listener).processSlider(this);
- }
-}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderListener.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Wesley Hales
- */
-public interface DataFilterSliderListener extends FacesListener {
-
- public void processSlider(org.richfaces.event.DataFilterSliderEvent event);
-
-}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderSource.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderSource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/event/DataFilterSliderSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-/**
- * @author Wesley Hales
- */
-public interface DataFilterSliderSource {
-
- /**
- * Adds a DataFilterSliderListener to this DataFilterSliderSource.
- *
- * @param listener the Slider listener to be added
- */
- public void addSliderListener(org.richfaces.event.DataFilterSliderListener
listener);
-
- /**
- * Removes a DataFilterSliderListener from this DataFilterSliderSource.
- *
- * @param listener the Slider listener to be removed
- */
- public void removeSliderListener(DataFilterSliderListener listener);
-
- /**
- * Returns all SliderListeners for this DataFilterSliderSource.
- *
- * @return the Slider listener array
- */
- public DataFilterSliderListener[] getSliderListeners();
-
-}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderAdapter.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderAdapter.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderAdapter.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.events;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.el.MethodBinding;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Wesley Hales
- */
-public class DataFilterSliderAdapter implements DataFilterSliderListener, StateHolder {
-
- public static Class[] SIGNATURE = new Class[] { DataFilterSliderEvent.class };
-
- private MethodBinding sliderMethod;
- private boolean sliderTransient;
-
- /**
- * empty constructor needed.
- *
- */
- public DataFilterSliderAdapter() {
- }
-
- /**
- * Creates a new DataFilterSliderAdapter.
- *
- * @param mySliderMethod the MethodBinding to adapt
- */
- public DataFilterSliderAdapter(MethodBinding mySliderMethod) {
- sliderMethod = mySliderMethod;
- }
-
- /**
- * Processes a SliderEvent.
- *
- * @param event the slider event
- */
- public void processSlider(DataFilterSliderEvent event) {
- FacesContext context = FacesContext.getCurrentInstance();
- sliderMethod.invoke(context, new Object[]{event});
- }
-
- /**
- * Saves the internal state of this DataFilterSliderAdapter.
- *
- * @param context the Faces context
- *
- * @return the saved state
- */
- public Object saveState(FacesContext context) {
- return UIComponentBase.saveAttachedState(context, sliderMethod);
- }
-
- /**
- * Restores the internal state of this DataFilterSliderAdapter.
- *
- * @param context the Faces context
- * @param object the state to restore
- */
- public void restoreState(FacesContext context, Object object){
- sliderMethod = (MethodBinding) UIComponentBase.restoreAttachedState(context,
object);
- }
-
- /**
- * Returns true if this DataFilterSliderAdapter is transient and should
- * not be state saved, otherwise false.
- *
- * @return the value of transient
- */
- public boolean isTransient() {
- return sliderTransient;
- }
-
- /**
- * Indicates whether or not this DataFilterSliderAdapter is transient and should
- * not be state saved.
- *
- * @param isTransient the new value for transient
- */
- public void setTransient(
-
- boolean isTransient) {
- sliderTransient = isTransient;
- }
-
-}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderEvent.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,73 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.events;
-
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.FacesListener;
-import javax.faces.event.FacesEvent;
-
-/**
- * @author Wesley Hales
- */
-public class DataFilterSliderEvent extends FacesEvent {
-
- private Integer oldSliderVal;
- private Integer newSliderVal;
-
- /**
- * Creates a new SliderEvent.
- *
- * @param component the source of the event
- * @param thisOldSliderVal the previously showing item identifier
- * @param thisNewSliderVal the currently showing item identifier
- */
- public DataFilterSliderEvent(UIComponent component, Integer thisOldSliderVal, Integer
thisNewSliderVal) {
- super(component);
- setPhaseId(PhaseId.INVOKE_APPLICATION);
- oldSliderVal = thisOldSliderVal;
- newSliderVal = thisNewSliderVal;
- }
-
- public Integer getOldSliderVal() {
- return oldSliderVal;
- }
-
- public Integer getNewSliderVal() {
- return newSliderVal;
- }
-
- public boolean isAppropriateListener(FacesListener listener){
- return (listener instanceof DataFilterSliderListener);
- }
-
- /**
- * Delivers this event to the SliderListener.
- *
- * @param listener the slider listener
- */
- public void processListener(FacesListener listener){
- ((DataFilterSliderListener) listener).processSlider(this);
- }
-}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderListener.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.events;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Wesley Hales
- */
-public interface DataFilterSliderListener extends FacesListener {
-
- public void processSlider(org.richfaces.events.DataFilterSliderEvent event);
-
-}
Deleted:
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderSource.java
===================================================================
---
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderSource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataFilterSlider/src/main/java/org/richfaces/events/DataFilterSliderSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.events;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * @author Wesley Hales
- */
-public interface DataFilterSliderSource {
-
- /**
- * Adds a DataFilterSliderListener to this DataFilterSliderSource.
- *
- * @param listener the Slider listener to be added
- */
- public void addSliderListener(org.richfaces.events.DataFilterSliderListener
listener);
-
- /**
- * Removes a DataFilterSliderListener from this DataFilterSliderSource.
- *
- * @param listener the Slider listener to be removed
- */
- public void removeSliderListener(DataFilterSliderListener listener);
-
- /**
- * Returns all SliderListeners for this DataFilterSliderSource.
- *
- * @return the Slider listener array
- */
- public DataFilterSliderListener[] getSliderListeners();
-
-}
Deleted:
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Column.java
===================================================================
---
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Column.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Column.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,45 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-/**
- * Marker interface for all components used as column in UIDataTable
- * @author shura
- *
- */
-public interface Column {
-
-
- /**
- * Out this column on new row
- * @parameter
- * @return the acceptClass
- */
- public abstract boolean isBreakBefore();
-
- /**
- * @param newBreakBefore the value to set
- */
- public abstract void setBreakBefore(boolean newBreakBefore);
-
-
-}
Deleted: branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Row.java
===================================================================
---
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Row.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/dataTable/src/main/java/org/richfaces/component/Row.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,39 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.util.Iterator;
-
-/**
- * Marker interface for table columns, rendered as entire row.
- * @author shura
- *
- */
-public interface Row extends Column {
-
- /**
- * Get iterator for all columns contained in this row.
- * @return
- */
- public Iterator columns();
-
-}
Deleted:
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
---
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,80 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Wesley Hales
- */
-public class DataScrollerEvent extends ActionEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 2657353903701932561L;
- private String oldScrolVal;
- private String newScrolVal;
-
- /**
- * Creates a new ScrollerEvent.
- *
- * @param component the source of the event
- * @param thisOldScrolVal the previously showing item identifier
- * @param thisNewScrolVal the currently showing item identifier
- */
- public DataScrollerEvent(UIComponent component, String thisOldScrolVal, String
thisNewScrolVal) {
- super(component);
- oldScrolVal = thisOldScrolVal;
- newScrolVal = thisNewScrolVal;
- }
-
- public String getOldScrolVal() {
- return oldScrolVal;
- }
-
- public String getNewScrolVal() {
- return newScrolVal;
- }
-
- public boolean isAppropriateListener(FacesListener listener){
- return super.isAppropriateListener(listener) || (listener instanceof
DataScrollerListener);
- }
-
- /**
- * Delivers this event to the SliderListener.
- *
- * @param listener the slider listener
- */
- public void processListener(FacesListener listener){
- if (listener instanceof DataScrollerListener) {
- DataScrollerListener dataScrollerListener = (DataScrollerListener) listener;
- dataScrollerListener.processScroller(this);
- }
-
- if (super.isAppropriateListener(listener)) {
- super.processListener(listener);
- }
- }
-}
Deleted:
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java
===================================================================
---
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,31 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-
-public interface DataScrollerListener extends FacesListener {
-
- public void processScroller(org.richfaces.event.DataScrollerEvent event);
-
-}
Deleted:
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java
===================================================================
---
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,47 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-public interface DataScrollerSource {
-
- /**
- * Adds a DataScrollerListener to this DataScrollerSource.
- *
- * @param listener the Scroler listener to be added
- */
- public void addScrollerListener(org.richfaces.event.DataScrollerListener listener);
-
- /**
- * Removes a DataFilterSliderListener from this DataScrollerSourceSource.
- *
- * @param listener the Scroler listener to be removed
- */
- public void removeScrollerListener(DataScrollerListener listener);
-
- /**
- * Returns all ScrollerListeners for this DataScrollerSource.
- *
- * @return the Scroler listener array
- */
- public DataScrollerListener[] getScrollerListeners();
-
-}
Deleted:
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/ISimpleToggleListener.java
===================================================================
---
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/ISimpleToggleListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/ISimpleToggleListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Created on 11.07.2006
- */
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author igels
- */
-
-//TODO by nick - denis - add addToggleListener method to component
-public interface ISimpleToggleListener extends FacesListener {
-
- public void processToggle(SimpleToggleEvent event);
-
-}
\ No newline at end of file
Deleted:
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/SimpleToggleEvent.java
===================================================================
---
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/SimpleToggleEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/simpleTogglePanel/src/main/java/org/richfaces/event/SimpleToggleEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,76 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Created on 11.07.2006
- */
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author igels
- */
-public class SimpleToggleEvent extends ActionEvent {
-
- private static final long serialVersionUID = 5582624805941635421L;
- private boolean _opened;
-
- /**
- * @param source
- * @param opened
- */
- public SimpleToggleEvent(UIComponent source, boolean opened) {
- super(source);
- this._opened = opened;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof ISimpleToggleListener;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- ((ISimpleToggleListener) listener).processToggle(this);
- }
-
- /**
- * @return Returns the _state.
- */
- public boolean isIsOpen() {
- return _opened;
- }
-
- /**
- *
- * @param opened The state to set
- */
- public void setIsOpen(boolean opened) {
- this._opened = opened;
- }
-}
\ No newline at end of file
Deleted: branches/refactor1/ui/tabPanel/src/main/java/org/richfaces/model/TabModel.java
===================================================================
---
branches/refactor1/ui/tabPanel/src/main/java/org/richfaces/model/TabModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tabPanel/src/main/java/org/richfaces/model/TabModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,104 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.3 $ $Date: 2007/02/21 20:35:05 $
- */
-public interface TabModel {
-
- /**
- * Get Get internal value for this tab - to store in selectedTab attribute of {@link
org.richfaces.component.UITabPanel}.
- * by default, if no tabValue set, as it's value used ordered number of this tab
in panel.
- *
- * @return Returns the value.
- */
- public Object getName();
-
- /**
- * Set Get internal value for this tab - to store in selectedTab attribute of {@link
org.richfaces.component.UITabPanel}.
- *
- * @param newvalue
- */
- public void setName(Object newvalue);
-
- public boolean isDisabled();
-
- public void setDisabled(boolean disabled);
-
- /**
- * Get label for this tab.
- *
- * @return Returns the label.
- */
- public String getLabel();
-
- /**
- * Set label for this tab.
- *
- * @param newvalue
- */
- public void setLabel(String newvalue);
-
- /**
- * Get width of label for this tab.
- *
- * @return Returns the labelWidth.
- */
- public String getLabelWidth();
-
- /**
- * Set width of label for this tab.
- *
- * @param newvalue
- */
- public void setLabelWidth(String newvalue);
-
- /**
- * Get Tab title - for pop-up message.
- *
- * @return Returns the title.
- */
- public String getTitle();
-
- /**
- * Set Tab title - for pop-up message.
- *
- * @param newvalue
- */
- public void setTitle(String newvalue);
-
- /**
- * Get Tab selection behavior for panel - one of "client",
"server", "ajax", "page".
- *
- * @return Returns the switchType.
- */
- public String getSwitchType();
-
- /**
- * Set Tab selection behavior for panel - one of "client",
"server", "ajax", "page".
- * @param newvalue
- */
- public void setSwitchType(String newvalue);
-}
\ No newline at end of file
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,139 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
-import org.ajax4jsf.ajax.repeat.Range;
-import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
-import org.richfaces.component.state.TreeRange;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 07.12.2006
- * Base class for all tree data models
- */
-public abstract class AbstractTreeDataModel extends ExtendedDataModel {
- public final static char SEPARATOR = NamingContainer.SEPARATOR_CHAR;
-
- private TreeNode wrappedData;
-
- public final int getRowCount() {
- return -1;
- }
-
- public final int getRowIndex() {
- return -1;
- }
-
- public final void setRowIndex(int rowIndex) {
- if(rowIndex!=-1) {
- throw new IllegalArgumentException("In AbstractTreeDataModel rowIndex must be
-1.");
- }
- }
-
- public final Object getWrappedData() {
- return wrappedData;
- }
-
- public final void setWrappedData(Object data) {
- wrappedData = (TreeNode) data;
- }
-
- public final void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object argument) throws IOException {
- walk(context, dataVisitor, range, null, argument, false);
- }
-
- /**
- * walk sub-model having row key argument as its root
- * @param context faces context
- * @param dataVisitor {@link UIDataAdaptor.ComponentVisitor}
- * @param range {@link TreeRange} to constraint the walk
- * @param rowKey row key to treat as root of sub-model
- * @param argument implementation specific argument
- * @param last boolean flag indicating whether we started our walk from last element
- * @throws IOException
- *
- * @see {@link ExtendedDataModel#walk(FacesContext, DataVisitor, Range, Object)}
- */
- public abstract void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last) throws IOException;
-
- /**
- * returns whether this node is leaf
- * @return
- */
- public abstract boolean isLeaf();
-
- /**
- * Walk backing sub-model having row key argument as its root. If there is no backing
model
- * configured, calling this method is equivalent to calling {@link #walk(FacesContext,
DataVisitor, Range, Object, Object, boolean)}
- * @param facesContext faces context
- * @param visitor {@link UIDataAdaptor.ComponentVisitor} instance
- * @param range {@link Range} to constraint the walk
- * @param key row key to treat as root of sub-model
- * @param argument implementation-specific argument
- * @throws IOException
- *
- * @see {@link #walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}
- */
- public abstract void walkModel(FacesContext facesContext, DataVisitor visitor, Range
range, Object key, Object argument, boolean last) throws IOException;
-
- /**
- * Processes concrete tree node. Knows about {@link LastElementAware} interface and
handles it
- * properly. Checks if argument is instance of {@link SubTreeChildrenAppender} and if it
is so
- * does appending current element
- * @param context
- * @param dataVisitor
- * @param argument
- * @param treeRowKey
- * @param last
- * @throws IOException
- */
- protected void processElement(FacesContext context, DataVisitor dataVisitor, Object
argument, TreeRowKey treeRowKey, boolean last) throws IOException {
-// if (argument instanceof SubTreeChildrenAppender) {
-// setRowKey(treeRowKey);
-//
-// if (isRowAvailable()) {
-// ((SubTreeChildrenAppender) argument).addChild(treeRowKey, getRowData(), last,
isLeaf(), getTreeNodeType());
-// }
-// }
-
- if (last && dataVisitor instanceof LastElementAware) {
- try {
- ((LastElementAware) dataVisitor).setLastElement();
- dataVisitor.process(context, treeRowKey, argument);
- } finally {
- ((LastElementAware) dataVisitor).resetLastElement();
- }
- } else {
- dataVisitor.process(context, treeRowKey, argument);
- }
- }
-
- public abstract TreeNode getTreeNode();
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,140 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.Range;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com created 08.01.2007
- *
- */
-public class CacheableTreeDataModel extends TreeDataModel {
-
- private final class Visitor implements DataVisitor, LastElementAware {
- private final DataVisitor visitor;
-
- private Visitor(DataVisitor visitor) {
- this.visitor = visitor;
- }
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
- TreeRowKey treeRowKey = (TreeRowKey) rowKey;
- treeDataModel.setRowKey(treeRowKey);
- locateTreeNode(treeRowKey, true).setData(treeDataModel.getRowData());
-
- if (visitor != null) {
- visitor.process(context, rowKey, argument);
- }
- }
-
- public void resetLastElement() {
- if (visitor instanceof LastElementAware) {
- ((LastElementAware) visitor).resetLastElement();
-
- }
- }
-
- public void setLastElement() {
- if (visitor instanceof LastElementAware) {
- ((LastElementAware) visitor).setLastElement();
-
- }
- }
- }
-
- private TreeDataModel treeDataModel;
-
- public boolean isLeaf() {
- TreeRowKey rowKey = (TreeRowKey) getRowKey();
- TreeNode treeNode = locateTreeNode(rowKey);
- if (treeNode != null && !treeNode.isLeaf()) {
- return false;
- }
-
- treeNode = treeDataModel.locateTreeNode(rowKey);
- if (treeNode != null) {
- return treeNode.isLeaf();
- }
-
- return false;
- }
-
- public CacheableTreeDataModel(TreeDataModel model) {
- super();
- setWrappedData(new TreeNodeImpl());
- setTreeDataModel(model);
- }
-
- public void walkModel(FacesContext context, DataVisitor visitor,
- Range range, Object key, Object argument, boolean last)
- throws IOException {
- treeDataModel.walkModel(context, new Visitor(visitor), range, key,
- argument, last);
- }
-
- public void setTreeDataModel(TreeDataModel treeDataModel) {
- this.treeDataModel = treeDataModel;
- }
-
- public TreeDataModel getTreeDataModel() {
- return treeDataModel;
- }
-
- public void walk(FacesContext context, final DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last)
- throws IOException {
-
- TreeNode cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
- TreeNode treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
-
- if (treeNode != null) {
- if (cachedTreeNode == null || (cachedTreeNode.isLeaf() && !treeNode.isLeaf()))
{
- //fill cache
- treeDataModel.walk(context, new Visitor(dataVisitor), range,
- rowKey, argument, last);
- } else {
- super.walk(context, dataVisitor, range, rowKey, argument, last);
- }
- }
- }
-
- public void setRowData(Object object) {
- (locateTreeNode((TreeRowKey)getRowKey())).setData(object);
- }
-
- public boolean isTransient() {
- return true;
- }
-
- public void setTransient(boolean newTransientValue) {
- if (!newTransientValue) {
- throw new IllegalArgumentException(
- "ReplaceableTreeDataModel shouldn't be transient!");
- }
- }
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/LastElementAware.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/LastElementAware.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/LastElementAware.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,45 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
-
-/**
- * @author Konstantin Mishin
- *
- * {@link UIDataAdaptor.ComponentVisitor} instances can implement this interface in order
to
- * be notified of last element occurence at the current tree level. {@link
#setLastElement()}
- * method is invoked before visiting last element and {@link #resetLastElement()} is
called after
- * visiting last element.
- */
-public interface LastElementAware {
-
- /**
- * The method is invoked to notify that last element occured
- */
- public void setLastElement();
- /**
- * The method is invoked to notify that we're done with last element
- */
- public void resetLastElement();
-
-}
Deleted: branches/refactor1/ui/tree/src/main/java/org/richfaces/component/ListRowKey.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/ListRowKey.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/ListRowKey.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,236 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 17.11.2006
- * Default {@link TreeRowKey} implementation based on {@link ArrayList}
- */
-public class ListRowKey extends TreeRowKey {
-
- private ArrayList path;
-
- /**
- *
- */
- private static final long serialVersionUID = 7718335783201397177L;
-
- public String toString() {
- return getPath();
- }
-
- /**
- * Default constructor
- */
- public ListRowKey() {
- super();
- this.path = new ArrayList();
- }
-
- /**
- * Copy constructor
- * @param parentRowKey row key to clone
- */
- protected ListRowKey(ListRowKey parentRowKey) {
- super();
- this.path = (ArrayList) parentRowKey.path.clone();
- }
-
- /**
- * Appending constructor
- * @param parentRowKey base row key
- * @param pathElement path segment to append to base row key
- */
- public ListRowKey(ListRowKey parentRowKey, Object pathElement) {
- this(parentRowKey);
- this.path.add(pathElement);
- }
-
- private static ArrayList parsePath(String path) {
- ArrayList result = new ArrayList();
-
- String trimmedPath = path.trim();
-
- StringBuffer sb = new StringBuffer();
- boolean escapedState = false;
- int pathLength = trimmedPath.length();
-
- //unescape
- for (int i = 0; i < pathLength; i++) {
- char c = trimmedPath.charAt(i);
-
- if (SEPARATOR_ESCAPE_CHAR == c) {
- if (escapedState) {
- sb.append(c);
- }
- escapedState = !escapedState;
- } else {
- if (c == AbstractTreeDataModel.SEPARATOR) {
- if (escapedState) {
- sb.append(c);
- } else {
- result.add(sb.toString());
- sb = new StringBuffer();
- }
- } else {
- sb.append(c);
- }
-
- escapedState = false;
- }
- }
-
- if (sb.length() != 0) {
- result.add(sb.toString());
- }
-
- return result;
- }
-
- /**
- * List constructor
- * @param list List of strings to create corresponding row key from
- */
- public ListRowKey(List list) {
- super();
-
- this.path = new ArrayList(list);
- }
-
- /**
- * Path object constructor
- * @param path first path segment
- */
- public ListRowKey(Object path) {
- super();
- this.path = new ArrayList(1);
- this.path.add(path);
- }
-
- /**
- * Path string constructor
- * @param path path string to create corresponding row key from
- */
- public ListRowKey(String path) {
- super();
- this.path = parsePath(path);
- }
-
- public int depth() {
- return path.size();
- }
-
- public Iterator iterator() {
- return path.iterator();
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ListRowKey other = (ListRowKey) obj;
- if (path == null) {
- if (other.path != null)
- return false;
- } else if (!path.equals(other.path))
- return false;
- return true;
- }
-
- public Iterator getSubPathIterator(int fromIndex) {
- return path.listIterator(fromIndex);
- }
-
- public boolean isSubKey(TreeRowKey rowKey) {
- if (rowKey instanceof ListRowKey) {
- ListRowKey listRowKey = (ListRowKey) rowKey;
-
- int commonLength = getCommonPathLength(listRowKey);
- if (commonLength != 0) {
- return commonLength == depth();
- } else {
- return rowKey.depth() == 0;
- }
- } else {
- return super.isSubKey(rowKey);
- }
- }
-
- public String getPath() {
- StringBuffer result = new StringBuffer();
- Iterator iterator = path.iterator();
- boolean hasNext = iterator.hasNext();
-
- while (hasNext) {
- String pathSegment = iterator.next().toString();
-
- StringBuffer escapedSubPath = new StringBuffer();
- for (int i = 0; i < pathSegment.length(); i++) {
- char ch = pathSegment.charAt(i);
-
- //escape
- if (AbstractTreeDataModel.SEPARATOR == ch || ListRowKey.SEPARATOR_ESCAPE_CHAR == ch)
{
- escapedSubPath.append(ListRowKey.SEPARATOR_ESCAPE_CHAR);
- }
-
- escapedSubPath.append(ch);
- }
-
- result.append(escapedSubPath.toString());
-
- hasNext = iterator.hasNext();
-
- if (hasNext) {
- result.append(AbstractTreeDataModel.SEPARATOR);
- }
- }
-
- return result.toString();
- }
-
- public int getCommonPathLength(TreeRowKey otherRowKey) {
- if (otherRowKey == null)
- return 0;
- Iterator iterator = this.iterator();
- Iterator otherIterator = otherRowKey.iterator();
- int length = 0;
- while (iterator.hasNext() && otherIterator.hasNext()
- && iterator.next().equals(otherIterator.next()))
- length++;
- return length;
- }
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeDataModel.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeDataModel.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeDataModel.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,223 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.Range;
-import org.richfaces.component.state.TreeRange;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 16.11.2006
- *
- */
-public class TreeDataModel extends AbstractTreeDataModel {
- private TreeRowKey currentRowKey;
-
- private TreeRowKey oldRowKey;
-
- private TreeNode rowTreeData;
-
- public Object getRowKey() {
- return this.currentRowKey;
- }
-
- public void setRowKey(Object rowKey) {
- if (rowKey != null) {
- ListRowKey newRowKey = (ListRowKey) rowKey;
- this.currentRowKey = newRowKey;
- } else {
- this.currentRowKey = null;
- this.oldRowKey = null;
- this.rowTreeData = null;
- }
- }
-
-
- public void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last) throws IOException {
-
- ListRowKey listRowKey = (ListRowKey) rowKey;
-
- TreeNode node = locateTreeNode(listRowKey);
-
- if (node != null) {
- TreeRange treeRange = (TreeRange) range;
-
- if (treeRange == null || treeRange.processNode(listRowKey)) {
-
- if (node.getParent() != null) {
- processElement(context, dataVisitor, argument, listRowKey, last);
- }
-
- if (treeRange == null || treeRange.processChildren(listRowKey)) {
- if (!node.isLeaf()) {
- Iterator children = node.getChildren();
-
- Map.Entry childEntry = children.hasNext() ? (Map.Entry) children.next() : null;
- TreeNode childNode;
- Object identifier;
-
- if (childEntry != null) {
- childNode = (TreeNode) childEntry.getValue();
- identifier = childEntry.getKey();
- } else {
- childNode = null;
- identifier = null;
- }
-
- do {
- Map.Entry nextChildEntry = children.hasNext() ? (Map.Entry) children.next() :
null;
- TreeNode nextChildNode;
- Object nextIdentifier;
-
- if (nextChildEntry != null) {
- nextChildNode = (TreeNode) nextChildEntry.getValue();
- nextIdentifier = nextChildEntry.getKey();
- } else {
- nextChildNode = null;
- nextIdentifier = null;
- }
-
- if (childNode != null) {
-
- boolean isLast = nextChildNode == null;
-
- ListRowKey newRowKey;
- if (rowKey != null) {
- newRowKey = new ListRowKey(listRowKey, identifier);
- } else {
- newRowKey = new ListRowKey(identifier);
- }
-
- this.walk(context, dataVisitor, range, newRowKey, argument, isLast);
- }
-
- identifier = nextIdentifier;
- childNode = nextChildNode;
- } while (childNode != null);
- }
- }
- }
- }
- }
-
- protected TreeNode locateTreeNode(TreeRowKey rowKey) {
- return locateTreeNode(rowKey, false);
- }
-
- protected TreeNode locateTreeNode(TreeRowKey rowKey, boolean allowCreate) {
- boolean useCached = (rowTreeData != null && rowKey != null &&
rowKey.equals(this.oldRowKey));
- if (!useCached) {
- TreeNode rootNode = (TreeNode) getWrappedData();
-
- if (rootNode != null) {
- if (rowKey != null) {
- int commonPathLength = rowKey.getCommonPathLength(oldRowKey);
- if (oldRowKey == null) {
- rowTreeData = rootNode;
- } else {
- int rootOpsCount = rowKey.depth();
- int currentUpOpsCount = oldRowKey.depth() - commonPathLength;
- int currentOpsCount = currentUpOpsCount + rootOpsCount - commonPathLength;
-
- if (rootOpsCount > currentOpsCount) {
- for (int i = 0; i < oldRowKey.depth()
- - commonPathLength; i++) {
-
- rowTreeData = rowTreeData.getParent();
- }
- } else {
- commonPathLength = 0;
- rowTreeData = rootNode;
- oldRowKey = null;
- }
- }
- oldRowKey = rowKey;
- Iterator iterator = rowKey.getSubPathIterator(commonPathLength);
- while (iterator.hasNext()) {
- Object pathSegment = iterator.next();
- TreeNode childRowTreeData = rowTreeData.getChild(pathSegment);
-
- if (childRowTreeData == null) {
- if (!allowCreate) {
- return null;
- } else {
- childRowTreeData = new TreeNodeImpl();
- rowTreeData.addChild(pathSegment, childRowTreeData);
- }
- }
-
- rowTreeData = childRowTreeData;
- }
- } else {
- return rootNode;
- }
- } else {
- return null;
- }
- }
- return rowTreeData;
- }
-
- public boolean isRowAvailable() {
- TreeNode data = locateTreeNode(this.currentRowKey);
-
- if (data != null) {
- return true;
- }
-
- return false;
- }
-
- public Object getRowData() {
- TreeNode treeNode = locateTreeNode(this.currentRowKey);
- if (treeNode != null) {
- return treeNode.getData();
- }
-
- return null;
- }
-
- public boolean isLeaf() {
- TreeNode treeNode = locateTreeNode(this.currentRowKey);
- if (treeNode != null) {
- return treeNode.isLeaf();
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- public void walkModel(FacesContext context, DataVisitor visitor, Range range, Object
key, Object argument, boolean last) throws IOException {
- walk(context, visitor, range, key, argument, last);
- }
-
- public TreeNode getTreeNode() {
- return locateTreeNode(this.currentRowKey);
- }
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeListenerEventsProducer.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.faces.el.MethodBinding;
-
-import org.richfaces.component.events.NodeExpandedListener;
-import org.richfaces.component.events.NodeSelectedListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 29.11.2006
- *
- * Base tree events interface
- */
-public interface TreeListenerEventsProducer {
- public abstract void setChangeExpandListener(MethodBinding binding);
- public abstract MethodBinding getChangeExpandListener();
-
- public abstract void setNodeSelectListener(MethodBinding binding);
- public abstract MethodBinding getNodeSelectListener();
-
- public abstract void setDropListener(MethodBinding binding);
- public abstract MethodBinding getDropListener();
-
- public abstract void setDragListener(MethodBinding binding);
- public abstract MethodBinding getDragListener();
-
- public void addNodeSelectListener(NodeSelectedListener listener);
- public void addChangeExpandListener(NodeExpandedListener listener);
-
- //TODO - rename this
- public boolean hasAjaxSubmitSelection();
-}
Deleted: branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNode.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNode.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNode.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,89 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Map;
-
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- * Interface representing tree ADT nodes
- */
-public interface TreeNode extends Serializable{
-
- /**
- * getter for node attached data
- * @return node attached data
- */
- public Object getData();
- /**
- * setter for node attached data
- * @param data data to set as attached node data
- */
- public void setData(Object data);
-
- /**
- * Returns whether this node is leaf
- * @return <code>true</code> if this node is leaf else returns
<code>false</code>
- */
- public boolean isLeaf();
-
- /**
- * getter for children
- * @return {@link Iterator} of {@link Map.Entry} instances containing {@link TreeNode}
as values
- * and their identifiers as keys
- */
- public Iterator getChildren();
- /**
- * find child by id
- * @param id identifier of the child to find
- * @return designated {@link TreeNode} instance or <code>null</code>
- */
- public TreeNode getChild(Object id);
-
- /**
- * adds child to children collection
- * @param identifier child identifier
- * @param child child
- */
- public void addChild(Object identifier, TreeNode child);
-
- /**
- * removes child from children collection by child id
- * @param id id of the child to remove
- */
- public void removeChild(Object id);
-
- /**
- * getter for parent {@link TreeNode}
- * @return parent {@link TreeNode} instance or <code>null</code> if this
node is root
- */
- public TreeNode getParent();
- /**
- * setter for parent {@link TreeNode}
- * @param parent {@link TreeNode} to set as parent
- */
- public void setParent(TreeNode parent);
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNodeImpl.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNodeImpl.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeNodeImpl.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- * Default {@link TreeNode} implementation based on {@link LinkedHashMap} to preserve
- * elements ordering
- */
-public class TreeNodeImpl implements TreeNode {
-
- private static final long serialVersionUID = -5498990493803705085L;
- private Object data;
- private TreeNode parent;
-
- private Map childrenMap = new LinkedHashMap();
-
- public Object getData() {
- return data;
- }
-
- public TreeNode getChild(Object identifier) {
- return (TreeNode) childrenMap.get(identifier);
- }
-
- public void addChild(Object identifier, TreeNode child) {
- child.setParent(this);
- childrenMap.put(identifier, child);
- }
-
- public void removeChild(Object identifier) {
- TreeNode treeNode = (TreeNode) childrenMap.remove(identifier);
- if (treeNode != null) {
- treeNode.setParent(null);
- }
- }
-
- public void setData(Object data) {
- this.data = data;
- }
-
- public TreeNode getParent() {
- return parent;
- }
-
- public void setParent(TreeNode parent) {
- this.parent = parent;
- }
-
- public Iterator getChildren() {
- return childrenMap.entrySet().iterator();
- }
-
- public boolean isLeaf() {
- return childrenMap.isEmpty();
- }
-
-}
Deleted: branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeRowKey.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeRowKey.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/TreeRowKey.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,85 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 06.12.2006
- * Base abstract clas for all tree row keys
- */
-public abstract class TreeRowKey implements Serializable {
-
- public static final char SEPARATOR_ESCAPE_CHAR = '_';
-
- /**
- * getter for key depth
- * @return key depth
- */
- public abstract int depth();
-
- /**
- * getter for subpath iterator
- * @param fromIndex
- * @return subpath segments iterator
- */
- public abstract Iterator getSubPathIterator(int fromIndex);
-
- /**
- * getter for path string representation
- * @return path string
- */
- public abstract String getPath();
-
- public String toString() {
- return getPath();
- }
-
- /**
- * tests if specified rowKey is sub-key of this row key
- * @param rowKey
- * @return
- */
- public boolean isSubKey(TreeRowKey rowKey) {
- if (rowKey == null) {
- return false;
- }
-
- return (rowKey.getPath() + AbstractTreeDataModel.SEPARATOR).startsWith(getPath());
- }
-
- /**
- * getter for path iterator
- * @return path segments iterator
- */
- public abstract Iterator iterator();
-
- /**
- * returns this row key and otherRowKey argument row key common path segments count
- * @param otherRowKey {@link TreeRowKey} to count common path segments for
- * @return common path segmments count
- */
- public abstract int getCommonPathLength(TreeRowKey otherRowKey);
-
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/AjaxSelectedEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.events;
-
-import javax.faces.component.UIComponent;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class AjaxSelectedEvent extends NodeSelectedEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 1156974665865521208L;
-
- public AjaxSelectedEvent(UIComponent component) {
- super(component);
- }
-
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.events;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public class NodeExpandedEvent extends FacesEvent {
-
- public NodeExpandedEvent(UIComponent component) {
- super(component);
- }
-
- /**
- *
- */
- private static final long serialVersionUID = 2620359072575831666L;
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof NodeExpandedListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- ((NodeExpandedListener) listener).processExpansion(this);
- }
-
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedListener.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeExpandedListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.events;
-
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public interface NodeExpandedListener extends FacesListener {
- public void processExpansion(NodeExpandedEvent nodeExpandedEvent) throws
AbortProcessingException;
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedEvent.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,60 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.events;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public class NodeSelectedEvent extends FacesEvent {
-
- public NodeSelectedEvent(UIComponent component) {
- super(component);
- }
-
- /**
- *
- */
- private static final long serialVersionUID = -1292268859927735863L;
-
- /* (non-Javadoc)
- * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
-
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof NodeSelectedListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
-
- public void processListener(FacesListener listener) {
- ((NodeSelectedListener) listener).processSelection(this);
- }
-
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedListener.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedListener.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/events/NodeSelectedListener.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.events;
-
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public interface NodeSelectedListener extends FacesListener {
- public void processSelection(NodeSelectedEvent nodeSelectedEvent) throws
AbortProcessingException;
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeRange.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeRange.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeRange.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,35 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.state;
-
-import org.ajax4jsf.ajax.repeat.Range;
-import org.richfaces.component.TreeRowKey;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.11.2006
- *
- */
-public interface TreeRange extends Range {
- public boolean processNode(TreeRowKey rowKey);
- public boolean processChildren(TreeRowKey rowKey);
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,60 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.state;
-
-import org.richfaces.component.UITree;
-
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * created 19.06.2007
- *
- * This interface is intended to "advising" changes to tree state. Tree
component should queue user-provided
- * instance of the interface for changes during RENDER_RESPONSE phase. Changes advised by
user should be
- * immediately applied. Advisor methods are provided with {@link UITree} component
instance to queue current
- * tree state.
- */
-public interface TreeStateAdvisor {
- /**
- * Advises new node opened/closed state
- * @param tree {@link UITree} component state to queue state
- * @return
- * <ul>
- * <li><code>null</code> if changes are not needed</li>
- * <li>{@link Boolean#TRUE} to advise node to be opened</li>
- * <li>{@link Boolean#FALSE} to advise node to be closed</li>
- * </ul>
- */
- public Boolean adviseNodeOpened(UITree tree);
-
- /**
- * Advises new node selection
- * @param tree {@link UITree} component state to queue state
- * @return
- * <ul>
- * <li><code>null</code> if changes are not needed</li>
- * <li>{@link Boolean#TRUE} to advise current node to be selected</li>
- * <li>{@link Boolean#FALSE} to advise current node to be
unselected</li>
- * </ul>
- */
- public Boolean adviseNodeSelected(UITree tree);
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlNodeData.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlNodeData.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlNodeData.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.xml;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- *
- */
-public class XmlNodeData implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 8320619478974873168L;
-
- private String namespace;
-
- private String name = "";
-
- private String text;
-
- private Map attributes = new HashMap();
-
- public Map getAttributes() {
- return attributes;
- }
-
- public void setAttribute(String key, Object value) {
- this.attributes.put(key, value);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public String getText() {
- return text != null ? text : "";
- }
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public String toString() {
- return getName() + "{" + attributes.toString() + " <" +
getText().trim() + ">" + "}";
- }
-}
Deleted:
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
===================================================================
---
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java 2007-06-28
19:44:00 UTC (rev 1388)
+++
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java 2007-06-28
19:49:03 UTC (rev 1389)
@@ -1,164 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.xml;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.RulesBase;
-import org.richfaces.component.TreeNode;
-import org.richfaces.component.TreeNodeImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- *
- */
-public class XmlTreeDataBuilder {
-
- private final static class Rule extends org.apache.commons.digester.Rule {
- private int level = -1;
- private List idsList = new ArrayList();
- private List treeNodesList = new ArrayList();
- private List exclusionSets = new ArrayList();
- private TreeNode treeNode = new TreeNodeImpl(); //add empty node to serve as root
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- super.begin(namespace, name, attributes);
-
- level++;
-
- XmlNodeData xmlNodeData = new XmlNodeData();
- xmlNodeData.setName(name);
- xmlNodeData.setNamespace(namespace);
-
- String id = null;
-
- if (attributes != null) {
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- xmlNodeData.setAttribute(attributes.getQName(i),
- attributes.getValue(i));
-
- }
-
- id = attributes.getValue("id");
- }
-
- if (exclusionSets.size() == level) {
- exclusionSets.add(null);
- }
-
- if (id == null || id.length() == 0) {
- int currentId = 0;
-
- if (idsList.size() <= level) {
- for (int i = idsList.size(); i <= level; i++) {
- idsList.add(null);
- }
- } else {
- Integer integer = (Integer) idsList.get(level);
- currentId = integer.intValue() + 1;
- }
-
- Set exclusions = (Set) exclusionSets.get(level);
-
- while (exclusions != null &&
exclusions.contains(Integer.toString(currentId))) {
- currentId++;
- }
-
- idsList.set(level, new Integer(currentId));
-
- id = Integer.toString(currentId);
- } else {
- Set exclusions = (Set) exclusionSets.get(level);
- if (exclusions == null) {
- exclusions = new HashSet();
-
- exclusionSets.set(level, exclusions);
- }
-
- exclusions.add(id);
- }
-
- TreeNode node = new TreeNodeImpl();
- node.setData(xmlNodeData);
-
- this.treeNode.addChild(id, node);
- this.treeNodesList.add(this.treeNode);
- this.treeNode = node;
- }
-
- public void body(String namespace, String name, String text)
- throws Exception {
- super.body(namespace, name, text);
-
- if (text != null) {
- ((XmlNodeData) this.treeNode.getData()).setText(text.trim());
- }
- }
-
- public void end(String namespace, String name) throws Exception {
- super.end(namespace, name);
-
- level--;
-
- if (idsList.size() - 1 > level + 1) {
- //idsList grew larger than we really need
- idsList.remove(idsList.size() - 1);
- }
-
- if (exclusionSets.size() - 1 > level + 1) {
- //the same condition as above
- exclusionSets.remove(exclusionSets.size() - 1);
- }
-
- this.treeNode = (TreeNode) this.treeNodesList.remove(this.treeNodesList.size() - 1);
- }
- }
-
- public static TreeNode build(InputSource inputSource) throws SAXException, IOException
{
- Digester digester = new Digester();
- Rule rule = new Rule();
- final List rulesList = new ArrayList(1);
- rulesList.add(rule);
-
- RulesBase rulesBase = new RulesBase() {
- protected List lookup(String namespace, String name) {
- return rulesList;
- }
- };
- digester.setRules(rulesBase);
- digester.setNamespaceAware(true);
- digester.parse(inputSource);
-
- return rule.treeNode;
- }
-}