JBoss Rich Faces SVN: r1515 - in branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces: event and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-07-06 08:08:29 -0400 (Fri, 06 Jul 2007)
New Revision: 1515
Modified:
branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-409
Modified: branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
--- branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-07-06 12:02:04 UTC (rev 1514)
+++ branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-07-06 12:08:29 UTC (rev 1515)
@@ -21,9 +21,14 @@
package org.richfaces.component;
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.richfaces.event.DataScrollerEvent;
+import org.richfaces.event.DataScrollerListener;
+import org.richfaces.event.DataScrollerSource;
+
import javax.faces.FacesException;
import javax.faces.component.ActionSource;
-import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
@@ -31,19 +36,13 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.richfaces.event.DataScrollerEvent;
-import org.richfaces.event.DataScrollerListener;
-import org.richfaces.event.DataScrollerSource;
-
-/**
- * JSF component class
- */
+/** JSF component class */
//xxxx nick -> alex - extend UIComponentBase and
//create event listener & event classes to define PageSwitchEvent
//public abstract class UIDatascroller extends UIComponentBase implements DataScrollerSource{
-public abstract class UIDatascroller extends UICommand implements DataScrollerSource,ActionSource{
+public abstract class UIDatascroller extends AjaxActionComponent
+ implements DataScrollerSource, ActionSource {
public static final String COMPONENT_TYPE = "org.richfaces.Datascroller";
public static final String COMPONENT_FAMILY = "org.richfaces.Datascroller";
@@ -67,18 +66,22 @@
public static final String NEXT_DISABLED_FACET_NAME = "next_disabled";
- public static final String PREVIOUS_DISABLED_FACET_NAME = "previous_disabled";
+ public static final String PREVIOUS_DISABLED_FACET_NAME
+ = "previous_disabled";
- public static final String FAST_FORWARD_DISABLED_FACET_NAME = "fastforward_disabled";
+ public static final String FAST_FORWARD_DISABLED_FACET_NAME
+ = "fastforward_disabled";
- public static final String FAST_REWIND_DISABLED_FACET_NAME = "fastrewind_disabled";
-
+ public static final String FAST_REWIND_DISABLED_FACET_NAME
+ = "fastrewind_disabled";
+
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
}
public DataScrollerListener[] getScrollerListeners() {
- return (DataScrollerListener[]) getFacesListeners(DataScrollerListener.class);
+ return (DataScrollerListener[]) getFacesListeners(
+ DataScrollerListener.class);
}
public void removeScrollerListener(DataScrollerListener listener) {
@@ -88,16 +91,18 @@
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
if (event instanceof DataScrollerEvent) {
- DataScrollerEvent dataScrollerEvent = (DataScrollerEvent) event;
- setPage(dataScrollerEvent.getNewScrolVal());
+ DataScrollerEvent dataScrollerEvent = (DataScrollerEvent) event;
+ setPage(dataScrollerEvent.getNewScrolVal());
- FacesContext context = FacesContext.getCurrentInstance();
+ FacesContext context = FacesContext.getCurrentInstance();
AjaxRendererUtils.addRegionByName(context, this, this.getId());
AjaxRendererUtils.addRegionByName(context, this, this.getFor());
-
+
+ setupReRender(context);
+
MethodBinding scrollerListener = getScrollerListener();
if (scrollerListener != null) {
- scrollerListener.invoke(context, new Object[] {event});
+ scrollerListener.invoke(context, new Object[]{event});
}
}
}
@@ -153,20 +158,23 @@
public abstract void setStyleClass(String styleClass);
public abstract void setStyle(String styleClass);
-
+
public abstract String getAlign();
public abstract void setAlign(String align);
-
+
public abstract String getBoundaryControls();
+
public abstract void setBoundaryControls(String boundaryControls);
public abstract String getFastControls();
+
public abstract void setFastControls(String fastControls);
public abstract String getStepControls();
+
public abstract void setStepControls(String stepControls);
-
+
/**
* Finds the dataTable which id is mapped to the "for" property
*
@@ -183,16 +191,19 @@
return (UIData) forComp;
}
}
- throw new FacesException("could not dataTable for datascroller " + this.getId());
+ throw new FacesException(
+ "could not dataTable for datascroller " + this.getId());
} else {
forComp = findComponent(forAttribute);
}
if (forComp == null) {
throw new IllegalArgumentException("could not dataTable with id '"
- + forAttribute + "'");
+ + forAttribute + "'");
} else if (!(forComp instanceof UIData)) {
- throw new IllegalArgumentException("component with id '" + forAttribute
- + "' must be of type " + UIData.class.getName() + ", not type "
+ throw new IllegalArgumentException(
+ "component with id '" + forAttribute
+ + "' must be of type " + UIData.class.getName()
+ + ", not type "
+ forComp.getClass().getName());
}
return (UIData) forComp;
@@ -203,7 +214,7 @@
int rows = getRows(uiData);
if (0 == rows) {
throw new FacesException("Missing 'rows' attribute on component '"
- + uiData.getId() + "'");
+ + uiData.getId() + "'");
}
int pageIndex;
@@ -219,7 +230,7 @@
}
return pageIndex;
}
-
+
/**
* Gets the index of the current page
*
@@ -234,7 +245,8 @@
* Sets the page number according to the parameter recived from the
* commandLink
*
- * @param facetName - can be "first:, "last", "next", "previous", "fastforward", "fastrewind"
+ * @param facetName - can be "first:, "last", "next", "previous",
+ * "fastforward", "fastrewind"
*/
public void setPage(String facetName) {
@@ -246,11 +258,15 @@
dataTable.setFirst(0);
} else if (PREVIOUS_FACET_NAME.equals(facetName)) {
int previous = dataTable.getFirst() - getRows(dataTable);
- if (previous >= 0) setFirstRow(previous);
+ if (previous >= 0) {
+ setFirstRow(previous);
+ }
} else if (NEXT_FACET_NAME.equals(facetName)) {
int rows = getRows(dataTable);
int next = dataTable.getFirst() + rows;
- if (next < getRowCount(dataTable)) setFirstRow(next);
+ if (next < getRowCount(dataTable)) {
+ setFirstRow(next);
+ }
//if (rows>0){
// if (((next+rows)/rows)>getMaxPages()){
// next=getMaxPages()*rows-rows;;
@@ -259,11 +275,14 @@
} else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
int fastStep = getFastStep();
int rows = getRows(dataTable);
- if (fastStep <= 0) fastStep = 1;
+ if (fastStep <= 0) {
+ fastStep = 1;
+ }
int next = dataTable.getFirst() + rows * fastStep;
int rowcount = getRowCount(dataTable);
- if (next >= rowcount)
+ if (next >= rowcount) {
next = (rowcount - 1) - ((rowcount - 1) % rows);
+ }
//if (rows>0){
// if (((next+rows)/rows)>getMaxPages()){
// next=getMaxPages()*rows-rows;;
@@ -272,16 +291,20 @@
setFirstRow(next);
} else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
int fastStep = getFastStep();
- if (fastStep <= 0) fastStep = 1;
+ if (fastStep <= 0) {
+ fastStep = 1;
+ }
int previous = dataTable.getFirst() - getRows(dataTable) * fastStep;
- if (previous < 0) previous = 0;
+ if (previous < 0) {
+ previous = 0;
+ }
setFirstRow(previous);
} else if (LAST_FACET_NAME.equals(facetName)) {
int rowcount = getRowCount(dataTable);
int rows = getRows(dataTable);
int delta = rowcount % rows;
int first = delta > 0 && delta < rows ? rowcount - delta : rowcount
- - rows;
+ - rows;
if (first >= 0) {
//if (rows>0){
//if (((first+rows)/rows)>getMaxPages()){
@@ -311,7 +334,7 @@
int rows = getRows(data);
int pageCount;
if (rows > 0) {
- int rowCount = getRowCount(data);
+ int rowCount = getRowCount(data);
pageCount = rows <= 0 ? 1 : rowCount / rows;
if (rowCount % rows > 0) {
pageCount++;
@@ -325,26 +348,22 @@
}
return pageCount;
}
-
- /**
- * @return the page count of the uidata
- */
+
+ /** @return the page count of the uidata */
public int getPageCount() {
return getPageCount(getDataTable());
}
public int getRowCount(UIData data) {
int rowCount = data.getRowCount();
- if (rowCount >= 0) {
- return rowCount;
+ if (rowCount >= 0) {
+ return rowCount;
}
-
- return BinarySearch.search(data);
+
+ return BinarySearch.search(data);
}
-
- /**
- * @return int
- */
+
+ /** @return int */
public int getRowCount() {
//xxx nick -> alex - scrollable models can return -1 here
//let's implement "dychotomic" discovery
@@ -352,7 +371,7 @@
// setPage() { setRowIndex(pageIdx * rows); }
// isPageAvailable() { return isRowAvailable() }
//return getUIData().getRowCount();
- return getRowCount(getDataTable());
+ return getRowCount(getDataTable());
}
public int getRows(UIData data) {
@@ -364,7 +383,7 @@
return row;
}
-
+
// facet getter methods
public UIComponent getFirst() {
return getFacet(FIRST_FACET_NAME);
@@ -391,11 +410,11 @@
}
public int getFirstRow(UIData data) {
- return data.getFirst();
+ return data.getFirst();
}
-
- public void setFirstRow(int rows) {
- getDataTable().setFirst(rows);
+
+ public void setFirstRow(int rows) {
+ getDataTable().setFirst(rows);
//setControls();
}
@@ -404,10 +423,11 @@
}
static class BinarySearch {
+
public static int search(UIData data) {
- int rowIndex = data.getRowIndex();
+ int rowIndex = data.getRowIndex();
try {
- int n = 1;
+ int n = 1;
int k = 2;
for (; ;) {
data.setRowIndex(k - 1);
Modified: branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
--- branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-07-06 12:02:04 UTC (rev 1514)
+++ branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2007-07-06 12:08:29 UTC (rev 1515)
@@ -21,30 +21,30 @@
package org.richfaces.event;
+import org.ajax4jsf.framework.ajax.AjaxActionEvent;
+
import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
import javax.faces.event.FacesListener;
-/**
- * @author Wesley Hales
- */
-public class DataScrollerEvent extends ActionEvent {
+/** @author Wesley Hales */
+public class DataScrollerEvent extends AjaxActionEvent {
/**
- *
- */
- private static final long serialVersionUID = 2657353903701932561L;
- private String oldScrolVal;
- private String newScrolVal;
+ *
+ */
+ 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) {
+ * 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;
@@ -58,23 +58,19 @@
return newScrolVal;
}
- public boolean isAppropriateListener(FacesListener listener){
- return super.isAppropriateListener(listener) || (listener instanceof DataScrollerListener);
+ 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);
- }
-
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener) {
if (super.isAppropriateListener(listener)) {
- super.processListener(listener);
+ super.processListener(listener);
}
}
}
Modified: branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
===================================================================
--- branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2007-07-06 12:02:04 UTC (rev 1514)
+++ branches/3.0.2/richfaces/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2007-07-06 12:08:29 UTC (rev 1515)
@@ -21,14 +21,6 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.ComponentVariables;
import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
@@ -37,253 +29,284 @@
import org.richfaces.component.UIDatascroller;
import org.richfaces.event.DataScrollerEvent;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.PhaseId;
+import java.io.IOException;
+import java.util.Map;
+
public class DataScrollerRenderer extends HeaderResourcesRendererBase {
- protected Class getComponentClass() {
- return UIDatascroller.class;
- }
+ protected Class getComponentClass() {
+ return UIDatascroller.class;
+ }
- public void encodeBegin(FacesContext context, UIComponent component)
- throws IOException {
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
- UIDatascroller scroller = (UIDatascroller) component;
+ UIDatascroller scroller = (UIDatascroller) component;
- UIData dataTable = scroller.getDataTable();
+ UIData dataTable = scroller.getDataTable();
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, component);
- variables.setVariable("dataTable", dataTable);
- if (!(scroller.getPageCount(dataTable) == 1) || (scroller.isRenderIfSinglePage()))
- {
- variables.setVariable("rendered", Boolean.TRUE);
- super.encodeBegin(context, component);
- }
- }
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(
+ this, component);
+ variables.setVariable("dataTable", dataTable);
+ if (!(scroller.getPageCount(dataTable) == 1)
+ || (scroller.isRenderIfSinglePage())) {
+ variables.setVariable("rendered", Boolean.TRUE);
+ super.encodeBegin(context, component);
+ }
+ }
- public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, component);
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(
+ this, component);
- if (Boolean.TRUE.equals(variables.getVariable("rendered")))
- {
- super.encodeEnd(context, component);
- }
- }
+ if (Boolean.TRUE.equals(variables.getVariable("rendered"))) {
+ super.encodeEnd(context, component);
+ }
+ }
- public void decode(FacesContext context, UIComponent component) {
+ public void doDecode(FacesContext context, UIComponent component) {
- String param = (String) getParamMap(context).get(
- component.getClientId(context));
- UIDatascroller scroller = (UIDatascroller) component;
+ String param = (String) getParamMap(context).get(
+ component.getClientId(context));
+ UIDatascroller scroller = (UIDatascroller) component;
- if (param != null) {
- new DataScrollerEvent(scroller, String.valueOf(scroller.getPageIndex()), param).queue();
- }
- }
+ if (param != null) {
+ DataScrollerEvent event = new DataScrollerEvent(scroller,
+ String.valueOf(scroller.getPageIndex()), param);
+ if (scroller.isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
- public ControlsState getControlsState(FacesContext context, UIDatascroller datascroller, UIData dataTable) {
- int pageIndex = datascroller.getPageIndex(dataTable);
- int pageCount = datascroller.getPageCount(dataTable);
- int minPageIdx = 1;
- int maxPageIdx = pageCount;
- int fastStep = datascroller.getFastStep();
- if (fastStep <= 1) {
- fastStep = 1;
- }
+ component.queueEvent(event);
+ }
+ }
- boolean useFirst = true;
- boolean useLast = true;
+ public ControlsState getControlsState(FacesContext context,
+ UIDatascroller datascroller, UIData dataTable) {
+ int pageIndex = datascroller.getPageIndex(dataTable);
+ int pageCount = datascroller.getPageCount(dataTable);
+ int minPageIdx = 1;
+ int maxPageIdx = pageCount;
+ int fastStep = datascroller.getFastStep();
+ if (fastStep <= 1) {
+ fastStep = 1;
+ }
- boolean useBackFast = true;
- boolean useForwFast = true;
+ boolean useFirst = true;
+ boolean useLast = true;
- ControlsState controlsState = new ControlsState();
-
- if (pageIndex <= minPageIdx) {
- useFirst = false;
- }
+ boolean useBackFast = true;
+ boolean useForwFast = true;
- if (pageIndex >= maxPageIdx) {
- useLast = false;
- }
+ ControlsState controlsState = new ControlsState();
- if (pageIndex - fastStep < minPageIdx) {
- useBackFast = false;
- }
+ if (pageIndex <= minPageIdx) {
+ useFirst = false;
+ }
- if (pageIndex + fastStep > maxPageIdx) {
- useForwFast = false;
- }
+ if (pageIndex >= maxPageIdx) {
+ useLast = false;
+ }
- boolean isAuto;
- String boundaryControls = datascroller.getBoundaryControls();
- String stepControls = datascroller.getStepControls();
- String fastControls = datascroller.getFastControls();
-
- if ((isAuto = "auto".equals(boundaryControls)) || "show".equals(boundaryControls)) {
- if (isAuto) {
- controlsState.setFirstRendered(useFirst);
- controlsState.setLastRendered(useLast);
- }
+ if (pageIndex - fastStep < minPageIdx) {
+ useBackFast = false;
+ }
- controlsState.setFirstEnabled(useFirst);
- controlsState.setLastEnabled(useLast);
- } else {
- controlsState.setFirstRendered(false);
- controlsState.setLastRendered(false);
- }
+ if (pageIndex + fastStep > maxPageIdx) {
+ useForwFast = false;
+ }
- if ((isAuto = "auto".equals(stepControls)) || "show".equals(stepControls)) {
- if (isAuto) {
- controlsState.setPreviousRendered(useFirst);
- controlsState.setNextRendered(useLast);
- }
+ boolean isAuto;
+ String boundaryControls = datascroller.getBoundaryControls();
+ String stepControls = datascroller.getStepControls();
+ String fastControls = datascroller.getFastControls();
- controlsState.setPreviousEnabled(useFirst);
- controlsState.setNextEnabled(useLast);
- } else {
- controlsState.setPreviousRendered(false);
- controlsState.setNextRendered(false);
- }
+ if ((isAuto = "auto".equals(boundaryControls)) || "show".equals(
+ boundaryControls)) {
+ if (isAuto) {
+ controlsState.setFirstRendered(useFirst);
+ controlsState.setLastRendered(useLast);
+ }
- if ((isAuto = "auto".equals(fastControls)) || "show".equals(fastControls)) {
- if (isAuto) {
- controlsState.setFastForwardRendered(useForwFast);
- controlsState.setFastRewindRendered(useBackFast);
- }
+ controlsState.setFirstEnabled(useFirst);
+ controlsState.setLastEnabled(useLast);
+ } else {
+ controlsState.setFirstRendered(false);
+ controlsState.setLastRendered(false);
+ }
- controlsState.setFastForwardEnabled(useForwFast);
- controlsState.setFastRewindEnabled(useBackFast);
- } else {
- controlsState.setFastForwardRendered(false);
- controlsState.setFastRewindRendered(false);
- }
-
- return controlsState;
- }
+ if ((isAuto = "auto".equals(stepControls)) || "show".equals(
+ stepControls)) {
+ if (isAuto) {
+ controlsState.setPreviousRendered(useFirst);
+ controlsState.setNextRendered(useLast);
+ }
- public void renderPager(FacesContext context, UIComponent component) throws IOException {
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, component);
- UIData data = (UIData) variables.getVariable("dataTable");
+ controlsState.setPreviousEnabled(useFirst);
+ controlsState.setNextEnabled(useLast);
+ } else {
+ controlsState.setPreviousRendered(false);
+ controlsState.setNextRendered(false);
+ }
- ResponseWriter out = context.getResponseWriter();
- UIDatascroller scroller = (UIDatascroller) component;
- int currentPage = scroller.getPageIndex(data);
+ if ((isAuto = "auto".equals(fastControls)) || "show".equals(
+ fastControls)) {
+ if (isAuto) {
+ controlsState.setFastForwardRendered(useForwFast);
+ controlsState.setFastRewindRendered(useBackFast);
+ }
- int maxPages = scroller.getMaxPages();
- if (maxPages <= 1) {
- maxPages = 1;
- }
- int pageCount = scroller.getPageCount(data);
- if (pageCount <= 1) {
- return;
- }
+ controlsState.setFastForwardEnabled(useForwFast);
+ controlsState.setFastRewindEnabled(useBackFast);
+ } else {
+ controlsState.setFastForwardRendered(false);
+ controlsState.setFastRewindRendered(false);
+ }
- int delta = maxPages / 2;
+ return controlsState;
+ }
- int pages;
- int start;
- if (pageCount > maxPages && currentPage > delta) {
- pages = maxPages;
- start = currentPage - pages / 2 - 1;
- if (start + pages > pageCount) {
- start = pageCount - pages;
- }
- } else {
- pages = pageCount < maxPages ? pageCount : maxPages;
- start = 0;
- }
+ public void renderPager(FacesContext context, UIComponent component)
+ throws IOException {
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(
+ this, component);
+ UIData data = (UIData) variables.getVariable("dataTable");
- for (int i = start, size = start + pages; i < size; i++) {
- //String styleClass;
- //String style;
+ ResponseWriter out = context.getResponseWriter();
+ UIDatascroller scroller = (UIDatascroller) component;
+ int currentPage = scroller.getPageIndex(data);
- boolean isCurrentPage = (i + 1 == currentPage);
- /*
- if (isCurrentPage) {
- styleClass = scroller.getSelectedStyleClass();
- style = scroller.getSelectedStyle();
- }
- else {
- styleClass = scroller.getStyleClass();
- style = scroller.getStyle();
- }
+ int maxPages = scroller.getMaxPages();
+ if (maxPages <= 1) {
+ maxPages = 1;
+ }
+ int pageCount = scroller.getPageCount(data);
+ if (pageCount <= 1) {
+ return;
+ }
- if (style==null){
- style="";
- }
- if (styleClass==null){
- styleClass="";
- }
- */
+ int delta = maxPages / 2;
- out.startElement("td", component);
- if (isCurrentPage) {
- out.writeAttribute("align", "center", null);
- //out.writeAttribute("class", "dr-dscr-act rich-datascr-act "+scroller.getStyleClass(), null);
- out.writeAttribute("class", "dr-dscr-act rich-datascr-act", null);
- out.writeAttribute("style", "" + scroller.getSelectedStyle(), null);
- } else {
- out.writeAttribute("align", "center", null);
- //out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact "+scroller.getStyleClass(), null);
- out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact", null);
- //out.writeAttribute("style", ""+scroller.getStyle(), null);
- out.writeAttribute("onclick", getOnClick(context, component, Integer.toString(i + 1)), null);
- }
- out.writeText(Integer.toString(i + 1), null);
- //renderChild(context, link);
- out.endElement("td");
- }
+ int pages;
+ int start;
+ if (pageCount > maxPages && currentPage > delta) {
+ pages = maxPages;
+ start = currentPage - pages / 2 - 1;
+ if (start + pages > pageCount) {
+ start = pageCount - pages;
+ }
+ } else {
+ pages = pageCount < maxPages ? pageCount : maxPages;
+ start = 0;
+ }
- }
+ for (int i = start, size = start + pages; i < size; i++) {
+ //String styleClass;
+ //String style;
- public void renderPages(FacesContext context, UIComponent component) throws IOException {
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, component);
- UIData data = (UIData) variables.getVariable("dataTable");
+ boolean isCurrentPage = (i + 1 == currentPage);
+ /*
+ if (isCurrentPage) {
+ styleClass = scroller.getSelectedStyleClass();
+ style = scroller.getSelectedStyle();
+ }
+ else {
+ styleClass = scroller.getStyleClass();
+ style = scroller.getStyle();
+ }
- ResponseWriter out = context.getResponseWriter();
- UIDatascroller scroller = (UIDatascroller) component;
- int currentPage = scroller.getPageIndex(data);
+ if (style==null){
+ style="";
+ }
+ if (styleClass==null){
+ styleClass="";
+ }
+ */
- int pageCount = scroller.getPageCount(data);
- if (pageCount <= 1) {
- pageCount = 1;
- }
- String varName = (String)scroller.getAttributes().get("pageIndexVar");
- if (varName != null && varName.length()>0)
- context.getExternalContext()
- .getRequestMap().put(varName, new Integer(currentPage));
- varName = (String)scroller.getAttributes().get("pagesVar");
- if (varName != null && varName.length()>0)
- context.getExternalContext()
- .getRequestMap().put(varName, new Integer(pageCount));
- }
+ out.startElement("td", component);
+ if (isCurrentPage) {
+ out.writeAttribute("align", "center", null);
+ //out.writeAttribute("class", "dr-dscr-act rich-datascr-act "+scroller.getStyleClass(), null);
+ out.writeAttribute("class", "dr-dscr-act rich-datascr-act",
+ null);
+ out.writeAttribute("style", "" + scroller.getSelectedStyle(),
+ null);
+ } else {
+ out.writeAttribute("align", "center", null);
+ //out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact "+scroller.getStyleClass(), null);
+ out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact",
+ null);
+ //out.writeAttribute("style", ""+scroller.getStyle(), null);
+ out.writeAttribute("onclick", getOnClick(context, component,
+ Integer.toString(i + 1)), null);
+ }
+ out.writeText(Integer.toString(i + 1), null);
+ //renderChild(context, link);
+ out.endElement("td");
+ }
- private Map getParamMap(FacesContext context) {
- return context.getExternalContext().getRequestParameterMap();
- }
+ }
- public String getOnClick(FacesContext context, UIComponent component, String value) {
+ public void renderPages(FacesContext context, UIComponent component)
+ throws IOException {
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(
+ this, component);
+ UIData data = (UIData) variables.getVariable("dataTable");
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
- context);
- UIDatascroller scroller = (UIDatascroller) component;
- Map eventOptions = AjaxRendererUtils.buildEventOptions(context, component);
- Map parameters = (Map) eventOptions.get("parameters");
- parameters.put(scroller.getClientId(context), value);
- function.addParameter(eventOptions);
- StringBuffer buffer = new StringBuffer();
- function.appendScript(buffer);
- buffer.append("; return false;");
- String script = buffer.toString();
- return script;
- }
+ ResponseWriter out = context.getResponseWriter();
+ UIDatascroller scroller = (UIDatascroller) component;
+ int currentPage = scroller.getPageIndex(data);
+ int pageCount = scroller.getPageCount(data);
+ if (pageCount <= 1) {
+ pageCount = 1;
+ }
+ String varName = (String) scroller.getAttributes().get("pageIndexVar");
+ if (varName != null && varName.length() > 0) {
+ context.getExternalContext()
+ .getRequestMap().put(varName, new Integer(currentPage));
+ }
+ varName = (String) scroller.getAttributes().get("pagesVar");
+ if (varName != null && varName.length() > 0) {
+ context.getExternalContext()
+ .getRequestMap().put(varName, new Integer(pageCount));
+ }
+ }
- /**
- * Creates HtmlAjaxCommandLink sets its id, value and reRender and UIParameter
- */
- public boolean getRendersChildren() {
- return true;
- }
+ private Map getParamMap(FacesContext context) {
+ return context.getExternalContext().getRequestParameterMap();
+ }
+
+ public String getOnClick(FacesContext context, UIComponent component,
+ String value) {
+
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
+ context);
+ UIDatascroller scroller = (UIDatascroller) component;
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
+ component);
+ Map parameters = (Map) eventOptions.get("parameters");
+ parameters.put(scroller.getClientId(context), value);
+ function.addParameter(eventOptions);
+ StringBuffer buffer = new StringBuffer();
+ function.appendScript(buffer);
+ buffer.append("; return false;");
+ String script = buffer.toString();
+ return script;
+ }
+
+
+ /** Creates HtmlAjaxCommandLink sets its id, value and reRender and UIParameter */
+ public boolean getRendersChildren() {
+ return true;
+ }
}
17 years, 5 months
JBoss Rich Faces SVN: r1514 - branches/3.0.2/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-07-06 08:02:04 -0400 (Fri, 06 Jul 2007)
New Revision: 1514
Modified:
branches/3.0.2/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java
Log:
support for new sorting API
Modified: branches/3.0.2/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java
===================================================================
--- branches/3.0.2/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java 2007-07-06 12:01:09 UTC (rev 1513)
+++ branches/3.0.2/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java 2007-07-06 12:02:04 UTC (rev 1514)
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.richfaces.model.SortField;
import org.richfaces.model.SortOrder;
@@ -255,26 +256,31 @@
protected Comparator <Issue> createComparator(SortOrder sortOrder) {
- int prop = sortOrder.getSortColumn();
- boolean asc = sortOrder.isAscending();
- switch (prop) {
- case 0:
- return asc ? byIdAsc : byIdDesc;
- case 1:
- return asc ? byKeyAsc : byKeyDesc;
- case 2:
- return asc ? bySummaryAsc : bySummaryDesc;
- case 3:
- return asc ? byAssigneeAsc : byAssigneeDesc;
- case 4:
- return asc ? byStatusAsc : byStatusDesc;
- case 5:
- return asc ? byReporterAsc : byReporterDesc;
- case 6:
- return asc ? byPriAsc: byPriDesc;
- case 7:
- return asc ? byResolutionAsc : byResolutionDesc;
+ SortField [] fields = sortOrder.getFields();
+ if (fields != null && fields.length > 0) {
+ SortField field = fields[0];
+ int prop = field.getIndex();
+ boolean asc = field.getAscending().booleanValue();
+
+ switch (prop) {
+ case 0:
+ return asc ? byIdAsc : byIdDesc;
+ case 1:
+ return asc ? byKeyAsc : byKeyDesc;
+ case 2:
+ return asc ? bySummaryAsc : bySummaryDesc;
+ case 3:
+ return asc ? byAssigneeAsc : byAssigneeDesc;
+ case 4:
+ return asc ? byStatusAsc : byStatusDesc;
+ case 5:
+ return asc ? byReporterAsc : byReporterDesc;
+ case 6:
+ return asc ? byPriAsc: byPriDesc;
+ case 7:
+ return asc ? byResolutionAsc : byResolutionDesc;
+ }
}
return null;
17 years, 5 months
JBoss Rich Faces SVN: r1513 - in branches/3.0.2/sandbox/scrollable-grid/src: main/java/org/richfaces/event/sort and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-07-06 08:01:09 -0400 (Fri, 06 Jul 2007)
New Revision: 1513
Added:
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortField.java
Modified:
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java
branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/PropertyResolverComparator.java
branches/3.0.2/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
Log:
support for multiple scrolling
Modified: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-07-06 10:39:38 UTC (rev 1512)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -28,7 +28,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.richfaces.event.scroll.ScrollEvent;
+import org.richfaces.event.sort.MultiColumnSortListener;
+import org.richfaces.event.sort.SingleColumnSortListener;
import org.richfaces.event.sort.SortEvent;
+import org.richfaces.event.sort.SortListener;
import org.richfaces.model.DataModelCache;
import org.richfaces.model.GridDataModel;
import org.richfaces.model.ScrollableGridRange;
@@ -46,7 +49,10 @@
public static final String COMPONENT_TYPE = "org.richfaces.component.ScrollableGrid";
+ public static final String SORT_SINGLE = "single";
+ public static final String SORT_MULTI = "multi";
+
private boolean MODEL_RANGE = false;
private final static Log log = LogFactory.getLog(UIScrollableGrid.class);
@@ -61,6 +67,8 @@
private String scrollPos;
+ private SortListener sortListener;
+
public int getReqRowsCount() {
return reqRowsCount;
}
@@ -202,11 +210,12 @@
public Object saveState(FacesContext context) {
- Object values[] = new Object[3];
+ Object values[] = new Object[4];
values[0] = super.saveState(context);
values[1] = getRanges();
values[2] = scrollPos;
-
+ values[3] = saveAttachedState(context, sortListener);
+
return (Object)values;
}
@@ -216,6 +225,7 @@
super.restoreState(context, values[0]);
setRanges((List)values[1]);
scrollPos = (String)values[2];
+ sortListener = (SortListener) restoreAttachedState(context, values[3]);
}
protected Iterator dataChildren() {
@@ -290,19 +300,10 @@
public void processSortingChange(FacesEvent event){
SortEvent e = (SortEvent)event;
- int sortColumn = e.getSortColumn();
- boolean asc = true;
+ getSortListener().processSort(e);
- SortOrder sortOrder = getSortOrder();
-
- if (sortOrder != null) {
- if (sortOrder.getSortColumn() == sortColumn) {
- asc = !sortOrder.isAscending();
- }
- }
- SortOrder newSortOrder = new SortOrder(sortColumn,asc);
- setSortOrder(newSortOrder);
+
resetDataModel();
getFacesContext().renderResponse();
}
@@ -366,5 +367,22 @@
public void setScrollPos(String scrollPos) {
this.scrollPos = scrollPos;
}
+
+ public SortListener getSortListener() {
+ if (sortListener != null) return sortListener;
+ if (SORT_MULTI.equals(getSortMode())) {
+ return MultiColumnSortListener.INSTANCE;
+ } else {
+ return SingleColumnSortListener.INSTANCE;
+ }
+ }
+
+ public void setSortListener(SortListener sortListener) {
+ this.sortListener = sortListener;
+ }
+ public abstract String getSortMode();
+ public abstract void setSortMode(String mode);
+
+
}
Modified: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java 2007-07-06 10:39:38 UTC (rev 1512)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -37,4 +37,9 @@
public abstract boolean isSortable();
public abstract void setSortable(boolean sortable);
+
+ public abstract String getName();
+
+ public abstract void setName(String name);
+
}
Added: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java (rev 0)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -0,0 +1,87 @@
+/**
+ *
+ */
+package org.richfaces.event.sort;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class MultiColumnSortListener implements SortListener {
+
+ public static final MultiColumnSortListener INSTANCE = new MultiColumnSortListener();
+
+ private MultiColumnSortListener() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.event.sort.SortListener#processSort(org.richfaces.event.sort.SortEvent)
+ */
+ public void processSort(SortEvent e) {
+ UIScrollableGrid grid = (UIScrollableGrid) e.getComponent();
+ int columnIndex = e.getSortColumn();
+ UIScrollableGridColumn column =
+ (UIScrollableGridColumn) grid.getChildren().get(columnIndex);
+ String name = column.getName();
+
+ SortOrder sortOrder = grid.getSortOrder();
+ if (sortOrder == null) {
+ sortOrder = new SortOrder();
+ grid.setSortOrder(sortOrder);
+
+ if (grid.getValueBinding("sortOrder") != null) {
+ grid.getValueBinding("sortOrder").setValue(FacesContext.getCurrentInstance(), sortOrder);
+ }
+
+ }
+
+ SortField[] fields = sortOrder.getFields();
+
+ if (fields == null) {
+ //If no sorting was applied at all, set sorting to current
+ fields = new SortField[] {new SortField(name, columnIndex, Boolean.TRUE)};
+ } else {
+
+ List newFields = Arrays.asList(fields);
+ SortField newField = null;
+
+ for (Iterator iterator = newFields.iterator(); iterator.hasNext() && newField == null; ) {
+ SortField sortField = (SortField) iterator.next();
+ if (sortField.getIndex() == columnIndex ||
+ (sortField.getName() != null &&
+ name != null &&
+ name.equals(sortField.getName()))) {
+
+ Boolean asc = sortField.getAscending();
+ asc = Boolean.TRUE.equals(asc) ? Boolean.FALSE : Boolean.TRUE;
+
+ newField = new SortField(name, columnIndex, asc);
+ iterator.remove();
+
+ }
+ }
+
+ if (newField == null) {
+ newField = new SortField(name, columnIndex, Boolean.TRUE);
+ }
+
+ newFields.add(newField);
+ fields = (SortField[]) newFields.toArray(new SortField[newFields.size()]);
+ }
+
+ sortOrder.setFields(fields);
+ }
+
+
+}
Added: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java (rev 0)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -0,0 +1,71 @@
+/**
+ *
+ */
+package org.richfaces.event.sort;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SingleColumnSortListener implements SortListener {
+
+ public static final SingleColumnSortListener INSTANCE = new SingleColumnSortListener();
+
+ private SingleColumnSortListener() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.event.sort.SortListener#processSort(org.richfaces.event.sort.SortEvent)
+ */
+ public void processSort(SortEvent e) {
+ UIScrollableGrid grid = (UIScrollableGrid) e.getComponent();
+ int columnIndex = e.getSortColumn();
+ UIScrollableGridColumn column =
+ (UIScrollableGridColumn) grid.getChildren().get(columnIndex);
+ String name = column.getName();
+
+ SortOrder sortOrder = grid.getSortOrder();
+ if (sortOrder == null) {
+ sortOrder = new SortOrder();
+ grid.setSortOrder(sortOrder);
+
+ if (grid.getValueBinding("sortOrder") != null) {
+ grid.getValueBinding("sortOrder").setValue(FacesContext.getCurrentInstance(), sortOrder);
+ }
+
+ }
+
+ SortField[] fields = sortOrder.getFields();
+
+ SortField newField = new SortField(name, columnIndex, Boolean.TRUE);
+
+ if (fields != null) {
+ for (int i = 0; i < fields.length; i++) {
+ SortField sortField = fields[i];
+ if (sortField.getIndex() == columnIndex ||
+ (sortField.getName() != null &&
+ name != null &&
+ name.equals(sortField.getName()))) {
+
+ Boolean asc = sortField.getAscending();
+ asc = Boolean.TRUE.equals(asc) ? Boolean.FALSE : Boolean.TRUE;
+
+ newField = new SortField(name, columnIndex, asc);
+ break;
+
+ }
+ }
+ }
+
+ sortOrder.setFields(new SortField[] {newField});
+ }
+
+
+}
Added: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortField.java (rev 0)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortField.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -0,0 +1,89 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SortField implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String name = null;
+ private int index = -1;
+ private Boolean ascending = null;
+
+
+
+ public SortField(String name, int index, Boolean ascending) {
+ super();
+ this.name = name;
+ this.index = index;
+ this.ascending = ascending;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public Boolean getAscending() {
+ return ascending;
+ }
+
+ public void setAscending(Boolean ascending) {
+ this.ascending = ascending;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((ascending == null) ? 0 : ascending.hashCode());
+ result = prime * result + index;
+ result = prime * result + ((name == null) ? 0 : name.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 SortField other = (SortField) obj;
+ if (ascending == null) {
+ if (other.ascending != null)
+ return false;
+ } else if (!ascending.equals(other.ascending))
+ return false;
+ if (index != other.index)
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+
+
+}
Modified: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java 2007-07-06 10:39:38 UTC (rev 1512)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -1,6 +1,7 @@
package org.richfaces.model;
import java.io.Serializable;
+import java.util.Arrays;
/**
*
* @author Maksim Kaszynski
@@ -9,66 +10,61 @@
*/
public class SortOrder implements Serializable {
+ private static int hashCode(Object[] array) {
+ final int prime = 31;
+ if (array == null)
+ return 0;
+ int result = 1;
+ for (int index = 0; index < array.length; index++) {
+ result = prime * result
+ + (array[index] == null ? 0 : array[index].hashCode());
+ }
+ return result;
+ }
+
private static final long serialVersionUID = 2423450561570551363L;
- private boolean ascending;
-
- private int sortColumn = -1;
+ private SortField [] fields;
+ public SortOrder() {
+
+ }
- public SortOrder( int sortColumn, boolean ascending) {
+ public SortOrder(SortField[] fields) {
super();
- this.sortColumn = sortColumn;
- this.ascending = ascending;
+ this.fields = fields;
}
- public SortOrder() {
- super();
- }
- public boolean isAscending() {
- return ascending;
- }
- public void setAscending(boolean ascending) {
- this.ascending = ascending;
+ public SortField[] getFields() {
+ return fields;
}
- public int getSortColumn() {
- return sortColumn;
+ public void setFields(SortField[] fields) {
+ this.fields = fields;
}
- public void setSortColumn(int sortColumn) {
- this.sortColumn = sortColumn;
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + SortOrder.hashCode(fields);
+ return result;
}
- /**
- * @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);
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SortOrder other = (SortOrder) obj;
+ if (!Arrays.equals(fields, other.fields))
+ return false;
+ return true;
}
- public int hashCode() {
- int c = (new Integer(sortColumn)).hashCode();
- if (ascending) {
- c = -c;
- }
- return c;
- }
+
+
}
\ No newline at end of file
Modified: branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/PropertyResolverComparator.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/PropertyResolverComparator.java 2007-07-06 10:39:38 UTC (rev 1512)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/PropertyResolverComparator.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -18,6 +18,7 @@
import javax.faces.el.EvaluationException;
import javax.faces.el.PropertyResolver;
+import org.richfaces.model.SortField;
import org.richfaces.model.SortOrder;
@@ -41,8 +42,11 @@
public int compare(Object arg0, Object arg1) {
int result = 0;
- Object prop1 = null;
+ /*Object prop1 = null;
+ SortField [ sortOrder.getFields();
+ while (result == 0 && )
+
try {
prop1 = resolver.getValue(arg0, sortOrder.getSortColumn());
} catch (EvaluationException e) {
@@ -77,7 +81,7 @@
}
if (!sortOrder.isAscending()) {
result = -result;
- }
+ }*/
return result;
}
Modified: branches/3.0.2/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java 2007-07-06 10:39:38 UTC (rev 1512)
+++ branches/3.0.2/sandbox/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java 2007-07-06 12:01:09 UTC (rev 1513)
@@ -7,6 +7,7 @@
import java.lang.String ;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase ;
+import org.richfaces.model.SortField;
import org.richfaces.model.SortOrder ;
import java.lang.Object ;
import org.richfaces.model.selection.Selection ;
@@ -183,8 +184,7 @@
assertEquals("oncomplete_oncomplete", component.getOncomplete());
component.setValueBinding("sortOrder", new MockValueBinding("sortOrder", org.richfaces.model.SortOrder.class));
SortOrder sortOrder = new SortOrder();
- sortOrder.setSortColumn(2);
- sortOrder.setAscending(true);
+ sortOrder.setFields(new SortField[] {new SortField(null, 2, Boolean.TRUE)});
component.setSortOrder(sortOrder);
assertEquals(sortOrder, component.getSortOrder());
component.setValueBinding("footerClass", new MockValueBinding("footerClass", java.lang.String.class));
17 years, 5 months
JBoss Rich Faces SVN: r1512 - branches/3.0.2/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2007-07-06 06:39:38 -0400 (Fri, 06 Jul 2007)
New Revision: 1512
Modified:
branches/3.0.2/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
Log:
Double initialization check added
Modified: branches/3.0.2/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
===================================================================
--- branches/3.0.2/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-07-06 10:33:43 UTC (rev 1511)
+++ branches/3.0.2/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-07-06 10:39:38 UTC (rev 1512)
@@ -39,11 +39,11 @@
Event.onReady(function(){
grid.init();
});
- /*Utils.execOnLoad(
+ Utils.execOnLoad(
function(){
grid.init();
},
- Utils.Condition.ElementPresent(grid.client_id), 100);*/
+ Utils.Condition.ElementPresent(grid.client_id), 100);
this.endInitTime = (new Date()).getTime();
this.rowCallbacks = [];
17 years, 5 months
JBoss Rich Faces SVN: r1511 - branches/3.0.2/sandbox-samples/scrollable-grid-demo.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-07-06 06:33:43 -0400 (Fri, 06 Jul 2007)
New Revision: 1511
Modified:
branches/3.0.2/sandbox-samples/scrollable-grid-demo/pom.xml
Log:
add neko filter
Modified: branches/3.0.2/sandbox-samples/scrollable-grid-demo/pom.xml
===================================================================
--- branches/3.0.2/sandbox-samples/scrollable-grid-demo/pom.xml 2007-07-05 23:06:10 UTC (rev 1510)
+++ branches/3.0.2/sandbox-samples/scrollable-grid-demo/pom.xml 2007-07-06 10:33:43 UTC (rev 1511)
@@ -25,7 +25,12 @@
<artifactId>richfaces</artifactId>
<version>3.0.2-SNAPSHOT</version>
</dependency>
-
+ <dependency>
+ <groupId>nekohtml</groupId>
+ <artifactId>nekohtml</artifactId>
+ <version>0.9.5</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
17 years, 5 months
JBoss Rich Faces SVN: r1510 - in branches/3.0.2: sandbox/calendar/src/main/java/org/richfaces/renderkit and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-07-05 19:06:10 -0400 (Thu, 05 Jul 2007)
New Revision: 1510
Modified:
branches/3.0.2/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
branches/3.0.2/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
Calendar is AJAXable now
Modified: branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-05 22:14:58 UTC (rev 1509)
+++ branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-05 23:06:10 UTC (rev 1510)
@@ -21,17 +21,31 @@
package org.richfaces.component;
+import java.io.IOException;
+import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
import java.util.TimeZone;
import javax.faces.component.UIInput;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.render.Renderer;
+import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+import org.richfaces.renderkit.CalendarDataModelItemAdaptor;
+import org.richfaces.renderkit.CalendarRendererBase;
+
/**
* JSF component class
*
@@ -75,9 +89,11 @@
Calendar calendar = Calendar.getInstance(getTimeZone(), getLocale());
calendar.setTime(date);
calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
+ /*
//force recalculation
calendar.getTimeInMillis();
calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek());
+ */
return calendar.getTime();
}
@@ -85,9 +101,11 @@
Calendar calendar = Calendar.getInstance(getTimeZone(), getLocale());
calendar.setTime(date);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
+ /*
//force recalculation
calendar.getTimeInMillis();
calendar.set(Calendar.DAY_OF_WEEK, getLastDayOfWeek(calendar));
+ */
return calendar.getTime();
}
@@ -110,6 +128,34 @@
return TimeZone.getDefault();
}
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // TODO Auto-generated method stub
+ super.broadcast(event);
+ if (event instanceof AjaxEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+
+ ajaxContext.setResponseData(getPreload());
+ }
+ }
+
+ public Object getPreload() {
+ Date[] preloadDateRange = getPreloadDateRange();
+ if (preloadDateRange != null && preloadDateRange.length != 0) {
+ CalendarDataModel calendarDataModel = (CalendarDataModel) getData();
+ if (calendarDataModel != null) {
+ CalendarDataModelItem[] calendarDataModelItems = calendarDataModel.getData(preloadDateRange);
+
+ HashMap args = new HashMap();
+ args.put("startDate", CalendarRendererBase.formatDate(preloadDateRange[0]));
+ args.put("days", new AdaptingCollection(calendarDataModelItems));
+ return args;
+ }
+ }
+
+ return null;
+ }
+
public Date[] getPreloadDateRange() {
Date dateRangeBegin = this.getPreloadDateRangeBegin();
Date dateRangeEnd = this.getPreloadDateRangeEnd();
@@ -133,4 +179,48 @@
return (Date[]) dates.toArray(new Date[dates.size()]);
}
+
+
+ public void encodeAjaxChild(FacesContext context, String path, Set ids,
+ Set renderedAreas) throws IOException {
+
+ Renderer renderer = this.getRenderer(context);
+ if (renderer instanceof AjaxChildrenEncoder) {
+ ((AjaxChildrenEncoder) renderer).encodeAjaxChild(context, path, ids, renderedAreas);
+ }
+ }
}
+
+class AdaptingCollection extends AbstractCollection {
+ private CalendarDataModelItem[] items;
+
+ public AdaptingCollection(CalendarDataModelItem[] items) {
+ super();
+ this.items = items;
+ }
+
+ public Iterator iterator() {
+ return new Iterator() {
+ private int idx = 0;
+ private CalendarDataModelItemAdaptor adaptor = new CalendarDataModelItemAdaptor();
+
+ public boolean hasNext() {
+ return idx < items.length;
+ }
+
+ public Object next() {
+ adaptor.setItem(items[idx++]);
+ return adaptor;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+
+ public int size() {
+ return this.items.length;
+ }
+}
Modified: branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-05 22:14:58 UTC (rev 1509)
+++ branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-05 23:06:10 UTC (rev 1510)
@@ -27,12 +27,17 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+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;
import org.richfaces.component.CalendarDataModel;
import org.richfaces.component.CalendarDataModelItem;
@@ -46,6 +51,9 @@
*/
public class CalendarRendererBase extends TemplateEncoderRendererBase {
+ public static final String DATE_SCROLL = "DateScroll";
+
+
/* (non-Javadoc)
* @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
*/
@@ -60,6 +68,28 @@
return HtmlUtil.qualifySize(size.toString());
}
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ super.doDecode(context, component);
+
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ String currentDateString = (String) requestParameterMap.get(clientId + DATE_SCROLL);
+ if (currentDateString != null) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ calendar.set(Calendar.DATE, 1);
+ int idx = currentDateString.indexOf('/');
+ calendar.set(Calendar.MONTH, Integer.parseInt(currentDateString.substring(0, idx)));
+ calendar.set(Calendar.YEAR, Integer.parseInt(currentDateString.substring(idx + 1)));
+
+ ((UICalendar) component).setCurrentDate(calendar.getTime());
+
+ new AjaxEvent(component).queue();
+ }
+ }
+
public void encodeChildren(FacesContext context, UIComponent calendar)
throws IOException {
@@ -74,22 +104,49 @@
}
public void writePreloadBody(FacesContext context, UICalendar calendar) throws IOException {
+ Object preload = calendar.getPreload();
+ if (preload != null) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.write(ScriptUtils.toScript(preload));
+ }
+ }
+
+ public void writeSubmitFunction(FacesContext context, UICalendar calendar) throws IOException {
ResponseWriter writer = context.getResponseWriter();
- Date[] preloadDateRange = calendar.getPreloadDateRange();
- if (preloadDateRange != null && preloadDateRange.length != 0) {
- CalendarDataModel calendarDataModel = (CalendarDataModel) calendar.getData();
- if (calendarDataModel != null) {
- CalendarDataModelItem[] calendarDataModelItems = calendarDataModel.getData(preloadDateRange);
-
- HashMap args = new HashMap();
- args.put("startDate", formatDate(preloadDateRange[0]));
- args.put("days", new AdaptingCollection(calendarDataModelItems));
- writer.write(ScriptUtils.toScript(args));
- }
+
+ String clientId = calendar.getClientId(context);
+
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(calendar, context,
+ AjaxRendererUtils.AJAX_FUNCTION_NAME);
+ ajaxFunction.addParameter(JSReference.NULL);
+ Map options = AjaxRendererUtils.buildEventOptions(context, calendar);
+ options.put("calendar", JSReference.THIS);
+ //ajax single
+ options.put("control", new JSReference(JSReference.THIS.toScript(), "id"));
+
+ String oncomplete = AjaxRendererUtils.getAjaxOncomplete(calendar);
+ JSFunctionDefinition oncompleteDefinition = new JSFunctionDefinition();
+ oncompleteDefinition.addParameter("request");
+ oncompleteDefinition.addParameter("event");
+ oncompleteDefinition.addParameter("data");
+ oncompleteDefinition.addToBody("this.calendar.load(data);");
+ if (oncomplete != null) {
+ oncompleteDefinition.addToBody(oncomplete);
}
+
+ options.put("oncomplete", oncompleteDefinition);
+ Map parametersMap = (Map) options.get("parameters");
+ JSReference requestValue = new JSReference("requestValue");
+ parametersMap.remove(clientId);
+ parametersMap.put(clientId + DATE_SCROLL, requestValue);
+ ajaxFunction.addParameter(options);
+ JSFunctionDefinition definition = new JSFunctionDefinition();
+ definition.addParameter(requestValue);
+ definition.addToBody(ajaxFunction);
+ writer.write(definition.toScript());
}
- protected static Object formatDate(Date date) {
+ public static Object formatDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
JSFunction result = new JSFunction("new Date");
@@ -102,36 +159,3 @@
}
-class AdaptingCollection extends AbstractCollection {
- private CalendarDataModelItem[] items;
-
- public AdaptingCollection(CalendarDataModelItem[] items) {
- super();
- this.items = items;
- }
-
- public Iterator iterator() {
- return new Iterator() {
- private int idx = 0;
- private CalendarDataModelItemAdaptor adaptor = new CalendarDataModelItemAdaptor();
-
- public boolean hasNext() {
- return idx < items.length;
- }
-
- public Object next() {
- adaptor.setItem(items[idx++]);
- return adaptor;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- };
- }
-
- public int size() {
- return this.items.length;
- }
-}
Modified: branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-07-05 22:14:58 UTC (rev 1509)
+++ branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-07-05 23:06:10 UTC (rev 1510)
@@ -3,41 +3,132 @@
xmlns:u='http:/jsf.exadel.com/template/util'
xmlns="http://www.w3.org/1999/xhtml" >
<f:verbatim><![CDATA[
- .Dayclass {
- color: #000000;
- font-weight:bold;
- }
- .Weekendclass {
- color:#800000;
- font-weight:bold;
- }
- .Commondayclass {
- color: #000080;
- }
- .Hovereddayclass {
- color:red;
- }
- .Weekenddayclass {
- color:#800000;
- }
- .Hoveredweekclass {
- color:red;
- }
- .Disableddayclass {
- color:gray;
- }
- .Todayclass {
- background-color: #f0f0f0;
- }
- .Selecteddayclass {
- background-color: #f08080;
- }
- .CalendarSplash {
- background-repeat: no-repeat;
- background-position: center center;
- }
+.calendar_exterior{
+ border : 1px solid #c0c0c0; /*panelBorderColor*/
+}
+.calendar_btn{
+ cursor : pointer;
+}
+.calendar_header{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 7px;
+ height : 22px;
+}
+
+.cell_size{
+ width : 25px;
+ height : 22px;
+}
+
+.calendar_cell{
+ background-color : #FFFFFF; /*generalBackgroundColor*/
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 0px;
+ vertical-align : middle;
+ text-align : center;
+}
+
+.calendar_tool{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color : #224986; /*headerBackgroundColor*/
+ font-size : 11px; /*headerSizeFont*/
+ font-family : verdana; /*headerFamilyFont*/
+ color : #ffffff; /*headerTextColor*/
+ font-weight : bold;
+ vertical-align : middle;
+ text-align : center;
+ width : 25px;
+ height : 22px;
+}
+
+.calendar_month{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ background-color : #224986; /*headerBackgroundColor*/
+ font-size : 11px; /*headerSizeFont*/
+ font-family : verdana; /*headerFamilyFont*/
+ color : #ffffff; /*headerTextColor*/
+ font-weight : bold;
+ vertical-align : middle;
+ text-align : center;
+}
+
+.calendar_days{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 0px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ vertical-align : middle;
+ text-align : center;
+ height : 22px;
+}
+
+.calendar_week{
+ border-bottom : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 1px solid #c0c0c0; /*panelBorderColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ background-color : #f5f5f5; /*unknown parameter - need to add*/
+ vertical-align : middle;
+ text-align : center;
+ width : 25px;
+}
+
+.calendar_holly{
+ background-color : #ffebda; /*unknown parameter - need to add*/
+ color : #ff7800; /*unknown parameter - need to add*/
+}
+
+.calendar_current{
+ background-color : #ff7800; /*unknown parameter - need to add*/
+ color : #ffebda; /*unknown parameter - need to add*/
+ font-weight : bold;
+}
+
+.calendar_spec{
+ background-color : #e4f5e2; /*unknown parameter - need to add*/
+}
+
+.calendar_select{
+ background-color : #224986; /*headerBackgroundColor*/
+ color : #FFFFFF; /*headerTextColor*/
+ font-weight : bold;
+}
+
+
+.right_cell{
+ border-right : 0px;
+}
+
+.bottom_cell{
+ border-bottom : 0px;
+}
+
+.calendar_toolfooter{
+ border-top : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 0px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 0px 7px 0px 7px;
+ height : 22px;
+}
+
+.calendar_footer{
+ border-top : 1px solid #c0c0c0; /*panelBorderColor*/
+ border-right : 0px solid #c0c0c0; /*panelBorderColor*/
+ background : #C7D7EC; /*additionalBackgroundColor*/
+ font-size : 11px; /*generalSizeFont*/
+ font-family : verdana; /*generalFamilyFont*/
+ padding : 7px;
+ height : 22px;
+}
]]>
</f:verbatim>
- <u:selector name=".CalendarSplash">
- </u:selector>
</f:template>
\ No newline at end of file
Modified: branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-05 22:14:58 UTC (rev 1509)
+++ branches/3.0.2/sandbox/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-07-05 23:06:10 UTC (rev 1510)
@@ -111,7 +111,7 @@
this.daysData = {startDate:null, days:[]};
this.days = [];
- var htmlTextHeader = '<div id="div_'+this.params.dayListTableId+'"></div><table cellspacing="0" border="1" frame="void" rules="all" id="'+this.params.dayListTableId+'">\n';
+ var htmlTextHeader = '<div id="div_'+this.params.dayListTableId+'"></div><table border="0" cellpadding="0" cellspacing="0" class="calendar_exterior" id="'+this.params.dayListTableId+'">\n';
var controlsHeaderContext = {
nextYearControl: Calendar.nextYearControl,
previousYearControl: Calendar.previousYearControl,
@@ -158,6 +158,8 @@
obj.innerHTML = htmlTextHeader+htmlControlsHeader+htmlTextWeekDayBar+htmlTextWeek+htmlTextFooter;
this.prepareEvents();
+
+ this.submitFunction = this.params.submitFunction.bind(this);
},
isWeekend: function(weekday) {
@@ -382,12 +384,14 @@
nextMonth: function() {
this.currentDate = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()+1,1);
- this.update();
+ this.submitFunction(this.currentDate.getMonth() + '/' + this.currentDate.getFullYear());
+ //this.update();
},
prevMonth: function() {
this.currentDate = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth()-1,1);
- this.update();
+ this.submitFunction(this.currentDate.getMonth() + '/' + this.currentDate.getFullYear());
+ //this.update();
},
nextYear: function() {
@@ -460,29 +464,29 @@
};
Calendar.header =
- new E('table',{'cellspacing':'0', 'cellpadding':'0', 'border':'0'},
+ new E('table',{'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'width': '100%'},
[
new E('tbody',{},
[
new E('tr',{},
[
- new E('td',{'align':'left', 'width':'1%'},
+ new E('td',{'class': 'calendar_tool calendar_btn'},
[
new ET(function (context) { return Richfaces.eval("previousYearControl", context)})
]),
- new E('td',{'align':'left', 'width':'1%'},
+ new E('td',{'class': 'calendar_tool calendar_btn'},
[
new ET(function (context) { return Richfaces.eval("previousMonthControl", context)})
]),
- new E('td',{'align':'center', 'width':'96%'},
+ new E('td',{'class': 'calendar_month calendar_btn'},
[
new ET(function (context) { return Richfaces.eval("dateControl", context)})
]),
- new E('td',{'align':'right', 'width':'1%'},
+ new E('td',{'class': 'calendar_tool calendar_btn'},
[
new ET(function (context) { return Richfaces.eval("nextMonthControl", context)})
]),
- new E('td',{'align':'right', 'width':'1%'},
+ new E('td',{'class': 'calendar_tool calendar_btn'},
[
new ET(function (context) { return Richfaces.eval("nextYearControl", context)})
])
Modified: branches/3.0.2/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- branches/3.0.2/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-05 22:14:58 UTC (rev 1509)
+++ branches/3.0.2/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-07-05 23:06:10 UTC (rev 1510)
@@ -20,6 +20,10 @@
<script type="text/javascript">
new Calendar('#{clientId}', {
+ submitFunction:
+ <jsp:scriptlet>/*<![CDATA[*/
+ writeSubmitFunction(context, component);
+ /*]]>*/</jsp:scriptlet>,
dayListTableId: '#{clientId}Day',
weekNumberBarId: '#{clientId}WeekNum',
weekDayBarId: '#{clientId}WeekDay',
Modified: branches/3.0.2/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.0.2/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-07-05 22:14:58 UTC (rev 1509)
+++ branches/3.0.2/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-07-05 23:06:10 UTC (rev 1510)
@@ -7,6 +7,7 @@
</head>
<body>
<f:view>
+ <h:form>
<calendar:calendar id="calendar" data="#{calendarDataModel}" locale="#{calendarBean.locale}">
<f:facet name="header">
@@ -31,6 +32,7 @@
<calendar:calendar id="calendar1" />
+ </h:form>
</f:view>
</body>
</html>
17 years, 5 months
JBoss Rich Faces SVN: r1509 - in trunk: framework/test/src/test/java/org/ajax4jsf and 17 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-05 18:14:58 -0400 (Thu, 05 Jul 2007)
New Revision: 1509
Added:
trunk/framework/test/src/test/java/org/ajax4jsf/resource/
trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
Removed:
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/
trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
Modified:
trunk/framework/impl/src/main/resources/META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder
trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
trunk/ui/gmap/src/main/templates/gmap.jspx
trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx
trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java
trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx
trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
trunk/ui/tree/src/main/templates/htmlTree.jspx
Log:
refactoring packages and classes in the implementation project
Modified: trunk/framework/impl/src/main/resources/META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/framework/impl/src/main/resources/META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder 2007-07-05 22:14:58 UTC (rev 1509)
@@ -1 +1 @@
-org.ajax4jsf.framework.resource.ResourceBuilderImpl
+org.ajax4jsf.resource.ResourceBuilderImpl
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource (from rev 1507, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource)
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/AllResourcesTests.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.framework.resource;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author shura (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:10 $
- *
- */
-public class AllResourcesTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.ajax4jsf.resource");
- //$JUnit-BEGIN$
- suite.addTestSuite(ResourceServiceThreadsTestCase.class);
- suite.addTestSuite(InternetResourceServiceTestCase.class);
- suite.addTestSuite(CSSTemplateTestCase.class);
- //$JUnit-END$
- return suite;
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/AllResourcesTests.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/AllResourcesTests.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.resource;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author shura (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:10 $
+ *
+ */
+public class AllResourcesTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.ajax4jsf.resource");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(ResourceServiceThreadsTestCase.class);
+ suite.addTestSuite(InternetResourceServiceTestCase.class);
+ suite.addTestSuite(CSSTemplateTestCase.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -1,186 +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 org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.shale.test.mock.MockPrintWriter;
-
-/**
- * @author shura (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:10 $
- *
- */
-public class CSSTemplateTestCase extends AbstractAjax4JsfTestCase {
-
- private static boolean methodCalled=false;
-
- private static boolean methodParamOk=false;
-
- /**
- * Constructor for CSSTemplateTestCase.
- * @param name
- */
- public CSSTemplateTestCase(String name) {
- super(name);
- }
-
- /*
- * @see VcpJsfTestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- CSSTemplateTestCase.methodCalled=false;
- CSSTemplateTestCase.methodParamOk=false;
- }
-
- /*
- * @see VcpJsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testCallWithContext() throws Exception {
- String templatePath = "org/ajax4jsf/framework/resource/call.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
- ResourceContext context = new FacesResourceContext(facesContext);
- try {
- resource.send(context);
- } catch (IOException e) {
- assertTrue("error send style",false);
- }
- assertTrue(methodCalled);
- }
-
- public static void contextCallWithParam(TemplateContext context,String param) {
- methodCalled = true;
- methodParamOk = "Test".equals(param);
- }
-
- public void testCallWithContextAndParam() throws Exception {
- String templatePath = "org/ajax4jsf/framework/resource/callWithParam.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
- ResourceContext context = new FacesResourceContext(facesContext);
- try {
- resource.send(context);
- } catch (IOException e) {
- assertTrue("error send style",false);
- }
- assertTrue(methodCalled);
- }
-
- public static void contextCall(TemplateContext context) {
- methodCalled = true;
- }
- /*
- * Test method for 'org.ajax4jsf.resource.TemplateCSSResource.send(ResourceContext)'
- */
- public void testSend() throws IOException {
- String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
- ResourceContext context = new FacesResourceContext(facesContext);
- try {
- resource.send(context);
- } catch (IOException e) {
- assertTrue("error send style",false);
- }
- MockPrintWriter printWriter = (MockPrintWriter) response.getWriter();
- String content = String.valueOf(printWriter.content());
- System.out.println(content);
- }
-
- /*
- * Test method for 'org.ajax4jsf.resource.TemplateCSSResource.TemplateCSSResource(String)'
- */
- public void testTemplateCSSResource() throws IOException {
- String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
- assertEquals(templatePath,resource.getKey());
- InternetResource resource2 = InternetResourceBuilder.getInstance().createResource(this,resource.getKey());
- ResourceContext ctx = new FacesResourceContext(this.facesContext);
- InputStream stream = resource.getResourceAsStream(ctx);
- byte[] resourceContent = new byte[8196];
- int length = stream.read(resourceContent);
- InputStream stream2 = resource2.getResourceAsStream(ctx);
- byte[] resource2Content = new byte[8196];
- int length2 = stream2.read(resource2Content);
- assertEquals(length, length2);
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.resource.InternetResourceBase.isCacheable()'
- */
- public void testIsCacheable() {
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.resource.InternetResourceBase.getContentType()'
- */
- public void testGetContentType() {
-
- String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
- assertEquals("text/css",resource.getContentType(null));
-}
-
- /*
- * Test method for 'org.ajax4jsf.resource.InternetResourceBase.getUri(FacesContext, Object)'
- */
- public void testGetUri() {
- String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
-// System.out.println(resource.getUri(facesContext,null));
- String expextedUri = request.getContextPath()+"/"+WebXml.RESOURCE_URI_PREFIX+resource.getKey();
-// System.out.println(expextedUri);
- assertTrue(resource.getUri(facesContext,null).startsWith(expextedUri));
- }
-
- /*
- * Test method for 'org.ajax4jsf.resource.InternetResourceBase.getResourceAsStream(ResourceContext)'
- */
- public void testGetResourceAsStream() {
-
- }
-
- /*
- * Test method for 'org.ajax4jsf.resource.InternetResourceBase.sendHeaders(ResourceContext)'
- */
- public void testSendHeaders() {
- String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
- TemplateCSSResource resource = new TemplateCSSResource(templatePath);
- ResourceContext context = new FacesResourceContext(facesContext);
- resource.sendHeaders(context);
- String header = response.getContentType();
- assertNotNull(header);
- assertTrue(header.startsWith("text/css"));
- }
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -0,0 +1,188 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.FacesResourceContext;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.TemplateCSSResource;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.shale.test.mock.MockPrintWriter;
+
+/**
+ * @author shura (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:10 $
+ *
+ */
+public class CSSTemplateTestCase extends AbstractAjax4JsfTestCase {
+
+ private static boolean methodCalled=false;
+
+ private static boolean methodParamOk=false;
+
+ /**
+ * Constructor for CSSTemplateTestCase.
+ * @param name
+ */
+ public CSSTemplateTestCase(String name) {
+ super(name);
+ }
+
+ /*
+ * @see VcpJsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ CSSTemplateTestCase.methodCalled=false;
+ CSSTemplateTestCase.methodParamOk=false;
+ }
+
+ /*
+ * @see VcpJsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testCallWithContext() throws Exception {
+ String templatePath = "org/ajax4jsf/framework/resource/call.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+ ResourceContext context = new FacesResourceContext(facesContext);
+ try {
+ resource.send(context);
+ } catch (IOException e) {
+ assertTrue("error send style",false);
+ }
+ assertTrue(methodCalled);
+ }
+
+ public static void contextCallWithParam(TemplateContext context,String param) {
+ methodCalled = true;
+ methodParamOk = "Test".equals(param);
+ }
+
+ public void testCallWithContextAndParam() throws Exception {
+ String templatePath = "org/ajax4jsf/framework/resource/callWithParam.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+ ResourceContext context = new FacesResourceContext(facesContext);
+ try {
+ resource.send(context);
+ } catch (IOException e) {
+ assertTrue("error send style",false);
+ }
+ assertTrue(methodCalled);
+ }
+
+ public static void contextCall(TemplateContext context) {
+ methodCalled = true;
+ }
+ /*
+ * Test method for 'org.ajax4jsf.resource.TemplateCSSResource.send(ResourceContext)'
+ */
+ public void testSend() throws IOException {
+ String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+ ResourceContext context = new FacesResourceContext(facesContext);
+ try {
+ resource.send(context);
+ } catch (IOException e) {
+ assertTrue("error send style",false);
+ }
+ MockPrintWriter printWriter = (MockPrintWriter) response.getWriter();
+ String content = String.valueOf(printWriter.content());
+ System.out.println(content);
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.resource.TemplateCSSResource.TemplateCSSResource(String)'
+ */
+ public void testTemplateCSSResource() throws IOException {
+ String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+ assertEquals(templatePath,resource.getKey());
+ InternetResource resource2 = InternetResourceBuilder.getInstance().createResource(this,resource.getKey());
+ ResourceContext ctx = new FacesResourceContext(this.facesContext);
+ InputStream stream = resource.getResourceAsStream(ctx);
+ byte[] resourceContent = new byte[8196];
+ int length = stream.read(resourceContent);
+ InputStream stream2 = resource2.getResourceAsStream(ctx);
+ byte[] resource2Content = new byte[8196];
+ int length2 = stream2.read(resource2Content);
+ assertEquals(length, length2);
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.resource.InternetResourceBase.isCacheable()'
+ */
+ public void testIsCacheable() {
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.resource.InternetResourceBase.getContentType()'
+ */
+ public void testGetContentType() {
+
+ String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+ assertEquals("text/css",resource.getContentType(null));
+}
+
+ /*
+ * Test method for 'org.ajax4jsf.resource.InternetResourceBase.getUri(FacesContext, Object)'
+ */
+ public void testGetUri() {
+ String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+// System.out.println(resource.getUri(facesContext,null));
+ String expextedUri = request.getContextPath()+"/"+WebXml.RESOURCE_URI_PREFIX+resource.getKey();
+// System.out.println(expextedUri);
+ assertTrue(resource.getUri(facesContext,null).startsWith(expextedUri));
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.resource.InternetResourceBase.getResourceAsStream(ResourceContext)'
+ */
+ public void testGetResourceAsStream() {
+
+ }
+
+ /*
+ * Test method for 'org.ajax4jsf.resource.InternetResourceBase.sendHeaders(ResourceContext)'
+ */
+ public void testSendHeaders() {
+ String templatePath = "org/ajax4jsf/framework/resource/styles.xml";
+ TemplateCSSResource resource = new TemplateCSSResource(templatePath);
+ ResourceContext context = new FacesResourceContext(facesContext);
+ resource.sendHeaders(context);
+ String header = response.getContentType();
+ assertNotNull(header);
+ assertTrue(header.startsWith("text/css"));
+ }
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -1,158 +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 org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.shale.test.mock.MockServletOutputStream;
-
-/**
- * @author shura
- *
- */
-public class InternetResourceServiceTestCase extends AbstractAjax4JsfTestCase {
-
- /**
- * @param name
- */
- public InternetResourceServiceTestCase(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- InternetResourceBuilder.setInstance(null);
- }
-
- /**
- * Test method for {@link org.ajax4jsf.resource.InternetResourceService#init(javax.servlet.FilterConfig)}.
- * @throws Exception
- */
- public void testInit() throws Exception {
- InternetResourceService service = new InternetResourceService();
- MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
- mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
- service.init(mockFilterConfig);
- assertSame(servletContext, service.getServletContext());
- }
-
- /**
- * Test method for {@link org.ajax4jsf.resource.InternetResourceService#serviceResource(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
- * @throws IOException
- * @throws Exception
- */
- public void testServiceResource() throws Exception, IOException {
- InternetResourceService service = new InternetResourceService();
- MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
- mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
- service.init(mockFilterConfig);
- InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
- InternetResource resource = builder.createResource(this, "test.js");
- MockResourceRequest resourceRequest = new MockResourceRequest(request);
- String key = resource.getKey();
- service.serviceResource(key,resourceRequest,response);
- byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
- String strContent = new String(content);
- assertEquals(strContent, "\nfunction Test(){};");
- response.setOutputStream(null);
- response.setWriter(null);
- }
-
- /**
- * Test method for {@link org.ajax4jsf.resource.InternetResourceService#serviceResource(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
- * @throws IOException
- * @throws Exception
- */
- public void testCachedServiceResource() throws Exception, IOException {
- InternetResourceService service = new InternetResourceService();
- MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
- mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
- service.init(mockFilterConfig);
- InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
- InternetResource resource = builder.createResource(this, MockCacheableResource.class.getName());
- MockResourceRequest resourceRequest = new MockResourceRequest(request);
- String key = resource.getKey();
- for(int i=1;i<=10;i++){
- service.serviceResource(key,resourceRequest,response);
- byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
- String strContent = new String(content);
- assertEquals(strContent, "test");
- assertEquals(((MockCacheableResource) resource).getCounter(), 1);
- response.setOutputStream(null);
- response.setWriter(null);
- }
- }
-
- /**
- * Test method for {@link org.ajax4jsf.resource.InternetResourceService#serviceResource(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
- * @throws IOException
- * @throws Exception
- */
- public void testCachedServiceExpiration() throws Exception, IOException {
- InternetResourceService service = new InternetResourceService();
- MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
- mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
- service.init(mockFilterConfig);
- InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
- InternetResource resource = builder.createResource(this, MockCacheableResource.class.getName());
- MockResourceRequest resourceRequest = new MockResourceRequest(request);
- String key = resource.getKey();
- for(int j=1;j<=10;j++){
- for(int i=1;i<=10;i++){
- request.setPathElements(request.getContextPath(), request.getServletPath(), request.getPathInfo(), String.valueOf(i));
- service.serviceResource(key,resourceRequest,response);
- byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
- String strContent = new String(content);
- assertEquals(strContent, "test");
- response.setOutputStream(null);
- response.setWriter(null);
- }
- }
- int counter = ((MockCacheableResource) resource).getCounter();
- assertTrue("Resource was generated "+counter+" times", counter<= 10);
- }
-
- public void testSendResource() {
-// fail("Not yet implemented");
- }
-
- /**
- * Test method for {@link org.ajax4jsf.resource.InternetResourceService#getProperties(java.lang.String)}.
- */
- public void testGetProperties() {
-// fail("Not yet implemented");
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/InternetResourceServiceTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -0,0 +1,159 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.InternetResourceService;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.shale.test.mock.MockServletOutputStream;
+
+/**
+ * @author shura
+ *
+ */
+public class InternetResourceServiceTestCase extends AbstractAjax4JsfTestCase {
+
+ /**
+ * @param name
+ */
+ public InternetResourceServiceTestCase(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ InternetResourceBuilder.setInstance(null);
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.resource.InternetResourceService#init(javax.servlet.FilterConfig)}.
+ * @throws Exception
+ */
+ public void testInit() throws Exception {
+ InternetResourceService service = new InternetResourceService();
+ MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
+ mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
+ service.init(mockFilterConfig);
+ assertSame(servletContext, service.getServletContext());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.resource.InternetResourceService#serviceResource(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
+ * @throws IOException
+ * @throws Exception
+ */
+ public void testServiceResource() throws Exception, IOException {
+ InternetResourceService service = new InternetResourceService();
+ MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
+ mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
+ service.init(mockFilterConfig);
+ InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
+ InternetResource resource = builder.createResource(this, "test.js");
+ MockResourceRequest resourceRequest = new MockResourceRequest(request);
+ String key = resource.getKey();
+ service.serviceResource(key,resourceRequest,response);
+ byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
+ String strContent = new String(content);
+ assertEquals(strContent, "\nfunction Test(){};");
+ response.setOutputStream(null);
+ response.setWriter(null);
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.resource.InternetResourceService#serviceResource(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
+ * @throws IOException
+ * @throws Exception
+ */
+ public void testCachedServiceResource() throws Exception, IOException {
+ InternetResourceService service = new InternetResourceService();
+ MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
+ mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
+ service.init(mockFilterConfig);
+ InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
+ InternetResource resource = builder.createResource(this, MockCacheableResource.class.getName());
+ MockResourceRequest resourceRequest = new MockResourceRequest(request);
+ String key = resource.getKey();
+ for(int i=1;i<=10;i++){
+ service.serviceResource(key,resourceRequest,response);
+ byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
+ String strContent = new String(content);
+ assertEquals(strContent, "test");
+ assertEquals(((MockCacheableResource) resource).getCounter(), 1);
+ response.setOutputStream(null);
+ response.setWriter(null);
+ }
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.resource.InternetResourceService#serviceResource(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
+ * @throws IOException
+ * @throws Exception
+ */
+ public void testCachedServiceExpiration() throws Exception, IOException {
+ InternetResourceService service = new InternetResourceService();
+ MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
+ mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
+ service.init(mockFilterConfig);
+ InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
+ InternetResource resource = builder.createResource(this, MockCacheableResource.class.getName());
+ MockResourceRequest resourceRequest = new MockResourceRequest(request);
+ String key = resource.getKey();
+ for(int j=1;j<=10;j++){
+ for(int i=1;i<=10;i++){
+ request.setPathElements(request.getContextPath(), request.getServletPath(), request.getPathInfo(), String.valueOf(i));
+ service.serviceResource(key,resourceRequest,response);
+ byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
+ String strContent = new String(content);
+ assertEquals(strContent, "test");
+ response.setOutputStream(null);
+ response.setWriter(null);
+ }
+ }
+ int counter = ((MockCacheableResource) resource).getCounter();
+ assertTrue("Resource was generated "+counter+" times", counter<= 10);
+ }
+
+ public void testSendResource() {
+// fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.resource.InternetResourceService#getProperties(java.lang.String)}.
+ */
+ public void testGetProperties() {
+// fail("Not yet implemented");
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -1,61 +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.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura
- *
- */
-public class MockCacheableResource extends InternetResourceBase {
-
- private int counter = 0;
-
- public int getCounter() {
- return counter;
- }
-
- /**
- *
- */
- public MockCacheableResource() {
- super();
- setRenderer(new LogfileRenderer());
- setCacheable(true);
- }
-
- public InputStream getResourceAsStream(ResourceContext context) {
- counter++;
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return new ByteArrayInputStream("test".getBytes());
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockCacheableResource.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -0,0 +1,63 @@
+/**
+ * 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.resource;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.LogfileRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura
+ *
+ */
+public class MockCacheableResource extends InternetResourceBase {
+
+ private int counter = 0;
+
+ public int getCounter() {
+ return counter;
+ }
+
+ /**
+ *
+ */
+ public MockCacheableResource() {
+ super();
+ setRenderer(new LogfileRenderer());
+ setCacheable(true);
+ }
+
+ public InputStream getResourceAsStream(ResourceContext context) {
+ counter++;
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return new ByteArrayInputStream("test".getBytes());
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockFilterConfig.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-
-/**
- * @author shura
- *
- */
-public class MockFilterConfig implements FilterConfig {
-
- private ServletContext servletContext;
-
- private Map initParameters = new HashMap();
-
- /**
- * @param servletContext
- */
- public MockFilterConfig(ServletContext servletContext) {
- super();
- this.servletContext = servletContext;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.FilterConfig#getFilterName()
- */
- public String getFilterName() {
- // TODO Auto-generated method stub
- return "A4J";
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.FilterConfig#getInitParameter(java.lang.String)
- */
- public String getInitParameter(String arg0) {
- // TODO Auto-generated method stub
- return (String) initParameters.get(arg0);
- }
-
- public void setInitParameter(String name, String value) {
- initParameters.put(name, value);
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.FilterConfig#getInitParameterNames()
- */
- public Enumeration getInitParameterNames() {
- final Iterator parametersIterator = initParameters.keySet().iterator();
- return new Enumeration(){
-
- public boolean hasMoreElements() {
- // TODO Auto-generated method stub
- return parametersIterator.hasNext();
- }
-
- public Object nextElement() {
- // TODO Auto-generated method stub
- return parametersIterator.next();
- }
-
- };
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.FilterConfig#getServletContext()
- */
- public ServletContext getServletContext() {
- // TODO Auto-generated method stub
- return servletContext;
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockFilterConfig.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockFilterConfig.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.resource;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+
+/**
+ * @author shura
+ *
+ */
+public class MockFilterConfig implements FilterConfig {
+
+ private ServletContext servletContext;
+
+ private Map initParameters = new HashMap();
+
+ /**
+ * @param servletContext
+ */
+ public MockFilterConfig(ServletContext servletContext) {
+ super();
+ this.servletContext = servletContext;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.FilterConfig#getFilterName()
+ */
+ public String getFilterName() {
+ // TODO Auto-generated method stub
+ return "A4J";
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.FilterConfig#getInitParameter(java.lang.String)
+ */
+ public String getInitParameter(String arg0) {
+ // TODO Auto-generated method stub
+ return (String) initParameters.get(arg0);
+ }
+
+ public void setInitParameter(String name, String value) {
+ initParameters.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.FilterConfig#getInitParameterNames()
+ */
+ public Enumeration getInitParameterNames() {
+ final Iterator parametersIterator = initParameters.keySet().iterator();
+ return new Enumeration(){
+
+ public boolean hasMoreElements() {
+ // TODO Auto-generated method stub
+ return parametersIterator.hasNext();
+ }
+
+ public Object nextElement() {
+ // TODO Auto-generated method stub
+ return parametersIterator.next();
+ }
+
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.FilterConfig#getServletContext()
+ */
+ public ServletContext getServletContext() {
+ // TODO Auto-generated method stub
+ return servletContext;
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockResourceRequest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.resource;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-/**
- * @author shura
- *
- */
-public class MockResourceRequest extends HttpServletRequestWrapper {
-
- private String method;
-
- public MockResourceRequest(HttpServletRequest mockRequest) {
- super(mockRequest);
- method = "GET";
- }
-
- public String getMethod() {
- return method;
- }
-
- public void setMethod(String method) {
- this.method = method;
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockResourceRequest.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/MockResourceRequest.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.resource;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * @author shura
+ *
+ */
+public class MockResourceRequest extends HttpServletRequestWrapper {
+
+ private String method;
+
+ public MockResourceRequest(HttpServletRequest mockRequest) {
+ super(mockRequest);
+ method = "GET";
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -1,47 +0,0 @@
-package org.ajax4jsf.framework.resource;
-
-import java.util.Arrays;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-public class ParametersEncodingTestCase extends AbstractAjax4JsfTestCase {
-
- private ResourceBuilderImpl builder;
-
- private byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
- public ParametersEncodingTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- super.setUp();
- builder = new ResourceBuilderImpl();
- }
-
- public void tearDown() throws Exception {
- builder = null;
- super.tearDown();
- }
-
- public final void testEncrypt() {
- byte[] bs = builder.encrypt(data);
- byte[] bs2 = builder.decrypt(bs);
- assertTrue(Arrays.equals(data, bs2));
- }
-
- public final void testDecryptLeak() {
- byte[] bs = {};
- for (int i = 0; i < 10000; i++) {
- bs = builder.encrypt(data);
-
- }
- byte[] bs2={};
- for (int i = 0; i < 10000; i++) {
- bs2 = builder.decrypt(bs);
-
- }
- assertTrue(Arrays.equals(data, bs2));
- }
-
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ParametersEncodingTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -0,0 +1,48 @@
+package org.ajax4jsf.resource;
+
+import java.util.Arrays;
+
+import org.ajax4jsf.resource.ResourceBuilderImpl;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+public class ParametersEncodingTestCase extends AbstractAjax4JsfTestCase {
+
+ private ResourceBuilderImpl builder;
+
+ private byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+
+ public ParametersEncodingTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ builder = new ResourceBuilderImpl();
+ }
+
+ public void tearDown() throws Exception {
+ builder = null;
+ super.tearDown();
+ }
+
+ public final void testEncrypt() {
+ byte[] bs = builder.encrypt(data);
+ byte[] bs2 = builder.decrypt(bs);
+ assertTrue(Arrays.equals(data, bs2));
+ }
+
+ public final void testDecryptLeak() {
+ byte[] bs = {};
+ for (int i = 0; i < 10000; i++) {
+ bs = builder.encrypt(data);
+
+ }
+ byte[] bs2={};
+ for (int i = 0; i < 10000; i++) {
+ bs2 = builder.decrypt(bs);
+
+ }
+ assertTrue(Arrays.equals(data, bs2));
+ }
+
+}
Deleted: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -1,110 +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.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
-import org.apache.shale.test.mock.MockHttpServletRequest;
-import org.apache.shale.test.mock.MockHttpServletResponse;
-import org.apache.shale.test.mock.MockServletOutputStream;
-
-/**
- * @author shura
- *
- */
-public class ResourceServiceThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
-
- /**
- * @param s
- */
- public ResourceServiceThreadsTestCase(String s) {
- super(s);
- // TODO Auto-generated constructor stub
- }
-
- InternetResourceService service;
- String key;
- InternetResource resource;
-
- public void setUp() throws Exception {
- super.setUp();
- service = new InternetResourceService();
- MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
- mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
- service.init(mockFilterConfig);
- InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
- resource = builder.createResource(this, MockCacheableResource.class.getName());
- key = resource.getKey();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- InternetResourceBuilder.setInstance(null);
- resource = null;
- service = null;
- key=null;
- }
-
- public class ResourceRunner extends TestCaseRunnable {
-
- private String data;
-
-
- /**
- * @param data
- */
- public ResourceRunner(String data) {
- super();
- this.data = data;
- }
-
-
- public void runTestCase(FacesContext context) throws Throwable {
- MockHttpServletResponse response = new MockHttpServletResponse();
- MockHttpServletRequest req = new MockHttpServletRequest(session);
- req.setServletContext(servletContext);
- req.setPathElements(request.getContextPath(), request.getServletPath(), request.getPathInfo(), data);
- MockResourceRequest resourceRequest = new MockResourceRequest(req);
- service.serviceResource(key,resourceRequest,response);
- byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
- String strContent = new String(content);
- assertEquals(strContent, "test");
-
- }
-
- }
-
- public void testTreadServiceResource() {
- TestCaseRunnable[] runnables = new TestCaseRunnable[1000];
- for (int i = 0; i < runnables.length; i++) {
- runnables[i] = new ResourceRunner(String.valueOf(i%10));
-
- }
- this.runTestCaseRunnables(runnables);
- int counter = ((MockCacheableResource) resource).getCounter();
- assertTrue("Resource was generated "+counter+" times", counter<= 10);
-
- }
-}
Copied: trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java (from rev 1508, trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java)
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java (rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/ResourceServiceThreadsTestCase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -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.resource;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.InternetResourceService;
+import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
+import org.apache.shale.test.mock.MockHttpServletRequest;
+import org.apache.shale.test.mock.MockHttpServletResponse;
+import org.apache.shale.test.mock.MockServletOutputStream;
+
+/**
+ * @author shura
+ *
+ */
+public class ResourceServiceThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
+
+ /**
+ * @param s
+ */
+ public ResourceServiceThreadsTestCase(String s) {
+ super(s);
+ // TODO Auto-generated constructor stub
+ }
+
+ InternetResourceService service;
+ String key;
+ InternetResource resource;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ service = new InternetResourceService();
+ MockFilterConfig mockFilterConfig = new MockFilterConfig(servletContext);
+ mockFilterConfig.setInitParameter(InternetResourceService.ENABLE_CACHING_PARAMETER, "true");
+ service.init(mockFilterConfig);
+ InternetResourceBuilder builder = InternetResourceBuilder.getInstance();
+ resource = builder.createResource(this, MockCacheableResource.class.getName());
+ key = resource.getKey();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ InternetResourceBuilder.setInstance(null);
+ resource = null;
+ service = null;
+ key=null;
+ }
+
+ public class ResourceRunner extends TestCaseRunnable {
+
+ private String data;
+
+
+ /**
+ * @param data
+ */
+ public ResourceRunner(String data) {
+ super();
+ this.data = data;
+ }
+
+
+ public void runTestCase(FacesContext context) throws Throwable {
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ MockHttpServletRequest req = new MockHttpServletRequest(session);
+ req.setServletContext(servletContext);
+ req.setPathElements(request.getContextPath(), request.getServletPath(), request.getPathInfo(), data);
+ MockResourceRequest resourceRequest = new MockResourceRequest(req);
+ service.serviceResource(key,resourceRequest,response);
+ byte[] content = ((MockServletOutputStream)response.getOutputStream()).content();
+ String strContent = new String(content);
+ assertEquals(strContent, "test");
+
+ }
+
+ }
+
+ public void testTreadServiceResource() {
+ TestCaseRunnable[] runnables = new TestCaseRunnable[1000];
+ for (int i = 0; i < runnables.length; i++) {
+ runnables[i] = new ResourceRunner(String.valueOf(i%10));
+
+ }
+ this.runTestCaseRunnables(runnables);
+ int counter = ((MockCacheableResource) resource).getCounter();
+ assertTrue("Resource was generated "+counter+" times", counter<= 10);
+
+ }
+}
Modified: trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx
===================================================================
--- trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/dataFilterSlider/src/main/templates/dataFilterSlider.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
component="org.richfaces.component.UIDataFltrSlider">
<h:styles>css/dataFilterSlider.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),scripts/scriptaculous-js-1.6.5/src/slider.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),scripts/scriptaculous-js-1.6.5/src/slider.js</h:scripts>
<f:clientid var="clientId"/>
<f:resource name="org.richfaces.renderkit.html.images.SliderArrowImage" var="arrow" />
Modified: trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
--- trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
<h:styles>css/datascroller.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
</h:scripts>
Modified: trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
===================================================================
--- trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
new org.ajax4jsf.dnd.DnDScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
Modified: trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
--- trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
<h:styles>css/dropdownmenu.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
scripts/menu.js
</h:scripts>
Modified: trunk/ui/gmap/src/main/templates/gmap.jspx
===================================================================
--- trunk/ui/gmap/src/main/templates/gmap.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/gmap/src/main/templates/gmap.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -27,7 +27,7 @@
<c:set var="enableDoubleClickZoom" value="#{component.attributes['enableDoubleClickZoom']}"/>
<c:set var="enableContinuousZoom" value="#{component.attributes['enableContinuousZoom']}"/>
<h:styles>css/gmap.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),script/gmap.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),script/gmap.js</h:scripts>
<div id="#{clientId}" class="dr-gmap rich-gmap #{component.attributes['styleClass']}"
x:passThruWithExclusions="id, styleClass"
Modified: trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx
===================================================================
--- trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/inputnumber-slider/src/main/templates/inputNumberSlider.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -10,7 +10,7 @@
component="org.richfaces.component.UIInputNumberSlider"
>
<h:styles>css/slider.xcss</h:styles>
- <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),script/SliderScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js,/org/richfaces/renderkit/html/scripts/events.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),script/SliderScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js,/org/richfaces/renderkit/html/scripts/events.js</h:scripts>
<f:clientid var="clientId"/>
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif" var="spacer" />
Modified: trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -17,7 +17,7 @@
<f:resource name="org.richfaces.renderkit.html.images.buttons.SpinnerButtonDown"
var="down_arrow" />
- <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),script/SpinnerScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.resource.PrototypeScript(),script/SpinnerScript.js,/org/richfaces/renderkit/html/scripts/browser_info.js</h:scripts>
<h:styles>css/spinner.xcss</h:styles>
<table width="2%" class="dr-spnr-c rich-spinner-c #{component.attributes['styleClass']}" id="#{clientId}" cellspacing="0" cellpadding="0" border="0" style="#{component.attributes['style']}">
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -13,7 +13,7 @@
<h:styles>css/menucomponents.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript()
</h:scripts>
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
<h:styles>css/menucomponents.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/ajax4jsf/renderkit/html/scripts/form.js,
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -16,7 +16,7 @@
/org/richfaces/renderkit/html/css/modalPanel.xcss
</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/richfaces/renderkit/html/scripts/modalPanel.js,
/org/richfaces/renderkit/html/scripts/modalPanelBorders.js,
Modified: trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java
===================================================================
--- trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/panelbar/src/main/java/org/richfaces/renderkit/html/PanelBarRendererBase.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -33,8 +33,8 @@
import org.ajax4jsf.framework.ajax.AjaxScript;
import org.ajax4jsf.framework.ajax.ImageCacheScript;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.resource.PrototypeScript;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.UIPanelBar;
import org.richfaces.component.UIPanelBarItem;
import org.richfaces.event.SwitchablePanelSwitchEvent;
Modified: trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
===================================================================
--- trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2007-07-05 22:14:58 UTC (rev 1509)
@@ -37,7 +37,7 @@
import org.ajax4jsf.framework.ajax.AjaxScript;
import org.ajax4jsf.framework.ajax.ImageCacheScript;
-import org.ajax4jsf.framework.resource.PrototypeScript;
+import org.ajax4jsf.resource.PrototypeScript;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.MockViewRoot;
import org.apache.commons.collections.Buffer;
Modified: trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx
===================================================================
--- trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
<f:clientid var="clientId"/>
<h:styles>css/simpleTogglePanel.xcss</h:styles>
<h:scripts>
-new org.ajax4jsf.framework.resource.PrototypeScript(),
+new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
new org.ajax4jsf.framework.ajax.ImageCacheScript(),
/org/ajax4jsf/renderkit/html/scripts/form.js,
Modified: trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
===================================================================
--- trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -12,7 +12,7 @@
<h:styles>css/tabPanel.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
new org.ajax4jsf.framework.ajax.ImageCacheScript(),
/org/richfaces/renderkit/html/scripts/browser_info.js,
Modified: trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
===================================================================
--- trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -11,7 +11,7 @@
component="org.richfaces.component.UIToggleControl">
<h:styles>css/toggleControl.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
scripts/togglePanel.js
</h:scripts> <f:clientid var="clientId"/>
Modified: trunk/ui/tree/src/main/templates/htmlTree.jspx
===================================================================
--- trunk/ui/tree/src/main/templates/htmlTree.jspx 2007-07-05 20:50:37 UTC (rev 1508)
+++ trunk/ui/tree/src/main/templates/htmlTree.jspx 2007-07-05 22:14:58 UTC (rev 1509)
@@ -14,7 +14,7 @@
<h:styles>css/tree.xcss</h:styles>
<h:scripts>
- new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
/org/ajax4jsf/framework/ajax/scripts/AJAX.js,
/org/richfaces/renderkit/html/scripts/utils.js,
/org/ajax4jsf/renderkit/html/scripts/form.js,
17 years, 5 months
JBoss Rich Faces SVN: r1508 - in trunk: framework/impl/src/main/java/org/ajax4jsf/dnd and 34 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-05 16:50:37 -0400 (Thu, 05 Jul 2007)
New Revision: 1508
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html
trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html
trunk/ui/core/src/main/config/resources/resources-config.xml
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java
trunk/framework/test/src/test/java/DnDScriptTest.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java
trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java
trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
Log:
refactoring packages and classes in the implementation project
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -21,7 +21,7 @@
package org.ajax4jsf.dnd;
-import org.ajax4jsf.framework.resource.ClientScript;
+import org.ajax4jsf.resource.ClientScript;
/**
* @author shura
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -24,7 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.ajax4jsf.framework.resource.ClientScript;
+import org.ajax4jsf.resource.ClientScript;
/**
* Resource for AJAX client-side script. Render one time per page.
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -21,7 +21,7 @@
package org.ajax4jsf.framework.ajax;
-import org.ajax4jsf.framework.resource.ClientScript;
+import org.ajax4jsf.resource.ClientScript;
/**
* Resource for Drag ' Drop client javascript
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -41,7 +41,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.resource.InternetResourceService;
+import org.ajax4jsf.resource.InternetResourceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -26,9 +26,9 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.PrototypeScript;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.PrototypeScript;
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -40,9 +40,9 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.Java2Dresource;
/**
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:07 $
- *
- */
-public abstract class BaseResourceRenderer implements ResourceRenderer {
-
- public void encode(InternetResource resource, FacesContext context,
- Object data) throws IOException {
- this.encodeBegin(resource, context, data, Collections.EMPTY_MAP);
- this.encodeEnd(resource, context, data);
- }
-
- public void encode(InternetResource resource, FacesContext context,
- Object data, Map attributes) throws IOException {
- this.encodeBegin(resource, context, data, attributes);
- this.encodeEnd(resource, context, data);
- }
-
- public void encodeBegin(InternetResource resource, FacesContext context,
- Object data, Map attributes) throws IOException {
- if (null != getTag()) {
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(getTag(), null);
- String attrs[][] = getCommonAttrs();
- if (null != getHrefAttr()) {
- writer.writeAttribute(getHrefAttr(), resource.getUri(context,
- data), null);
- }
- if (null != attrs) {
- for (int i = 0; i < attrs.length; i++) {
- writer.writeAttribute(attrs[i][0], attrs[i][1], null);
- }
- }
- for (Iterator iter = attributes.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry attr = (Map.Entry) iter.next();
- writer.writeAttribute(attr.getKey().toString(),
- attr.getValue(), null);
- }
- }
- this.customEncode(resource, context, data);
- }
-
- public void encodeEnd(InternetResource resource, FacesContext context,
- Object data) throws IOException {
- if (null != getTag()) {
- ResponseWriter writer = context.getResponseWriter();
- writer.endElement(getTag());
-
- }
- }
-
- /**
- * Template method for customaize encoding for component. can insert size
- * etc. attributes, child tags etc.
- *
- * @param resource
- * @param context
- * @param component
- * @throws IOException
- */
- protected void customEncode(InternetResource resource,
- FacesContext context, Object data) throws IOException {
- // TODO if concrete renderer need
-
- }
-
- protected abstract String getTag();
-
- protected abstract String getHrefAttr();
-
- protected abstract String[][] getCommonAttrs();
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
- * org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context)
- throws IOException {
- InputStream in = base.getResourceAsStream(context);
- OutputStream out = context.getOutputStream();
- if (null == in) {
- String message = Messages.getMessage(
- Messages.NO_INPUT_STREAM_ERROR, base.getKey());
- throw new IOException(message);
- }
- int total = sendStream(in, out);
-
- return total;
- }
-
- /**
- * @param in
- * @param out
- * @return
- * @throws IOException
- */
- protected int sendStream(InputStream in, OutputStream out)
- throws IOException {
- int total = 0;
- byte[] buffer = new byte[InternetResourceBase.BUFFER_SIZE];
- int length;
- try {
- for (length = in.read(buffer); length > 0; length = in.read(buffer)) {
- out.write(buffer, 0, length);
- total += length;
- }
- } finally {
- in.close();
- out.flush();
- out.close();
- }
- return total;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Object getData(InternetResource base, FacesContext context,
- Object data) {
- // By default, resource dot't provide any data. Can be used in
- // Template-based or other
- // configurable resources ( like weblets configuration ).
- return null;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,43 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.resource;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.InternetResource;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com
- * created 01.05.2007
- *
- */
-public class CacheKey {
- private Object resourceData;
- private HttpServletRequest request;
- private HttpServletResponse response;
- private InternetResource resource;
- public CacheKey(Object resourceData,
- HttpServletRequest request, HttpServletResponse response,
- InternetResource resource) {
- super();
- this.resourceData = resourceData;
- this.request = request;
- this.response = response;
- this.resource = resource;
- }
- public Object getResourceData() {
- return resourceData;
- }
- public HttpServletRequest getRequest() {
- return request;
- }
- public HttpServletResponse getResponse() {
- return response;
- }
- public InternetResource getResource() {
- return resource;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,153 +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;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
- *
- */
-public class CachedResourceContext extends ResourceContext {
- private ResourceContext parent;
- private CacheContent content;
-
- /**
- * @param parent
- */
- public CachedResourceContext(ResourceContext parent) {
- this.setCacheEnabled(true);
- this.parent = parent;
- this.content = new CacheContent();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- return content.getOutputStream();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
- */
- public String getPathInfo() {
- return this.parent.getPathInfo();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
- */
- public String getQueryString() {
- return this.parent.getQueryString();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getRequestParameter(java.lang.String)
- */
- public String getRequestParameter(String data_parameter) {
- return this.parent.getRequestParameter(data_parameter);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getResourceAsStream(java.lang.String)
- */
- public InputStream getResourceAsStream(String path) {
- return this.parent.getResourceAsStream(path);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
- */
- public Object getSessionAttribute(String name) {
- return this.parent.getSessionAttribute(name);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
- */
- public void setDateHeader(String name, long value) {
- this.content.setDateHeader(name,value);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String, java.lang.String)
- */
- public void setHeader(String name, String value) {
- this.content.setHeader(name,value);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
- */
- public void setIntHeader(String name, int value) {
- this.content.setIntHeader(name,value);
- }
-
- /**
- * @return Returns the content.
- */
- CacheContent getContent() {
- return this.content;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getWriter()
- */
- public PrintWriter getWriter() throws IOException {
- return content.getWriter();
- }
-
- public void setContentType(String contentType) {
- this.content.setContentType(contentType);
- }
-
- public Object getResourceData() {
- return parent.getResourceData();
- }
-
- public void setResourceData(Object codec) {
- parent.setResourceData(codec);
-
- }
-
- public String getInitParameter(String name) {
- return parent.getInitParameter(name);
- }
-
- public String getServletPath() {
- return parent.getServletPath();
- }
-
- public void release() {
- super.release();
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,181 +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.Date;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Resource for AJAX client-side script. Render one time per page.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/01/26 14:15:18 $
- *
- */
-public abstract class ClientScript extends JarResource {
-
- private static final Log log = LogFactory.getLog(ClientScript.class);
-
- protected boolean usePrototype = false;
- /**
- * Set JavaScript renderer and modification time to application-startup time.
- */
- public ClientScript() {
- super();
- setRenderer(new ScriptRenderer());
- InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
- String key = this.getClass().getName();
- try {
- // Search already registered resource for this class.
- InternetResource resource = resourceBuilder.getResource(key);
- this.setKey(resource.getKey());
- } catch(ResourceNotFoundException ex){
- // If script not registered, append it to builder.
- setLastModified(new Date(resourceBuilder.getStartTime()));
- resourceBuilder.addResource(key,this);
- }
- String script ;
- if (getJavaScript().startsWith("/")) {
- // remove lead / for classloader covention.
- script = getJavaScript().substring(1);
- } else {
- script = this.getClass().getPackage().getName().replace('.', '/')+"/"
- + getJavaScript();
- }
- setPath(script);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#getLastModified()
- */
- public Date getLastModified(ResourceContext resourceContext) {
-
- if (isCacheable(null)) {
- return super.getLastModified(resourceContext);
- } else {
- return new Date(System.currentTimeMillis()+1000L);
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return true;
- }
-
- /**
- * @return Returns the javaScript.
- */
- public abstract String getJavaScript();
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map attributes) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encode(context, data, attributes);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encodeBegin(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encodeBegin(context, component, attrs);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO, getKey()));
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encodeEnd(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException {
- if (isNotAjaxRequest(context)) {
- super.encodeEnd(context, component);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO, getKey()));
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encode(context, data);
- }else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
- }
- }
-
- /**
- * @return Returns the usePrototype.
- */
- protected boolean isUsePrototype() {
- return usePrototype;
- }
-
-
- private boolean isNotAjaxRequest(FacesContext context){
- return true;//! AjaxRendererUtils.isAjaxRequest(context);
- }
-
- private void encodePrototype(FacesContext context) throws IOException{
- if (isUsePrototype()) {
- InternetResourceBuilder.getInstance().createResource(null,PrototypeScript.class.getName()).encode(context,null);
- }
-
- }
-
-
- /**
- * @param usePrototype the usePrototype to set
- */
- public void setUsePrototype(boolean usePrototype) {
- this.usePrototype = usePrototype;
- }
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,223 +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;
-import java.lang.reflect.Method;
-
-import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
- *
- */
-public class FacesResourceContext extends ResourceContext {
-
- FacesContext facesContext;
-
- ExternalContext externalContext;
-
- HttpServletResponse response;
-
- /**
- * @param facesContext
- */
- public FacesResourceContext(FacesContext facesContext) {
-
- this.facesContext = facesContext;
- this.externalContext = facesContext.getExternalContext();
- Object facesResponse = externalContext.getResponse();
- if (facesResponse instanceof HttpServletResponse) {
- this.response = (HttpServletResponse) facesResponse;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
- * java.lang.String)
- */
- public void setHeader(String name, String value) {
- if (null != response) {
- response.setHeader(name, value);
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String,
- * int)
- */
- public void setIntHeader(String name, int value) {
- if (null != response) {
- response.setIntHeader(name, value);
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String,
- * long)
- */
- public void setDateHeader(String name, long value) {
- if (null != response) {
- response.setDateHeader(name, value);
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- if (null != response) {
- return response.getOutputStream();
-
- } else {
- // May be non-servlet (Portlet?) environment. Try to use reflection
- OutputStream stream = null;
- Object response = externalContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getOutputStream", new Class[0]);
- stream = (OutputStream) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return stream;
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getWriter()
- */
- public PrintWriter getWriter() throws IOException {
- if (null != response) {
- return response.getWriter();
-
- } else {
- // May be non-servlet (Portlet?) environment. Try to use reflection
- PrintWriter writer = null;
- Object response = externalContext.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;
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
- */
- public String getQueryString() {
- return ((HttpServletRequest) externalContext.getRequest())
- .getQueryString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
- */
- public String getPathInfo() {
- return externalContext.getRequestPathInfo();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
- */
- public Object getSessionAttribute(String name) {
- return externalContext.getSessionMap().get(name);
- }
-
- public InputStream getResourceAsStream(String path) {
-
- return externalContext.getResourceAsStream(path);
- }
-
- public String getRequestParameter(String data_parameter) {
-
- return (String) externalContext.getRequestParameterMap().get(
- data_parameter);
- }
-
- public void setContentType(String contentType) {
- response.setContentType(contentType);
-
- }
-
- public String getInitParameter(String name) {
- // TODO Auto-generated method stub
- return externalContext.getInitParameter(name);
- }
-
- public String getServletPath() {
- // TODO Auto-generated method stub
- return externalContext.getRequestServletPath();
- }
-
- public void release() {
- super.release();
- externalContext = null;
- response = null;
- facesContext.release();
- }
-
- // added by nick 11.01.2007 - getters for contexts added
- public FacesContext getFacesContext() {
- return facesContext;
- }
-
- public ExternalContext getExternalContext() {
- return externalContext;
- }
- // by nick
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.ajax4jsf.framework.util.image.GIFEncoder;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
- *
- */
-public class GifRenderer extends ImageRenderer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/gif";
- }
-
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- // ImageIO.write(image,"gif",context.getOutputStream());
- GIFEncoder encoder = new GIFEncoder();
- DataOutputStream out = new DataOutputStream(context.getOutputStream());
- try {
- encoder.encode((BufferedImage) image, out);
- out.flush();
- out.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_ARGB;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
- *
- */
-public class HTMLRenderer extends BaseResourceRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "span";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "text/html";
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
- */
- protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
- // Encode style in page - read from resource.
- ResourceContext resourceContext = new FacesResourceContext(context);
- InputStream in = resource.getResourceAsStream(resourceContext);
- StringBuffer buff = new StringBuffer();
- int input;
- while((input = in.read())>0){
- buff.append((char)input);
- }
- in.close();
- // MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
- // TODO - detect page content type ?
- context.getResponseWriter().writeText(buff,resource.getKey());
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.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;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @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: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,429 +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.HashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for all Html page resources - images, scripts, styles etc. Realise
- * as "brige" pattern - different subclasses for different resource source
- * (static,jar,soft generator ) and customaized with differernt renderers for
- * image, script, style ( linked ir inline ). must operate with different
- * sources - application context, classpath, software generator.
- *
- * @author shura (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:15 $
- *
- */
-public abstract class InternetResourceBase implements InternetResource {
-
- private static final Log log = LogFactory
- .getLog(InternetResourceBase.class);
-
- static final int BUFFER_SIZE = 1024;
-
- // Hours
-
- private int contentLength = -1;
-
- private Date lastModified;
-
- private Date expired;
-
- private boolean cacheable = true;
-
- private boolean sessionAware = true;
-
- private ResourceRenderer renderer = null;
-
- private Map customProperties = new HashMap();
-
- private String key;
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentLength()
- */
- public int getContentLength(ResourceContext resourceContext) {
- return contentLength;
- }
-
- /**
- * @param contentLength
- * The contentLength to set.
- */
- protected void setContentLength(int contentLength) {
- this.contentLength = contentLength;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getExpired()
- */
- public Date getExpired(ResourceContext resourceContext) {
- return expired;
- }
-
- /**
- * @param expired
- * The expired to set.
- */
- public void setExpired(Date expired) {
- this.expired = expired;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getLastModified()
- */
- public Date getLastModified(ResourceContext resourceContext) {
-
- if (null != lastModified) {
- return lastModified;
- } else {
- return new Date(System.currentTimeMillis());
- }
- }
-
- /**
- * @param lastModified
- * The lastModified to set.
- */
- public void setLastModified(Date lastModified) {
- this.lastModified = lastModified;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return cacheable;
- }
-
- /**
- * @param cacheable
- * The cacheable to set.
- */
- public void setCacheable(boolean cacheable) {
- this.cacheable = cacheable;
- }
-
- /**
- * @return Returns the sessionAware.
- */
- public boolean isSessionAware() {
- return requireFacesContext();
- }
-
- /**
- * @param sessionAware
- * The sessionAware to set.
- */
- public void setSessionAware(boolean sessionAware) {
- this.sessionAware = sessionAware;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentType()
- */
- public String getContentType(ResourceContext resourceContext) {
- return getRenderer(null).getContentType();
- }
-
- /**
- * @return Returns the renderer.
- */
- public ResourceRenderer getRenderer(ResourceContext resourceContext) {
- return renderer;
- }
-
- /**
- * @param renderer
- * The renderer to set.
- */
- public void setRenderer(ResourceRenderer renderer) {
- this.renderer = renderer;
- }
-
- /**
- * Key for wich resource registered in resource builder.
- *
- * @return Returns the key.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Set registration key ( by {@link InternetResourceBuilder} for this
- * resource.
- *
- * @param key
- * The key to set.
- */
- public void setKey(String key) {
- this.key = key;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public String getUri(final FacesContext context, Object data) {
- return InternetResourceBuilder.getInstance().getUri(this, context,
- getDataToStore(context, data));
- }
-
- /**
- * Template method to construct resource-specific data ( to store in
- * resource URI ). If resource must store any data in session or other
- * cache, it must be done here. Since lightweight realisation, information
- * for restore such data muct be returned by this method.
- *
- * @param context -
- * current faces context.
- * @param data -
- * data for build information, usually current
- * {@link javax.faces.component.UIComponent}
- * @return - any {@link java.io.Serializable} object, or null.
- */
- protected Object getDataToStore(FacesContext context, Object data) {
- return getRenderer(null).getData(this, context, data);
- }
-
- /**
- * Restore data object from resource URI request parameter ( same object as
- * returned in getDataToStore method )
- *
- * @param context
- * @return restored data, or null.
- */
- protected Object restoreData(ResourceContext context) {
-
- Object data = context.getResourceData();
- if (data instanceof byte[]) {
- byte[] objectArray = (byte[]) data;
- data = deserializeData(objectArray);
- }
- return data;
-
- }
-
- /**
- * Deserialize parameters object from byte array. By default, used Java
- * de-serialisation from ObjectOutputStream , but implementations can
- * override this method ( togewer with getDataToStore ) for implement short
- * version.
- *
- * @param objectArray
- * @return
- * @throws IOException
- * @throws ClassNotFoundException
- */
- protected Object deserializeData(byte[] objectArray) {
- return objectArray;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getResourceAsStream()
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- throw new UnsupportedOperationException(Messages.getMessage(
- Messages.METHOD_NOT_IMPLEMENTED, "getResourceAsStream"));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- // TODO Auto-generated method stub
- return customProperties.get(key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object,
- * java.lang.Object)
- */
- public void setProperty(Object key, Object value) {
- customProperties.put(key, value);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO, getKey()));
- }
- getRenderer(null).encode(this, context, data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
- * java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map attributes)
- throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO_2,
- getKey(), attributes));
- }
- getRenderer(null).encodeBegin(this, context, data, attributes);
- getRenderer(null).encodeEnd(this, context, data);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs)
- throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_BEGIN_HTML_INFO,
- getKey(), attrs));
- }
- getRenderer(null).encodeBegin(this, context, component, attrs);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent, java.util.Map)
- */
- public void encodeEnd(FacesContext context, Object component)
- throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_END_HTML_INFO,
- getKey()));
- }
- getRenderer(null).encodeEnd(this, context, component);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#send(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void send(ResourceContext context) throws IOException {
- if (log.isDebugEnabled()) {
- log
- .debug(Messages.getMessage(Messages.SEND_CONTENT_INFO,
- getKey()));
- }
- int total = getRenderer(null).send(this, context);
- // For cacheable resources, store size.
- if (isCacheable(null)) {
- setContentLength(total);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#sendHeaders(javax.servlet.http.HttpServletResponse)
- */
- public void sendHeaders(ResourceContext context) {
- boolean cached = context.isCacheEnabled() && isCacheable(null);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SET_RESPONSE_HEADERS_INFO,
- getKey()));
- }
- // context.setHeader("Content-Type",getContentType());
- context.setContentType(getContentType(null));
- if (getContentLength(context) > 0) {
- context.setIntHeader("Content-Length", getContentLength(context));
- } else {
- // context.setHeader("Transfer-Encoding", "chunked");
- }
- Date lastModified = getLastModified(context);
- if (lastModified != null) {
- context.setDateHeader("Last-Modified", lastModified.getTime());
- }
- if (cached) {
- Date expired = getExpired(context);
- if (expired != null) {
- context.setDateHeader("Expires", expired.getTime());
- } else {
- context.setDateHeader("Expires", System.currentTimeMillis()
- + DEFAULT_EXPIRE);
- context.setHeader("Cache-control", "max-age="
- + (DEFAULT_EXPIRE / 1000));
- }
- } else {
- context.setHeader("Cache-control", "max-age=0, no-store, no-cache");
- context.setHeader("Pragma", "no-cache");
- context.setIntHeader("Expires", 0);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // by default, send data in ordinary Http request.
- return getRenderer(null).requireFacesContext();
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,385 +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 java.util.Properties;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.cache.Cache;
-import org.ajax4jsf.cache.CacheConfigurationLoader;
-import org.ajax4jsf.cache.CacheException;
-import org.ajax4jsf.cache.CacheFactory;
-import org.ajax4jsf.cache.CacheLoader;
-import org.ajax4jsf.cache.CacheManager;
-import org.ajax4jsf.cache.ServletContextInitMap;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-public class InternetResourceService implements CacheLoader, CacheConfigurationLoader {
- private static final Log log = LogFactory
- .getLog(InternetResourceService.class);
-
- static final String ENABLE_CACHING_PARAMETER = "enable-cache";
-
- private static final String RESOURCE_LIFECYCLE_PARAMETER = "org.ajax4jsf.RESOURCE_LIFECYCLE";
-
- private FilterConfig filterConfig;
-
- private boolean cacheEnabled = true;
-
- private Cache cache = null;
-
- //private ServletCacheAdministrator cacheAdmin;
-
- private FacesContextFactory contextFactory;
-
- // private RenderKitFactory renderKitFactory;
- private String lifecycleClass;
-
- private ResourceLifecycle lifecycle;
-
- private InternetResourceBuilder resourceBuilder;
-
- private WebXml webXml;
-
- public InternetResourceService() {
- }
-
- public void setCacheEnabled(boolean b) {
- cacheEnabled = b;
- }
-
- public void init(FilterConfig config) throws ServletException {
- filterConfig = config;
- ServletContext servletContext = config.getServletContext();
- if ("false".equalsIgnoreCase(config
- .getInitParameter(ENABLE_CACHING_PARAMETER))) {
- setCacheEnabled(false);
- // this.cacheEnabled = false;
- //this.cacheAdmin = null;
- } else {
- //this.cacheAdmin = ServletCacheAdministrator.getInstance(
- // servletContext, cacheProperties);
- try {
- CacheManager cacheManager = CacheManager.getInstance();
- Map env = new ServletContextInitMap(servletContext);
- CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
- this.cache = cacheFactory.createCache(env, this, this);
- } catch (CacheException e) {
- throw new FacesException(e.getMessage(), e);
- }
- }
- // Create Resource-specific Faces Lifecycle instance.
- lifecycleClass = servletContext
- .getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
- if (lifecycleClass != null) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- Class clazz = classLoader.loadClass(lifecycleClass);
- lifecycle = (ResourceLifecycle) clazz.newInstance();
- } catch (Exception e) {
- throw new FacesException(
- "Error create instance of resource Lifecycle "
- + lifecycleClass, e);
- }
- } else {
- lifecycle = new ResourceLifecycle();
- }
- webXml = new WebXml();
- webXml.init(servletContext,filterConfig.getFilterName());
- if (log.isDebugEnabled()) {
- log.debug("Resources service initialized");
- }
- }
-
- public boolean serviceResource(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse) throws ServletException,
- IOException {
- String resourceKey = webXml
- .getFacesResourceKey(httpServletRequest);
- if (null != resourceKey) {
- serviceResource(resourceKey, httpServletRequest,
- httpServletResponse);
- return true;
- }
- return false;
- }
-
- public void serviceResource(String resourceKey, HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- InternetResource resource;// getInternetResource(request);
- try {
- resource = getResourceBuilder().getResourceForKey(resourceKey);
- } catch (ResourceNotFoundException e) {
- throw new ServletException(e);
- }
- Object resourceDataForKey = getResourceBuilder()
- .getResourceDataForKey(resourceKey);
- if (resource.isCacheable(null) && this.cacheEnabled) {
- // Test for client request modification time.
- try {
- long ifModifiedSince = request
- .getDateHeader("If-Modified-Since");
- if (ifModifiedSince >= 0) {
- // Test for modification. 1000 ms due to round
- // modification
- // time to seconds.
- long lastModified = resource.getLastModified(null)
- .getTime() - 1000;
- if (lastModified <= ifModifiedSince) {
- response.setStatus(304);
- return;
- }
- }
- } catch (IllegalArgumentException e) {
- log
- .warn(
- Messages
- .getMessage(Messages.PARSING_IF_MODIFIED_SINCE_WARNING),
- e);
- }
- String cacheKey = resourceKey;// + "?" +
- // request.getQueryString();
- // TODO - select session/application scope.
- //Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
-// try {
- // TODO - use last modified/expires time
-
- CacheKey key = new CacheKey(resourceDataForKey, request, response, resource);
-
- CacheContent content;
- try {
- content = (CacheContent) cache
- .get(cacheKey, key);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
- }
- content.sendHeaders(response);
- // Correct expires date for resource.
- Date expired = resource.getExpired(null);
- if (expired != null) {
- response.setDateHeader("Expires", expired.getTime());
- } else {
- response.setDateHeader("Expires", System
- .currentTimeMillis()
- + InternetResource.DEFAULT_EXPIRE);
- }
- if (!request.getMethod().equals("HEAD")) {
- content.send(response);
- }/*
- } catch (NeedsRefreshException e) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
- }
- CachedResourceContext context = (CachedResourceContext) sendResource(
- resource, request, response, resourceDataForKey);
- // TODO - set refresh interval ?
- cache.put(cacheKey, context.getContent());
- } catch (Exception ex) {
- //cache.cancelUpdate(cacheKey);
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- ex);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
- ex);
- }
- }*/
- } catch (CacheException e) {
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- e);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, e.getMessage()),
- e);
- }
- } else {
- sendResource(resource, request, response, resourceDataForKey);
- }
- }
-
- /**
- * @param resource
- * @param request
- * @param response
- * @throws IOException
- */
- protected ResourceContext sendResource(InternetResource resource,
- HttpServletRequest request, HttpServletResponse response,
- Object data) throws IOException {
- ResourceContext resourceContext = getResourceContext(resource, request,
- response);
- resourceContext.setResourceData(data);
- getLifecycle().send(resourceContext, resource);
- resourceContext.release();
- return resourceContext;
- }
-
- /**
- * @param resource
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws FacesException
- */
- protected ResourceContext getResourceContext(InternetResource resource,
- HttpServletRequest request, HttpServletResponse response)
- throws FacesException {
- FacesContext facesContext = null;
- ResourceContext resourceContext;
- if (resource.requireFacesContext()) {
- facesContext = getFacesContext(request, response);
- resourceContext = new FacesResourceContext(facesContext);
- } else {
- resourceContext = new ServletResourceContext(getServletContext(),
- request, response);
- }
- if (resource.isCacheable(null) && this.cacheEnabled) {
- resourceContext = new CachedResourceContext(resourceContext);
- }
- return resourceContext;
- }
-
- /**
- * Get properties file from classpath
- *
- * @param name
- * @return
- */
- protected Properties getProperties(String name) {
- Properties properties = new Properties();
- InputStream props = BaseFilter.class.getResourceAsStream(name);
- if (null != props) {
- try {
- properties.load(props);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
- name), e);
- } finally {
- try {
- props.close();
- } catch (IOException e) {
- // Can be ignored
- }
- }
- }
- return properties;
-
- }
-
- /**
- * @return Returns the servletContext.
- */
- protected ServletContext getServletContext() {
- return filterConfig.getServletContext();
- }
-
- /**
- * @return the lifecycle
- * @throws ServletException
- */
- protected ResourceLifecycle getLifecycle() throws FacesException {
- return lifecycle;
- }
-
- /**
- * @return the contextFactory
- */
- protected synchronized FacesContextFactory getContextFactory() {
- if (contextFactory == null) {
- contextFactory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- }
-
- return contextFactory;
- }
-
- protected FacesContext getFacesContext(ServletRequest request,
- ServletResponse response) throws FacesException {
- return getContextFactory().getFacesContext(getServletContext(),
- request, response, getLifecycle());
- }
-
- /**
- * @return the resourceBuilder
- */
- protected InternetResourceBuilder getResourceBuilder() {
- if (resourceBuilder == null) {
- // Create resource builder for this filter.
- resourceBuilder = InternetResourceBuilder.getInstance();
- }
- return resourceBuilder;
- }
-
- public Object load(Object key, Object context) throws CacheException {
- CacheKey cacheKey = (CacheKey) context;
-
- CachedResourceContext resourceContext = (CachedResourceContext) getResourceContext(cacheKey.getResource(), cacheKey.getRequest(),
- cacheKey.getResponse());
- resourceContext.setResourceData(cacheKey.getResourceData());
- try {
- getLifecycle().send(resourceContext, cacheKey.getResource());
- } catch (IOException e) {
- throw new CacheException(e.getMessage(), e);
- }
- resourceContext.release();
-
- // TODO - set refresh interval ?
- //cache.put(cacheKey, resourceContext.getContent());
- return resourceContext.getContent();
- }
-
- public Properties loadProperties(String name) {
- return getProperties(name);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.InputStream;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * Class stoped all resources in application classpath.
- * TODO - set last midified & expired values.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:00 $
- *
- */
-public class JarResource extends InternetResourceBase {
-
- /**
- * Default place for all static resources in Jar.
- * to avoid access to any class in application, only allowed subpackages for
- * META-INF/resources
- */
- public static final String RESOURCES_ROOT="META-INF/resources";
-
- private String path;
-
- public JarResource(){
-
- }
-
- public JarResource(String path) {
- this.path = path;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext, java.lang.Object)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return loader.getResourceAsStream(path);
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,135 +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.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.ResourceContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/01 15:31:57 $
- *
- */
-public class Java2Dresource extends InternetResourceBase {
- private static final Log log = LogFactory.getLog(Java2Dresource.class);
-
- /**
- * Primary calculation of image dimensions - used when HTML code is
- * generated to render IMG's width and height Subclasses should override
- * this method to provide correct sizes of rendered images
- *
- * @param facesContext
- * @return dimensions of the image to be displayed on page
- */
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return new Dimension(1, 1);
- }
-
- /**
- * Secondary calculation is used basically by {@link getImage} method
- *
- * @param resourceContext
- * @return
- */
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return new Dimension(1, 1);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- // TODO Auto-generated method stub
- return super.getResourceAsStream(context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResourceBase#send(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void send(ResourceContext context) throws IOException {
- ImageRenderer renderer = (ImageRenderer) getRenderer(null);
- try {
- RenderedImage image = getImage(context);
- if (null != image) {
- renderer.sendImage(context, image);
-
- }
- } catch (Exception e) {
- throw new FacesException(Messages
- .getMessage(Messages.SEND_IMAGE_ERROR_2), e);
- }
- }
-
- /**
- * Create {@link RenderedImage} for send to client. can be used as Java2d or
- * Java Advanced Imaging.
- *
- * @param context
- * @return image to send.
- */
- protected RenderedImage getImage(ResourceContext context) {
- ImageRenderer renderer = (ImageRenderer) getRenderer(null);
- Dimension imageDimensions = getDimensions(context);
- BufferedImage image = null;
- if (imageDimensions.getHeight() > 0.0
- && imageDimensions.getWidth() > 0.0) {
- image = renderer.createImage(imageDimensions.width,
- imageDimensions.height);
- Graphics2D graphics = image.createGraphics();
- paint(context, graphics);
- graphics.dispose();
-
- }
- return image;
- }
-
- /**
- * Template method for create image as Applet-like paint.
- *
- * @param context -
- * current resource context.
- * @param graphics2D -
- * graphics to paint.
- */
- protected void paint(ResourceContext context, Graphics2D graphics2D) {
- // TODO Auto-generated method stub
-
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,66 +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.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
- *
- */
-public class JpegRenderer extends ImageRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/jpeg";
- }
-
- public void sendImage(ResourceContext context, RenderedImage image) throws IOException {
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image, "jpeg", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_RGB;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
- *
- */
-public class LogfileRenderer extends BaseResourceRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "pre";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "text/plain";
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
- */
- protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
- // Encode style in page - read from resource.
- ResourceContext resourceContext = new FacesResourceContext(context);
- InputStream in = resource.getResourceAsStream(resourceContext);
- StringBuffer buff = new StringBuffer();
- int input;
- while((input = in.read())>0){
- buff.append((char)input);
- }
- in.close();
- // MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
- // TODO - detect page content type ?
- context.getResponseWriter().writeText(buff,resource.getKey());
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,66 +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;
-
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 20.11.2006
- *
- */
-public class MimeRenderer extends BaseResourceRenderer {
-
- private String contentType = null;
-
- public MimeRenderer() {
-
- }
-
- public MimeRenderer(String contentType) {
- super();
- this.contentType = contentType;
- }
-
- public String getContentType() {
- return this.contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
-
-
- protected String getTag() {
- return null;
- }
-
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return null;
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,80 +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;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for resources, rendered only one time in page ( JavaScript, CSS )
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
- *
- */
-public abstract class OneTimeRenderer extends BaseResourceRenderer {
-
- private static final Log log = LogFactory.getLog(OneTimeRenderer.class);
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#encodeBegin(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encodeBegin(InternetResource resource, FacesContext context, Object data, Map attributes) throws IOException {
-
- if (!isRendered(resource,context)) {
- super.encodeBegin(resource, context, data, attributes);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO_2, resource.getKey()));
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#encodeEnd(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encodeEnd(InternetResource resource, FacesContext context, Object data) throws IOException {
- // TODO Auto-generated method stub
- if (!isRendered(resource,context)) {
- super.encodeEnd(resource, context, data);
- context.getExternalContext().getRequestMap().put(resource.getKey(),Boolean.TRUE);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.MARK_AS_RENDERED_INFO, resource.getKey()));
- }
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO_2, resource.getKey()));
- }
- }
-
- /**
- * Detect for resource rendered status. For cacheable, show key parameter in request Map.
- * @param resource
- * @param context
- * @return - true, if resource already rendered.
- */
- private boolean isRendered(InternetResource resource, FacesContext context){
- return null != context.getExternalContext().getRequestMap().get(resource.getKey()); // resource.isCacheable() &&
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,125 +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.image.BufferedImage;
-import java.awt.image.IndexColorModel;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
- *
- */
-public class Png8Renderer extends ImageRenderer {
-
- /**
- * Default web safe colors color model
- */
- public static IndexColorModel webColorModel;
-
- // Build web safe 6x6x6 cube color model.
- static {
- byte[] webLevels = { 0, 51, 102, (byte) 153, (byte) 204, (byte) 255 };
- byte[] r = new byte[256];
- byte[] g = new byte[256];
- byte[] b = new byte[256];
- r[0] = g[0] = b[0] = 0;
- for (int i = 0; i < webLevels.length; i++) {
- for (int j = 0; j < webLevels.length; j++) {
- for (int k = 0; k < webLevels.length; k++) {
- int colorNum = i * webLevels.length * webLevels.length + j
- * webLevels.length + k + 1;
- r[colorNum] = webLevels[i];
- g[colorNum] = webLevels[j];
- b[colorNum] = webLevels[k];
- }
- }
- }
- webColorModel = new IndexColorModel(8, webLevels.length
- * webLevels.length * webLevels.length + 1, r, g, b, 0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#sendImage(org.ajax4jsf.resource.ResourceContext,
- * java.awt.image.RenderedImage)
- */
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- // PNGEncodeParam param = new PNGEncodeParam.Palette();
- // param.setBitDepth(8);
- // param.setInterlacing(true);
- // String[] encoders = ImageCodec.getEncoderNames(image,null);
- // ImageEncoder encoder =
- // ImageCodec.createImageEncoder("png",context.getOutputStream(),param);
- // encoder.encode(image);
- try {
- ImageIO.write(image, "png", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#getImageType()
- */
- public int getImageType() {
- return BufferedImage.TYPE_BYTE_INDEXED;
- // return BufferedImage.TYPE_INT_ARGB;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#createImage(int, int)
- */
- public BufferedImage createImage(int width, int height) {
-
- // return new BufferedImage(width,height,getImageType());//,colorModel);
- return new BufferedImage(width, height, getImageType(), webColorModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/png";
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,63 +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.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:05 $
- *
- */
-public class PngRenderer extends ImageRenderer {
-
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image, "png", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/png";
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_ARGB;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,36 +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;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
- *
- */
-public class PrototypeScript extends ClientScript {
-
- public String getJavaScript() {
- return "scripts/prototype.js";
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,589 +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.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StreamCorruptedException;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.zip.Deflater;
-import java.util.zip.Inflater;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
-import javax.servlet.ServletContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.base64.Codec;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.resource.ResourceRenderer;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Produce instances of InternetResource's for any types - jar resource, dynamic
- * created image, component-incapsulated etc. Realised as singleton class to
- * support cache, configuration etc.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
- *
- */
-public class ResourceBuilderImpl extends InternetResourceBuilder {
-
- private static final Log log = LogFactory.getLog(ResourceBuilderImpl.class);
-
- private static final String DATA_SEPARATOR = "/DATA/";
-
- private static Map renderers;
-
- private static ResourceRenderer defaultRenderer = new MimeRenderer(null);
-
- /**
- * keep resources instances . TODO - put this map to application-scope
- * attribute, for support clastering environment.
- */
- private Map resources = Collections.synchronizedMap(new HashMap());
-
- private long _startTime;
-
- private Codec codec;
-
- static {
- renderers = new HashMap();
- // append known renderers for extentions.
- renderers.put(".gif", new GifRenderer());
- ResourceRenderer renderer = new JpegRenderer();
- renderers.put(".jpeg", renderer);
- renderers.put(".jpg", renderer);
- renderers.put(".png", new PngRenderer());
- renderers.put(".js", new ScriptRenderer());
- renderers.put(".css", new StyleRenderer());
- renderers.put(".log", new LogfileRenderer());
- renderers.put(".html", new HTMLRenderer());
- renderers.put(".xhtml", new MimeRenderer("application/xhtml+xml"));
- renderers.put(".xml", new MimeRenderer("text/xml"));
- renderers.put(".xcss", new TemplateCSSRenderer());
- // renderers.put(".htc",new BehaviorRenderer());
- // set in-memory caching ImageIO
- ImageIO.setUseCache(false);
-
- }
-
- public WebXml getWebXml(FacesContext context) {
- WebXml webXml = (WebXml) context.getExternalContext().getApplicationMap().get(WebXml.CONTEXT_ATTRIBUTE);
- if (null == webXml) {
- throw new FacesException(
- "Resources framework is not initialised, check web.xml for Filter configuration");
- }
- return webXml;
- }
-
- public ResourceBuilderImpl() {
- super();
- _startTime = System.currentTimeMillis();
- codec = new Codec();
- }
-
- /**
- * @throws FacesException
- */
- protected void registerResources() throws FacesException {
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Enumeration e = loader
- .getResources("META-INF/resources-config.xml");
- while (e.hasMoreElements()) {
- URL resource = (URL) e.nextElement();
- registerConfig(resource);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- private void registerConfig(URL resourceConfig) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Process resources configuration file "+resourceConfig.toExternalForm());
- }
-
- InputStream in = resourceConfig.openStream();
- try {
- Digester digester = new Digester();
- digester.setValidating(false);
- digester.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId,
- String systemId) throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
- });
- digester.setNamespaceAware(false);
- digester.setUseContextClassLoader(true);
- digester.push(this);
- digester.addObjectCreate("resource-config/resource", "class",
- JarResource.class);
- digester.addObjectCreate("resource-config/resource/renderer",
- "class", HTMLRenderer.class);
- digester.addCallMethod(
- "resource-config/resource/renderer/content-type",
- "setContentType", 0);
- digester.addSetNext("resource-config/resource/renderer",
- "setRenderer", ResourceRenderer.class.getName());
- digester.addCallMethod("resource-config/resource/name",
- "setKey", 0);
- digester.addCallMethod("resource-config/resource/path",
- "setPath", 0);
- digester.addCallMethod("resource-config/resource/cacheable",
- "setCacheable", 0);
- digester.addCallMethod(
- "resource-config/resource/session-aware",
- "setSessionAware", 0);
- digester.addCallMethod("resource-config/resource/property",
- "setProperty", 2);
- digester.addCallParam("resource-config/resource/property/name",
- 0);
- digester.addCallParam(
- "resource-config/resource/property/value", 1);
- digester.addCallMethod("resource-config/resource/content-type",
- "setContentType", 0);
- digester.addSetNext("resource-config/resource", "addResource",
- InternetResource.class.getName());
- digester.parse(in);
- } finally {
- in.close();
- }
- } catch (IOException e) {
- throw new FacesException(e);
- } catch (SAXException e) {
- throw new FacesException(e);
- }
- }
-
- /**
- */
- public void init()
- throws FacesException {
- // TODO - mace codec configurable.
- registerResources();
- }
-
- /**
- * Base point for creating resource. Must detect type and build
- * appropriate instance. Currently - make static resource for ordinary
- * request, or instance of class.
- *
- * @param base
- * base object for resource ( resourcess in classpath
- * will be get relative to it package )
- * @param path
- * key - path to resource, resource class name etc.
- * @return
- * @throws FacesException
- */
- public InternetResource createResource(Object base, String path)
- throws FacesException {
- // TODO - detect type of resource ( for example, resources location path
- // in Skin
- try {
- return getResource(path);
- } catch (ResourceNotFoundException e) {
- try {
- return getResource(buildKey(base, path));
- } catch (ResourceNotFoundException e1) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_INFO,
- path));
- }
- }
- }
- // path - is class name ?
- InternetResource res;
- try {
- Class resourceClass = Class.forName(path);
- res = createDynamicResource(path, resourceClass);
- } catch (Exception e) {
- try {
- res = createJarResource(base, path);
- } catch (ResourceNotFoundException ex) {
- res = createStaticResource(path);
- }
- // TODO - if resource not found, create static ?
- }
- return res;
- }
-
- private String buildKey(Object base, String path) {
- if (path.startsWith("/")) {
- return path.substring(1);
- }
- if (null == base) {
- return path;
- }
- StringBuffer packageName = new StringBuffer(base.getClass()
- .getPackage().getName().replace('.', '/'));
- return packageName.append("/").append(path).toString();
- }
-
- public String getUri(InternetResource resource, FacesContext context,
- Object storeData) {
- StringBuffer uri = new StringBuffer();// ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
- uri.append(resource.getKey());
- // append serialized data as Base-64 encoded request string.
- if (storeData != null) {
- try {
- byte[] objectData;
- if (!(storeData instanceof byte[])) {
- ByteArrayOutputStream dataSteram = new ByteArrayOutputStream(
- 1024);
- ObjectOutputStream objStream = new ObjectOutputStream(
- dataSteram);
- objStream.writeObject(storeData);
- objStream.flush();
- objStream.close();
- dataSteram.close();
- objectData = dataSteram.toByteArray();
- } else {
- objectData = (byte[]) storeData;
- }
- uri.append(DATA_SEPARATOR);
- byte[] dataArray = encrypt(objectData);
- uri.append(new String(dataArray, "ISO-8859-1"));
-
- // / byte[] objectData = dataSteram.toByteArray();
- // / uri.append("?").append(new
- // String(Base64.encodeBase64(objectData),
- // / "ISO-8859-1"));
- } catch (Exception e) {
- // Ignore errors, log it
- log.error(Messages
- .getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
- }
- }
- String resourceURL = getWebXml(context).getFacesResourceURL(context,
- uri.toString());// context.getApplication().getViewHandler().getResourceURL(context,uri.toString());
- if (resource.isSessionAware()) {
- resourceURL = context.getExternalContext().encodeResourceURL(
- resourceURL);
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
- resource.getKey(), resourceURL));
- }
- return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
-
- }
-
- /**
- * @param key
- * @return
- */
- public InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException {
-
- int data = key.indexOf(DATA_SEPARATOR);
- if (data >= 0) {
- key = key.substring(0, data);
- }
- return getResource(key);
- }
-
- public Object getResourceDataForKey(String key) {
- Object data = null;
- String dataString = null;
- int dataStart = key.indexOf(DATA_SEPARATOR);
- if (dataStart >= 0) {
- dataString = key.substring(dataStart + DATA_SEPARATOR.length());
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.RESTORE_DATA_FROM_RESOURCE_URI_INFO, key,
- dataString));
- }
- if (dataString != null) {
- // dataString =
- // dataString.substring(dataStart+ResourceServlet.DATA_PARAMETER.length()+1);
- byte[] objectArray = null;
- try {
- byte[] dataArray = dataString.getBytes("ISO-8859-1");
- objectArray = decrypt(dataArray);
-
- ObjectInputStream in = new ObjectInputStream(
- new ByteArrayInputStream(objectArray));
- data = in.readObject();
- } catch (StreamCorruptedException e) {
- data = objectArray;
- } catch (IOException e) {
- log.error(Messages
- .getMessage(Messages.DESERIALIZE_DATA_INPUT_ERROR), e);
- } catch (ClassNotFoundException e) {
- log.error(Messages
- .getMessage(Messages.DATA_CLASS_NOT_FOUND_ERROR), e);
- }
- }
- return data;
- }
-
- public InternetResource getResource(String path)
- throws ResourceNotFoundException {
-
- InternetResource internetResource = (InternetResource) resources
- .get(path);
- if (null == internetResource) {
- throw new ResourceNotFoundException("Resource not registered : "
- + path);
- } else {
- return internetResource;
- }
- }
-
- public void addResource(InternetResource resource) {
- resources.put(resource.getKey(), resource);
- ResourceRenderer renderer = resource.getRenderer(null);
- if (renderer == null) {
- setRenderer(resource, resource.getKey());
- }
- }
-
- public void addResource(String key, InternetResource resource) {
- resources.put(key, resource);
- resource.setKey(key);
- // TODO - set renderer ?
- }
-
-// public String getFacesResourceKey(HttpServletRequest request) {
-// return getWebXml(context).getFacesResourceKey(request);
-// }
-
- public String getFacesResourceURL(FacesContext context, String Url) {
- return getWebXml(context).getFacesResourceURL(context, Url);
- }
-
- /**
- * Build resource for link to static context in webapp.
- *
- * @param path
- * @return
- * @throws FacesException
- */
- protected InternetResource createStaticResource(String path)
- throws ResourceNotFoundException, FacesException {
- FacesContext context = FacesContext.getCurrentInstance();
- if (null != context) {
- if (context.getExternalContext().getContext() instanceof ServletContext) {
- ServletContext servletContext = (ServletContext) context
- .getExternalContext().getContext();
- InputStream in = servletContext.getResourceAsStream(path);
- if (null != in) {
- InternetResourceBase res = new StaticResource(path);
- setRenderer(res, path);
- res.setLastModified(new Date(getStartTime()));
- addResource(path, res);
- try {
- in.close();
- } catch (IOException e) {
- }
- return res;
- }
- }
- }
- throw new ResourceNotFoundException(Messages.getMessage(
- Messages.STATIC_RESOURCE_NOT_FOUND_ERROR, path));
- }
-
- private void setRenderer(InternetResource res, String path)
- throws FacesException {
- int lastPoint = path.lastIndexOf('.');
- if (lastPoint > 0) {
- String ext = path.substring(lastPoint);
- ResourceRenderer resourceRenderer = (ResourceRenderer) renderers
- .get(ext);
- if (null != resourceRenderer) {
- res.setRenderer(resourceRenderer);
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.NO_RESOURCE_REGISTERED_ERROR_2, path,
- renderers.keySet()));
- }
-
- // String mimeType = servletContext.getMimeType(path);
- res.setRenderer(defaultRenderer);
- }
- }
- }
-
- /**
- * Create resurce to send from classpath relative to base class.
- *
- * @param base
- * @param path
- * @return
- * @throws FacesException
- */
- protected InternetResource createJarResource(Object base, String path)
- throws ResourceNotFoundException, FacesException {
- String key = buildKey(base, path);
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (null != loader.getResource(key)) {
- JarResource res = new JarResource(key);
- setRenderer(res, path);
- res.setLastModified(new Date(getStartTime()));
- addResource(key, res);
- return res;
- } else {
- throw new ResourceNotFoundException(Messages.getMessage(
- Messages.NO_RESOURCE_EXISTS_ERROR, key));
- }
-
- }
-
- /**
- * Create resource by instatiate given class.
- *
- * @param path
- * @param instatiate
- * @return
- */
- protected InternetResource createDynamicResource(String path,
- Class instatiate) throws ResourceNotFoundException {
- if (InternetResource.class.isAssignableFrom(instatiate)) {
- InternetResource resource;
- try {
- resource = (InternetResource) instatiate.newInstance();
- addResource(path, resource);
- } catch (Exception e) {
- String message = Messages.getMessage(
- Messages.INSTANTIATE_RESOURCE_ERROR, instatiate
- .toString());
- log.error(message, e);
- throw new ResourceNotFoundException(message, e);
- }
- return resource;
- }
- throw new FacesException(Messages
- .getMessage(Messages.INSTANTIATE_CLASS_ERROR));
- }
-
- /**
- * Create resource by instatiate {@link UserResource} class with given
- * properties ( or got from cache ).
- *
- * @param cacheable
- * @param session
- * @param mime
- * @return
- * @throws FacesException
- */
- public InternetResource createUserResource(boolean cacheable,
- boolean session, String mime) throws FacesException {
- String path = getUserResourceKey(cacheable, session, mime);
- InternetResource userResource;
- try {
- userResource = getResource(path);
- } catch (ResourceNotFoundException e) {
- userResource = new UserResource(cacheable, session, mime);
- addResource(path, userResource);
- }
- return userResource;
- }
-
- /**
- * Generate resource key for user-generated resource with given
- * properties.
- *
- * @param cacheable
- * @param session
- * @param mime
- * @return
- */
- private String getUserResourceKey(boolean cacheable, boolean session,
- String mime) {
- StringBuffer pathBuffer = new StringBuffer(UserResource.class.getName());
- pathBuffer.append(cacheable ? "/c" : "/n");
- pathBuffer.append(session ? "/s" : "/n");
- if (null != mime) {
- pathBuffer.append('/').append(mime.hashCode());
- }
- String path = pathBuffer.toString();
- return path;
- }
-
- /**
- * @return Returns the startTime for application.
- */
- public long getStartTime() {
- return _startTime;
- }
-
- protected byte[] encrypt(byte[] src) {
- try {
- Deflater compressor = new Deflater(Deflater.BEST_SPEED);
- byte[] compressed = new byte[src.length + 100];
- compressor.setInput(src);
- compressor.finish();
- int totalOut = compressor.deflate(compressed);
- byte[] zipsrc = new byte[totalOut];
- System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
- compressor.end();
- return codec.encode(zipsrc);
- } catch (Exception e) {
- throw new FacesException("Error encode resource data", e);
- }
- }
-
- protected byte[] decrypt(byte[] src) {
- try {
- byte[] zipsrc = codec.decode(src);
- Inflater decompressor = new Inflater();
- byte[] uncompressed = new byte[zipsrc.length * 5];
- decompressor.setInput(zipsrc);
- int totalOut = decompressor.inflate(uncompressed);
- byte[] out = new byte[totalOut];
- System.arraycopy(uncompressed, 0, out, 0, totalOut);
- decompressor.end();
- return out;
- } catch (Exception e) {
- throw new FacesException("Error decode resource data", e);
- }
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.framework.resource;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseListener;
-import javax.faces.lifecycle.Lifecycle;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * Lifecycle for simulate faces request processing for resource.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
- *
- */
-public class ResourceLifecycle extends Lifecycle {
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#addPhaseListener(javax.faces.event.PhaseListener)
- */
- public void addPhaseListener(PhaseListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#execute(javax.faces.context.FacesContext)
- */
- public void execute(FacesContext arg0) throws FacesException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#getPhaseListeners()
- */
- public PhaseListener[] getPhaseListeners() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#removePhaseListener(javax.faces.event.PhaseListener)
- */
- public void removePhaseListener(PhaseListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#render(javax.faces.context.FacesContext)
- */
- public void render(FacesContext arg0) throws FacesException {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @param context
- * @param resource
- * @throws IOException
- */
- public void send(ResourceContext resourceContext, InternetResource resource) throws IOException{
- resource.sendHeaders(resourceContext);
- resource.send(resourceContext);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,150 +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 org.ajax4jsf.Messages;
-import org.ajax4jsf.javascript.JSMin;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
- *
- */
-public class ScriptRenderer extends OneTimeRenderer {
-
- private static final String COMPRESS_SCRIPTS_PARAMETER = "org.ajax4jsf.COMPRESS_SCRIPT";
-
- private static final Log _log = LogFactory.getLog(ScriptRenderer.class);
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "script";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return "src";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return new String[][]{{"type",getContentType()}};
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO - use configurable encoding ?
- return "text/javascript";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context) throws IOException {
- InputStream in = base.getResourceAsStream(context);
- if (null == in) {
- String message = Messages.getMessage(
- Messages.NO_INPUT_STREAM_ERROR, base.getKey());
- throw new IOException(message);
- }
- OutputStream out = context.getOutputStream();
- // Compress JavaScript output by JSMin ( true by default )
- if( ! "false".equalsIgnoreCase(context.getInitParameter(COMPRESS_SCRIPTS_PARAMETER))){
- CountingOutputStream countingStream = new CountingOutputStream(out);
- JSMin jsmin = new JSMin(in,countingStream);
- try {
- jsmin.jsmin();
- } catch (Exception e) {
- _log.error("Error send script to client for resource "+base.getKey(), e);
- } finally {
- in.close();
- countingStream.flush();
- countingStream.close();
- }
- int written = countingStream.getWritten();
- if(_log.isDebugEnabled()){
- _log.debug("Send "+written+" bytes to client for JavaScript resource "+base.getKey());
- }
- return written;
- } else {
- return sendStream(in, out);
- }
- }
-
-
-}
-
-class CountingOutputStream extends OutputStream {
- private OutputStream outputStream;
- private int written = 0;
-
- CountingOutputStream(OutputStream outputStream) {
- super();
- this.outputStream = outputStream;
- }
-
- public void close() throws IOException {
- outputStream.close();
- }
-
- public void flush() throws IOException {
- outputStream.flush();
- }
-
- public void write(byte[] b, int off, int len) throws IOException {
- outputStream.write(b, off, len);
- written += len;
- }
-
- public void write(byte[] b) throws IOException {
- outputStream.write(b);
- written += b.length;
- }
-
- public void write(int b) throws IOException {
- outputStream.write(b);
- written++;
- }
-
- int getWritten() {
- return written;
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,143 +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;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
- *
- */
-public class ServletResourceContext extends ResourceContext {
-
- private ServletContext context;
- private HttpServletRequest request;
-
- private HttpServletResponse response;
-
- /**
- * @param request
- * @param response
- */
- public ServletResourceContext(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
- this.context = context;
- this.request = request;
- this.response = response;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String, java.lang.String)
- */
- public void setHeader(String name, String value) {
- response.setHeader(name,value);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
- */
- public void setIntHeader(String name, int value) {
- response.setIntHeader(name,value);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
- */
- public void setDateHeader(String name, long value) {
- response.setDateHeader(name,value);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- // TODO Auto-generated method stub
- return response.getOutputStream();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
- */
- public String getQueryString() {
- return request.getQueryString();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
- */
- public String getPathInfo() {
- return request.getPathInfo();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
- */
- public Object getSessionAttribute(String name) {
- return request.getSession(false).getAttribute(name);
- }
-
- public InputStream getResourceAsStream(String path) {
- // TODO Auto-generated method stub
- return context.getResourceAsStream(path);
- }
-
- public String getRequestParameter(String data_parameter) {
- // TODO Auto-generated method stub
- return request.getParameter(data_parameter);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getWriter()
- */
- public PrintWriter getWriter() throws IOException {
- // TODO Auto-generated method stub
- return response.getWriter();
- }
-
- public void setContentType(String contentType) {
- response.setContentType(contentType);
- }
-
- public String getInitParameter(String name) {
- // TODO Auto-generated method stub
- return context.getInitParameter(name);
- }
-
- public String getServletPath() {
- // TODO Auto-generated method stub
- return request.getServletPath();
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.framework.resource;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SmartPositionScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- // TODO Auto-generated method stub
- return "scripts/smartposition.js";
- }
-
- protected boolean isUsePrototype() {
-
- return true;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.framework.resource;
-
-import java.io.InputStream;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
- *
- */
-public class StaticResource extends InternetResourceBase {
-
- private String path;
- private byte[] resourceData = null;
-
- /**
- *
- */
- public StaticResource() {
- super();
- }
-
-
-
- public StaticResource(String path){
- this.path = path;
- setCacheable(true);
- }
-
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- return context.getResourceAsStream(path);
- }
-
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return true;
- }
-
-
-
- public String getUri(FacesContext context, Object data) {
- // perform all encodings, suitable for JSF specification.
- String src = context.getApplication().getViewHandler().getResourceURL(context,path);
- return context.getExternalContext().encodeResourceURL(src);
- }
-
- public void encode(FacesContext context, Object data) {
- // TODO Auto-generated method stub
-
- }
-
-
-
- /**
- * @return the path
- */
- public String getPath() {
- return path;
- }
-
-
-
- /**
- * @param path the path to set
- */
- public void setPath(String path) {
- this.path = path;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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;
-
-
-/**
- * Render style element with content in page. Warning - not use for head link element,
- * it must be rendered separate.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
- *
- */
-public class StyleRenderer extends OneTimeRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- return "link";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- return "href";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- return new String[][]{{"type","text/css"},{"rel","stylesheet"}};
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO use configurable encoding ?
- return "text/css";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
- */
- /*
- protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
- // Encode style in page - read from resource.
- ResourceContext resourceContext = new FacesResourceContext(context);
- InputStream in = resource.getResourceAsStream(resourceContext);
- StringBuffer buff = new StringBuffer();
- int input;
- while((input = in.read())>0){
- buff.append((char)input);
- }
- in.close();
- // MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
- // TODO - detect page content type ?
- context.getResponseWriter().writeText(buff,resource.getKey());
- }
-*/
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.InputStream;
-import java.nio.ByteBuffer;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author shura
- *
- */
-public class TemplateCSSRenderer extends StyleRenderer {
-
- private static final String COMPILED_TEMPLATE_PROPERTY = "compiled-template";
-
- private RendererBase renderer = new RendererBase() {
-
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIComponent.class;
- }
-
- };
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context) throws IOException {
- PreparedTemplate template = null;
- template = getTemplate(base, context);
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if(null != facesContext) {
- // Create responseWriter.
- String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
- if (null == defaultRenderKitId) {
- defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
- // TODO - handle response encoding
- ResponseWriter responseWriter = renderKit.createResponseWriter(context.getWriter(),null,"UTF-8");
- facesContext.setResponseWriter(responseWriter);
- responseWriter.startDocument();
- // TODO - parameters and mock renderer/component ?
- // for first time, this template only allow skin or faces variables interaction
- template.encode(renderer,facesContext,null);
- responseWriter.endDocument();
- responseWriter.flush();
- responseWriter.close();
- } else {
- throw new FacesException("FacesContext for resource from template "+base.getKey()+" is null");
- }
- return 0;
- }
-
- /**
- * @param base
- * @param context
- * @return
- * @throws IOException
- */
- public PreparedTemplate getTemplate(InternetResource base, ResourceContext context) throws IOException {
- PreparedTemplate template;
- // if(base.isCacheable()){
- template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
- // }
- if(null == template){
- HtmlCompiler compiler = new HtmlCompiler();
- InputStream resourceAsStream = base.getResourceAsStream(context);
- template = compiler.compile(resourceAsStream, base.getKey());
- base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
- resourceAsStream.close();
- }
- return template;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#requireFacesContext()
- */
- public boolean requireFacesContext() {
- return true;
- }
-
- public Object getData(InternetResource base, FacesContext context, Object data) {
- ResourceContext resourceContext = new FacesResourceContext(context);
- PreparedTemplate template;
- try {
- template = getTemplate(base, resourceContext);
- } catch (IOException e) {
- return null;
- }
- UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
- TemplateContext templateContext = new TemplateContext(null,context,component);
- Object value = template.getValue(templateContext);
- if(null == value){
- int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
- value = ByteBuffer.allocate(4).putInt(hashCode).array();
- }
- return value;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,295 +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.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
-
-
-/**
- * Class for create and send resources from template ( at most, used for CSS files )
- * @author shura (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
- *
- */
-public class TemplateCSSResource implements InternetResource {
-
- private String templateName;
- private InternetResource _resource;
- private static TemplateCSSRenderer templateCSSRenderer = new TemplateCSSRenderer();
-
- public TemplateCSSResource(){
-
- }
- /**
- * @param templateName
- */
- public TemplateCSSResource(String templateName) {
- super();
- setPath(templateName);
- }
- /**
- * @param templateName
- * @throws FacesException
- */
- public void setPath(String templateName) throws FacesException {
- // remove leaded / - as need for ClassLoader.getResource call.
- this.templateName = templateName.startsWith("/")?templateName.substring(1):templateName;
- // Self-register resource in system.
- _resource = InternetResourceBuilder.getInstance().createResource(null,this.templateName);
- _resource.setRenderer(templateCSSRenderer);
- try {
- // Attempt to compile template at init time. Due to client-side caching,
- // without registering resources requests can be not call rendering template.
- templateCSSRenderer.getTemplate(_resource, null);
- } catch (Exception e) {
- // Do nothing - template will be compiled at rendering time.
- // TODO log error.
- }
- }
-
- /**
- * @param context
- * @param data
- * @param attributes
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map attributes) throws IOException {
- _resource.encode(context, data, attributes);
- }
-
- /**
- * @param context
- * @param data
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- _resource.encode(context, data);
- }
-
- /**
- * @param context
- * @param component
- * @param attrs
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs) throws IOException {
- _resource.encodeBegin(context, component, attrs);
- }
-
- /**
- * @param context
- * @param component
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException {
- _resource.encodeEnd(context, component);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getContentLength(ResourceContext)
- */
- public int getContentLength(ResourceContext resourceContext) {
- return _resource.getContentLength(resourceContext);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getContentType(ResourceContext)
- */
- public String getContentType(ResourceContext resourceContext) {
- return _resource.getContentType(null);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getExpired(ResourceContext)
- */
- public Date getExpired(ResourceContext resourceContext) {
- return _resource.getExpired(null);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getKey()
- */
- public String getKey() {
- return _resource.getKey();
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getLastModified(ResourceContext)
- */
- public Date getLastModified(ResourceContext resourceContext) {
- return _resource.getLastModified(null);
- }
-
- /**
- * @param key
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- return _resource.getProperty(key);
- }
-
- /**
- * @param context
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getResourceAsStream(org.ajax4jsf.resource.ResourceContext)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- return _resource.getResourceAsStream(context);
- }
-
- /**
- * @param context
- * @param data
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext, java.lang.Object)
- */
- public String getUri(FacesContext context, Object data) {
- return _resource.getUri(context, data);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#isCacheable(ResourceContext)
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return _resource.isCacheable(null);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#isSessionAware()
- */
- public boolean isSessionAware() {
- return _resource.isSessionAware();
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
- */
- public boolean requireFacesContext() {
- return _resource.requireFacesContext();
- }
-
- /**
- * @param context
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#send(org.ajax4jsf.resource.ResourceContext)
- */
- public void send(ResourceContext context) throws IOException {
- _resource.send(context);
- }
-
- /**
- * @param response
- * @see org.ajax4jsf.resource.InternetResource#sendHeaders(org.ajax4jsf.resource.ResourceContext)
- */
- public void sendHeaders(ResourceContext response) {
- _resource.sendHeaders(response);
- }
-
- /**
- * @param key
- * @see org.ajax4jsf.resource.InternetResource#setKey(java.lang.String)
- */
- public void setKey(String key) {
- _resource.setKey(key);
- }
-
- /**
- * @param key
- * @param value
- * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object, java.lang.Object)
- */
- public void setProperty(Object key, Object value) {
- _resource.setProperty(key, value);
- }
-
- /**
- * @param renderer
- * @see org.ajax4jsf.resource.InternetResource#setRenderer(org.ajax4jsf.resource.ResourceRenderer)
- */
- public void setRenderer(ResourceRenderer renderer) {
- _resource.setRenderer(renderer);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getRenderer(ResourceContext)
- */
- public ResourceRenderer getRenderer(ResourceContext resourceContext) {
- return _resource.getRenderer(null);
- }
-
- /**
- * @param cacheable
- * @see org.ajax4jsf.resource.InternetResource#setCacheable(boolean)
- */
- public void setCacheable(boolean cacheable) {
- _resource.setCacheable(cacheable);
- }
-
- /**
- * @param expired
- * @see org.ajax4jsf.resource.InternetResource#setExpired(java.util.Date)
- */
- public void setExpired(Date expired) {
- _resource.setExpired(expired);
- }
-
- /**
- * @param lastModified
- * @see org.ajax4jsf.resource.InternetResource#setLastModified(java.util.Date)
- */
- public void setLastModified(Date lastModified) {
- _resource.setLastModified(lastModified);
- }
-
- /**
- * @param sessionAware
- * @see org.ajax4jsf.resource.InternetResource#setSessionAware(boolean)
- */
- public void setSessionAware(boolean sessionAware) {
- _resource.setSessionAware(sessionAware);
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,138 +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.resource.ResourceComponent;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @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.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.resource.InternetResourceBase#send(org.ajax4jsf.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.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: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,34 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-
-
-
-
- <meta content="text/html; charset=Windows-1251" http-equiv="content-type">
-
-
-
-
- <title>Internet Resources</title>
-</head>
-
-
-<body>
-
-
-<h1>Package for manipulate page resources ( images, scripts, styles,
-applets etc ) at Java Server Faces render Phase and at request phase of
-concrete resource.</h1>
-
-Note: The resource framework implements the Lightweight design patter.
-Therefore, the resource classes should not contain data depends of
-the particular request. The data is taken from the {@link javax.context.FacesContext}
-and {@link javax.component.UIComponent}, that is passed as a parameter
-when html is generated.
-For passing the data with URI, the {@link InternetResourceBase} class
-has getDataToSave method. It is invoked when the generation is taken place.
-The returned object is serialized. Then, restoreData method de-serialize it back.
-The {@link InternetResourceBuilder} class controls this process.
-</body>
-</html>
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceRenderer;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:07 $
+ *
+ */
+public abstract class BaseResourceRenderer implements ResourceRenderer {
+
+ public void encode(InternetResource resource, FacesContext context,
+ Object data) throws IOException {
+ this.encodeBegin(resource, context, data, Collections.EMPTY_MAP);
+ this.encodeEnd(resource, context, data);
+ }
+
+ public void encode(InternetResource resource, FacesContext context,
+ Object data, Map attributes) throws IOException {
+ this.encodeBegin(resource, context, data, attributes);
+ this.encodeEnd(resource, context, data);
+ }
+
+ public void encodeBegin(InternetResource resource, FacesContext context,
+ Object data, Map attributes) throws IOException {
+ if (null != getTag()) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(getTag(), null);
+ String attrs[][] = getCommonAttrs();
+ if (null != getHrefAttr()) {
+ writer.writeAttribute(getHrefAttr(), resource.getUri(context,
+ data), null);
+ }
+ if (null != attrs) {
+ for (int i = 0; i < attrs.length; i++) {
+ writer.writeAttribute(attrs[i][0], attrs[i][1], null);
+ }
+ }
+ for (Iterator iter = attributes.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry attr = (Map.Entry) iter.next();
+ writer.writeAttribute(attr.getKey().toString(),
+ attr.getValue(), null);
+ }
+ }
+ this.customEncode(resource, context, data);
+ }
+
+ public void encodeEnd(InternetResource resource, FacesContext context,
+ Object data) throws IOException {
+ if (null != getTag()) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.endElement(getTag());
+
+ }
+ }
+
+ /**
+ * Template method for customaize encoding for component. can insert size
+ * etc. attributes, child tags etc.
+ *
+ * @param resource
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ protected void customEncode(InternetResource resource,
+ FacesContext context, Object data) throws IOException {
+ // TODO if concrete renderer need
+
+ }
+
+ protected abstract String getTag();
+
+ protected abstract String getHrefAttr();
+
+ protected abstract String[][] getCommonAttrs();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
+ * org.ajax4jsf.resource.ResourceContext)
+ */
+ public int send(InternetResource base, ResourceContext context)
+ throws IOException {
+ InputStream in = base.getResourceAsStream(context);
+ OutputStream out = context.getOutputStream();
+ if (null == in) {
+ String message = Messages.getMessage(
+ Messages.NO_INPUT_STREAM_ERROR, base.getKey());
+ throw new IOException(message);
+ }
+ int total = sendStream(in, out);
+
+ return total;
+ }
+
+ /**
+ * @param in
+ * @param out
+ * @return
+ * @throws IOException
+ */
+ protected int sendStream(InputStream in, OutputStream out)
+ throws IOException {
+ int total = 0;
+ byte[] buffer = new byte[InternetResourceBase.BUFFER_SIZE];
+ int length;
+ try {
+ for (length = in.read(buffer); length > 0; length = in.read(buffer)) {
+ out.write(buffer, 0, length);
+ total += length;
+ }
+ } finally {
+ in.close();
+ out.flush();
+ out.close();
+ }
+ return total;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Object getData(InternetResource base, FacesContext context,
+ Object data) {
+ // By default, resource dot't provide any data. Can be used in
+ // Template-based or other
+ // configurable resources ( like weblets configuration ).
+ return null;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.ajax4jsf.resource;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.resource.InternetResource;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class CacheKey {
+ private Object resourceData;
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+ private InternetResource resource;
+ public CacheKey(Object resourceData,
+ HttpServletRequest request, HttpServletResponse response,
+ InternetResource resource) {
+ super();
+ this.resourceData = resourceData;
+ this.request = request;
+ this.response = response;
+ this.resource = resource;
+ }
+ public Object getResourceData() {
+ return resourceData;
+ }
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+ public HttpServletResponse getResponse() {
+ return response;
+ }
+ public InternetResource getResource() {
+ return resource;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,153 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
+ *
+ */
+public class CachedResourceContext extends ResourceContext {
+ private ResourceContext parent;
+ private CacheContent content;
+
+ /**
+ * @param parent
+ */
+ public CachedResourceContext(ResourceContext parent) {
+ this.setCacheEnabled(true);
+ this.parent = parent;
+ this.content = new CacheContent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ return content.getOutputStream();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
+ */
+ public String getPathInfo() {
+ return this.parent.getPathInfo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
+ */
+ public String getQueryString() {
+ return this.parent.getQueryString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getRequestParameter(java.lang.String)
+ */
+ public String getRequestParameter(String data_parameter) {
+ return this.parent.getRequestParameter(data_parameter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getResourceAsStream(java.lang.String)
+ */
+ public InputStream getResourceAsStream(String path) {
+ return this.parent.getResourceAsStream(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
+ */
+ public Object getSessionAttribute(String name) {
+ return this.parent.getSessionAttribute(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
+ */
+ public void setDateHeader(String name, long value) {
+ this.content.setDateHeader(name,value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String, java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ this.content.setHeader(name,value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
+ */
+ public void setIntHeader(String name, int value) {
+ this.content.setIntHeader(name,value);
+ }
+
+ /**
+ * @return Returns the content.
+ */
+ CacheContent getContent() {
+ return this.content;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException {
+ return content.getWriter();
+ }
+
+ public void setContentType(String contentType) {
+ this.content.setContentType(contentType);
+ }
+
+ public Object getResourceData() {
+ return parent.getResourceData();
+ }
+
+ public void setResourceData(Object codec) {
+ parent.setResourceData(codec);
+
+ }
+
+ public String getInitParameter(String name) {
+ return parent.getInitParameter(name);
+ }
+
+ public String getServletPath() {
+ return parent.getServletPath();
+ }
+
+ public void release() {
+ super.release();
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,181 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Resource for AJAX client-side script. Render one time per page.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/01/26 14:15:18 $
+ *
+ */
+public abstract class ClientScript extends JarResource {
+
+ private static final Log log = LogFactory.getLog(ClientScript.class);
+
+ protected boolean usePrototype = false;
+ /**
+ * Set JavaScript renderer and modification time to application-startup time.
+ */
+ public ClientScript() {
+ super();
+ setRenderer(new ScriptRenderer());
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+ String key = this.getClass().getName();
+ try {
+ // Search already registered resource for this class.
+ InternetResource resource = resourceBuilder.getResource(key);
+ this.setKey(resource.getKey());
+ } catch(ResourceNotFoundException ex){
+ // If script not registered, append it to builder.
+ setLastModified(new Date(resourceBuilder.getStartTime()));
+ resourceBuilder.addResource(key,this);
+ }
+ String script ;
+ if (getJavaScript().startsWith("/")) {
+ // remove lead / for classloader covention.
+ script = getJavaScript().substring(1);
+ } else {
+ script = this.getClass().getPackage().getName().replace('.', '/')+"/"
+ + getJavaScript();
+ }
+ setPath(script);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#getLastModified()
+ */
+ public Date getLastModified(ResourceContext resourceContext) {
+
+ if (isCacheable(null)) {
+ return super.getLastModified(resourceContext);
+ } else {
+ return new Date(System.currentTimeMillis()+1000L);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return true;
+ }
+
+ /**
+ * @return Returns the javaScript.
+ */
+ public abstract String getJavaScript();
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
+ */
+ public void encode(FacesContext context, Object data, Map attributes) throws IOException {
+ if (isNotAjaxRequest(context)) {
+ encodePrototype(context);
+ super.encode(context, data, attributes);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#encodeBegin(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs) throws IOException {
+ if (isNotAjaxRequest(context)) {
+ encodePrototype(context);
+ super.encodeBegin(context, component, attrs);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO, getKey()));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#encodeEnd(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void encodeEnd(FacesContext context, Object component) throws IOException {
+ if (isNotAjaxRequest(context)) {
+ super.encodeEnd(context, component);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO, getKey()));
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void encode(FacesContext context, Object data) throws IOException {
+ if (isNotAjaxRequest(context)) {
+ encodePrototype(context);
+ super.encode(context, data);
+ }else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
+ }
+ }
+
+ /**
+ * @return Returns the usePrototype.
+ */
+ protected boolean isUsePrototype() {
+ return usePrototype;
+ }
+
+
+ private boolean isNotAjaxRequest(FacesContext context){
+ return true;//! AjaxRendererUtils.isAjaxRequest(context);
+ }
+
+ private void encodePrototype(FacesContext context) throws IOException{
+ if (isUsePrototype()) {
+ InternetResourceBuilder.getInstance().createResource(null,PrototypeScript.class.getName()).encode(context,null);
+ }
+
+ }
+
+
+ /**
+ * @param usePrototype the usePrototype to set
+ */
+ public void setUsePrototype(boolean usePrototype) {
+ this.usePrototype = usePrototype;
+ }
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,223 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
+ *
+ */
+public class FacesResourceContext extends ResourceContext {
+
+ FacesContext facesContext;
+
+ ExternalContext externalContext;
+
+ HttpServletResponse response;
+
+ /**
+ * @param facesContext
+ */
+ public FacesResourceContext(FacesContext facesContext) {
+
+ this.facesContext = facesContext;
+ this.externalContext = facesContext.getExternalContext();
+ Object facesResponse = externalContext.getResponse();
+ if (facesResponse instanceof HttpServletResponse) {
+ this.response = (HttpServletResponse) facesResponse;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
+ * java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ if (null != response) {
+ response.setHeader(name, value);
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String,
+ * int)
+ */
+ public void setIntHeader(String name, int value) {
+ if (null != response) {
+ response.setIntHeader(name, value);
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String,
+ * long)
+ */
+ public void setDateHeader(String name, long value) {
+ if (null != response) {
+ response.setDateHeader(name, value);
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ if (null != response) {
+ return response.getOutputStream();
+
+ } else {
+ // May be non-servlet (Portlet?) environment. Try to use reflection
+ OutputStream stream = null;
+ Object response = externalContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getOutputStream", new Class[0]);
+ stream = (OutputStream) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return stream;
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException {
+ if (null != response) {
+ return response.getWriter();
+
+ } else {
+ // May be non-servlet (Portlet?) environment. Try to use reflection
+ PrintWriter writer = null;
+ Object response = externalContext.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;
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
+ */
+ public String getQueryString() {
+ return ((HttpServletRequest) externalContext.getRequest())
+ .getQueryString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
+ */
+ public String getPathInfo() {
+ return externalContext.getRequestPathInfo();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
+ */
+ public Object getSessionAttribute(String name) {
+ return externalContext.getSessionMap().get(name);
+ }
+
+ public InputStream getResourceAsStream(String path) {
+
+ return externalContext.getResourceAsStream(path);
+ }
+
+ public String getRequestParameter(String data_parameter) {
+
+ return (String) externalContext.getRequestParameterMap().get(
+ data_parameter);
+ }
+
+ public void setContentType(String contentType) {
+ response.setContentType(contentType);
+
+ }
+
+ public String getInitParameter(String name) {
+ // TODO Auto-generated method stub
+ return externalContext.getInitParameter(name);
+ }
+
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return externalContext.getRequestServletPath();
+ }
+
+ public void release() {
+ super.release();
+ externalContext = null;
+ response = null;
+ facesContext.release();
+ }
+
+ // added by nick 11.01.2007 - getters for contexts added
+ public FacesContext getFacesContext() {
+ return facesContext;
+ }
+
+ public ExternalContext getExternalContext() {
+ return externalContext;
+ }
+ // by nick
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.ajax4jsf.framework.util.image.GIFEncoder;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
+ *
+ */
+public class GifRenderer extends ImageRenderer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/gif";
+ }
+
+ public void sendImage(ResourceContext context, RenderedImage image)
+ throws IOException {
+ // ImageIO.write(image,"gif",context.getOutputStream());
+ GIFEncoder encoder = new GIFEncoder();
+ DataOutputStream out = new DataOutputStream(context.getOutputStream());
+ try {
+ encoder.encode((BufferedImage) image, out);
+ out.flush();
+ out.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ public int getImageType() {
+ // TODO Auto-generated method stub
+ return BufferedImage.TYPE_INT_ARGB;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
+ *
+ */
+public class HTMLRenderer extends BaseResourceRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "span";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "text/html";
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
+ */
+ protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
+ // Encode style in page - read from resource.
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ InputStream in = resource.getResourceAsStream(resourceContext);
+ StringBuffer buff = new StringBuffer();
+ int input;
+ while((input = in.read())>0){
+ buff.append((char)input);
+ }
+ in.close();
+ // MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
+ // TODO - detect page content type ?
+ context.getResponseWriter().writeText(buff,resource.getKey());
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.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;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @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: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,429 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for all Html page resources - images, scripts, styles etc. Realise
+ * as "brige" pattern - different subclasses for different resource source
+ * (static,jar,soft generator ) and customaized with differernt renderers for
+ * image, script, style ( linked ir inline ). must operate with different
+ * sources - application context, classpath, software generator.
+ *
+ * @author shura (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:15 $
+ *
+ */
+public abstract class InternetResourceBase implements InternetResource {
+
+ private static final Log log = LogFactory
+ .getLog(InternetResourceBase.class);
+
+ static final int BUFFER_SIZE = 1024;
+
+ // Hours
+
+ private int contentLength = -1;
+
+ private Date lastModified;
+
+ private Date expired;
+
+ private boolean cacheable = true;
+
+ private boolean sessionAware = true;
+
+ private ResourceRenderer renderer = null;
+
+ private Map customProperties = new HashMap();
+
+ private String key;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentLength()
+ */
+ public int getContentLength(ResourceContext resourceContext) {
+ return contentLength;
+ }
+
+ /**
+ * @param contentLength
+ * The contentLength to set.
+ */
+ protected void setContentLength(int contentLength) {
+ this.contentLength = contentLength;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getExpired()
+ */
+ public Date getExpired(ResourceContext resourceContext) {
+ return expired;
+ }
+
+ /**
+ * @param expired
+ * The expired to set.
+ */
+ public void setExpired(Date expired) {
+ this.expired = expired;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getLastModified()
+ */
+ public Date getLastModified(ResourceContext resourceContext) {
+
+ if (null != lastModified) {
+ return lastModified;
+ } else {
+ return new Date(System.currentTimeMillis());
+ }
+ }
+
+ /**
+ * @param lastModified
+ * The lastModified to set.
+ */
+ public void setLastModified(Date lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#isCacheable()
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return cacheable;
+ }
+
+ /**
+ * @param cacheable
+ * The cacheable to set.
+ */
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ /**
+ * @return Returns the sessionAware.
+ */
+ public boolean isSessionAware() {
+ return requireFacesContext();
+ }
+
+ /**
+ * @param sessionAware
+ * The sessionAware to set.
+ */
+ public void setSessionAware(boolean sessionAware) {
+ this.sessionAware = sessionAware;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentType()
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return getRenderer(null).getContentType();
+ }
+
+ /**
+ * @return Returns the renderer.
+ */
+ public ResourceRenderer getRenderer(ResourceContext resourceContext) {
+ return renderer;
+ }
+
+ /**
+ * @param renderer
+ * The renderer to set.
+ */
+ public void setRenderer(ResourceRenderer renderer) {
+ this.renderer = renderer;
+ }
+
+ /**
+ * Key for wich resource registered in resource builder.
+ *
+ * @return Returns the key.
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Set registration key ( by {@link InternetResourceBuilder} for this
+ * resource.
+ *
+ * @param key
+ * The key to set.
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public String getUri(final FacesContext context, Object data) {
+ return InternetResourceBuilder.getInstance().getUri(this, context,
+ getDataToStore(context, data));
+ }
+
+ /**
+ * Template method to construct resource-specific data ( to store in
+ * resource URI ). If resource must store any data in session or other
+ * cache, it must be done here. Since lightweight realisation, information
+ * for restore such data muct be returned by this method.
+ *
+ * @param context -
+ * current faces context.
+ * @param data -
+ * data for build information, usually current
+ * {@link javax.faces.component.UIComponent}
+ * @return - any {@link java.io.Serializable} object, or null.
+ */
+ protected Object getDataToStore(FacesContext context, Object data) {
+ return getRenderer(null).getData(this, context, data);
+ }
+
+ /**
+ * Restore data object from resource URI request parameter ( same object as
+ * returned in getDataToStore method )
+ *
+ * @param context
+ * @return restored data, or null.
+ */
+ protected Object restoreData(ResourceContext context) {
+
+ Object data = context.getResourceData();
+ if (data instanceof byte[]) {
+ byte[] objectArray = (byte[]) data;
+ data = deserializeData(objectArray);
+ }
+ return data;
+
+ }
+
+ /**
+ * Deserialize parameters object from byte array. By default, used Java
+ * de-serialisation from ObjectOutputStream , but implementations can
+ * override this method ( togewer with getDataToStore ) for implement short
+ * version.
+ *
+ * @param objectArray
+ * @return
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ protected Object deserializeData(byte[] objectArray) {
+ return objectArray;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getResourceAsStream()
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ throw new UnsupportedOperationException(Messages.getMessage(
+ Messages.METHOD_NOT_IMPLEMENTED, "getResourceAsStream"));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
+ */
+ public Object getProperty(Object key) {
+ // TODO Auto-generated method stub
+ return customProperties.get(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object,
+ * java.lang.Object)
+ */
+ public void setProperty(Object key, Object value) {
+ customProperties.put(key, value);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void encode(FacesContext context, Object data) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO, getKey()));
+ }
+ getRenderer(null).encode(this, context, data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
+ * java.lang.Object, java.util.Map)
+ */
+ public void encode(FacesContext context, Object data, Map attributes)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO_2,
+ getKey(), attributes));
+ }
+ getRenderer(null).encodeBegin(this, context, data, attributes);
+ getRenderer(null).encodeEnd(this, context, data);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent, java.util.Map)
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_BEGIN_HTML_INFO,
+ getKey(), attrs));
+ }
+ getRenderer(null).encodeBegin(this, context, component, attrs);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent, java.util.Map)
+ */
+ public void encodeEnd(FacesContext context, Object component)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_END_HTML_INFO,
+ getKey()));
+ }
+ getRenderer(null).encodeEnd(this, context, component);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#send(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void send(ResourceContext context) throws IOException {
+ if (log.isDebugEnabled()) {
+ log
+ .debug(Messages.getMessage(Messages.SEND_CONTENT_INFO,
+ getKey()));
+ }
+ int total = getRenderer(null).send(this, context);
+ // For cacheable resources, store size.
+ if (isCacheable(null)) {
+ setContentLength(total);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#sendHeaders(javax.servlet.http.HttpServletResponse)
+ */
+ public void sendHeaders(ResourceContext context) {
+ boolean cached = context.isCacheEnabled() && isCacheable(null);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SET_RESPONSE_HEADERS_INFO,
+ getKey()));
+ }
+ // context.setHeader("Content-Type",getContentType());
+ context.setContentType(getContentType(null));
+ if (getContentLength(context) > 0) {
+ context.setIntHeader("Content-Length", getContentLength(context));
+ } else {
+ // context.setHeader("Transfer-Encoding", "chunked");
+ }
+ Date lastModified = getLastModified(context);
+ if (lastModified != null) {
+ context.setDateHeader("Last-Modified", lastModified.getTime());
+ }
+ if (cached) {
+ Date expired = getExpired(context);
+ if (expired != null) {
+ context.setDateHeader("Expires", expired.getTime());
+ } else {
+ context.setDateHeader("Expires", System.currentTimeMillis()
+ + DEFAULT_EXPIRE);
+ context.setHeader("Cache-control", "max-age="
+ + (DEFAULT_EXPIRE / 1000));
+ }
+ } else {
+ context.setHeader("Cache-control", "max-age=0, no-store, no-cache");
+ context.setHeader("Pragma", "no-cache");
+ context.setIntHeader("Expires", 0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // by default, send data in ordinary Http request.
+ return getRenderer(null).requireFacesContext();
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,385 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.cache.CacheConfigurationLoader;
+import org.ajax4jsf.cache.CacheException;
+import org.ajax4jsf.cache.CacheFactory;
+import org.ajax4jsf.cache.CacheLoader;
+import org.ajax4jsf.cache.CacheManager;
+import org.ajax4jsf.cache.ServletContextInitMap;
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class InternetResourceService implements CacheLoader, CacheConfigurationLoader {
+ private static final Log log = LogFactory
+ .getLog(InternetResourceService.class);
+
+ static final String ENABLE_CACHING_PARAMETER = "enable-cache";
+
+ private static final String RESOURCE_LIFECYCLE_PARAMETER = "org.ajax4jsf.RESOURCE_LIFECYCLE";
+
+ private FilterConfig filterConfig;
+
+ private boolean cacheEnabled = true;
+
+ private Cache cache = null;
+
+ //private ServletCacheAdministrator cacheAdmin;
+
+ private FacesContextFactory contextFactory;
+
+ // private RenderKitFactory renderKitFactory;
+ private String lifecycleClass;
+
+ private ResourceLifecycle lifecycle;
+
+ private InternetResourceBuilder resourceBuilder;
+
+ private WebXml webXml;
+
+ public InternetResourceService() {
+ }
+
+ public void setCacheEnabled(boolean b) {
+ cacheEnabled = b;
+ }
+
+ public void init(FilterConfig config) throws ServletException {
+ filterConfig = config;
+ ServletContext servletContext = config.getServletContext();
+ if ("false".equalsIgnoreCase(config
+ .getInitParameter(ENABLE_CACHING_PARAMETER))) {
+ setCacheEnabled(false);
+ // this.cacheEnabled = false;
+ //this.cacheAdmin = null;
+ } else {
+ //this.cacheAdmin = ServletCacheAdministrator.getInstance(
+ // servletContext, cacheProperties);
+ try {
+ CacheManager cacheManager = CacheManager.getInstance();
+ Map env = new ServletContextInitMap(servletContext);
+ CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
+ this.cache = cacheFactory.createCache(env, this, this);
+ } catch (CacheException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+ // Create Resource-specific Faces Lifecycle instance.
+ lifecycleClass = servletContext
+ .getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
+ if (lifecycleClass != null) {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ try {
+ Class clazz = classLoader.loadClass(lifecycleClass);
+ lifecycle = (ResourceLifecycle) clazz.newInstance();
+ } catch (Exception e) {
+ throw new FacesException(
+ "Error create instance of resource Lifecycle "
+ + lifecycleClass, e);
+ }
+ } else {
+ lifecycle = new ResourceLifecycle();
+ }
+ webXml = new WebXml();
+ webXml.init(servletContext,filterConfig.getFilterName());
+ if (log.isDebugEnabled()) {
+ log.debug("Resources service initialized");
+ }
+ }
+
+ public boolean serviceResource(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse) throws ServletException,
+ IOException {
+ String resourceKey = webXml
+ .getFacesResourceKey(httpServletRequest);
+ if (null != resourceKey) {
+ serviceResource(resourceKey, httpServletRequest,
+ httpServletResponse);
+ return true;
+ }
+ return false;
+ }
+
+ public void serviceResource(String resourceKey, HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ InternetResource resource;// getInternetResource(request);
+ try {
+ resource = getResourceBuilder().getResourceForKey(resourceKey);
+ } catch (ResourceNotFoundException e) {
+ throw new ServletException(e);
+ }
+ Object resourceDataForKey = getResourceBuilder()
+ .getResourceDataForKey(resourceKey);
+ if (resource.isCacheable(null) && this.cacheEnabled) {
+ // Test for client request modification time.
+ try {
+ long ifModifiedSince = request
+ .getDateHeader("If-Modified-Since");
+ if (ifModifiedSince >= 0) {
+ // Test for modification. 1000 ms due to round
+ // modification
+ // time to seconds.
+ long lastModified = resource.getLastModified(null)
+ .getTime() - 1000;
+ if (lastModified <= ifModifiedSince) {
+ response.setStatus(304);
+ return;
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ log
+ .warn(
+ Messages
+ .getMessage(Messages.PARSING_IF_MODIFIED_SINCE_WARNING),
+ e);
+ }
+ String cacheKey = resourceKey;// + "?" +
+ // request.getQueryString();
+ // TODO - select session/application scope.
+ //Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
+// try {
+ // TODO - use last modified/expires time
+
+ CacheKey key = new CacheKey(resourceDataForKey, request, response, resource);
+
+ CacheContent content;
+ try {
+ content = (CacheContent) cache
+ .get(cacheKey, key);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
+ }
+ content.sendHeaders(response);
+ // Correct expires date for resource.
+ Date expired = resource.getExpired(null);
+ if (expired != null) {
+ response.setDateHeader("Expires", expired.getTime());
+ } else {
+ response.setDateHeader("Expires", System
+ .currentTimeMillis()
+ + InternetResource.DEFAULT_EXPIRE);
+ }
+ if (!request.getMethod().equals("HEAD")) {
+ content.send(response);
+ }/*
+ } catch (NeedsRefreshException e) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
+ }
+ CachedResourceContext context = (CachedResourceContext) sendResource(
+ resource, request, response, resourceDataForKey);
+ // TODO - set refresh interval ?
+ cache.put(cacheKey, context.getContent());
+ } catch (Exception ex) {
+ //cache.cancelUpdate(cacheKey);
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ ex);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
+ ex);
+ }
+ }*/
+ } catch (CacheException e) {
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ e);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, e.getMessage()),
+ e);
+ }
+ } else {
+ sendResource(resource, request, response, resourceDataForKey);
+ }
+ }
+
+ /**
+ * @param resource
+ * @param request
+ * @param response
+ * @throws IOException
+ */
+ protected ResourceContext sendResource(InternetResource resource,
+ HttpServletRequest request, HttpServletResponse response,
+ Object data) throws IOException {
+ ResourceContext resourceContext = getResourceContext(resource, request,
+ response);
+ resourceContext.setResourceData(data);
+ getLifecycle().send(resourceContext, resource);
+ resourceContext.release();
+ return resourceContext;
+ }
+
+ /**
+ * @param resource
+ * @param request
+ * @param response
+ * @return
+ * @throws ServletException
+ * @throws FacesException
+ */
+ protected ResourceContext getResourceContext(InternetResource resource,
+ HttpServletRequest request, HttpServletResponse response)
+ throws FacesException {
+ FacesContext facesContext = null;
+ ResourceContext resourceContext;
+ if (resource.requireFacesContext()) {
+ facesContext = getFacesContext(request, response);
+ resourceContext = new FacesResourceContext(facesContext);
+ } else {
+ resourceContext = new ServletResourceContext(getServletContext(),
+ request, response);
+ }
+ if (resource.isCacheable(null) && this.cacheEnabled) {
+ resourceContext = new CachedResourceContext(resourceContext);
+ }
+ return resourceContext;
+ }
+
+ /**
+ * Get properties file from classpath
+ *
+ * @param name
+ * @return
+ */
+ protected Properties getProperties(String name) {
+ Properties properties = new Properties();
+ InputStream props = BaseFilter.class.getResourceAsStream(name);
+ if (null != props) {
+ try {
+ properties.load(props);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
+ name), e);
+ } finally {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // Can be ignored
+ }
+ }
+ }
+ return properties;
+
+ }
+
+ /**
+ * @return Returns the servletContext.
+ */
+ protected ServletContext getServletContext() {
+ return filterConfig.getServletContext();
+ }
+
+ /**
+ * @return the lifecycle
+ * @throws ServletException
+ */
+ protected ResourceLifecycle getLifecycle() throws FacesException {
+ return lifecycle;
+ }
+
+ /**
+ * @return the contextFactory
+ */
+ protected synchronized FacesContextFactory getContextFactory() {
+ if (contextFactory == null) {
+ contextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ }
+
+ return contextFactory;
+ }
+
+ protected FacesContext getFacesContext(ServletRequest request,
+ ServletResponse response) throws FacesException {
+ return getContextFactory().getFacesContext(getServletContext(),
+ request, response, getLifecycle());
+ }
+
+ /**
+ * @return the resourceBuilder
+ */
+ protected InternetResourceBuilder getResourceBuilder() {
+ if (resourceBuilder == null) {
+ // Create resource builder for this filter.
+ resourceBuilder = InternetResourceBuilder.getInstance();
+ }
+ return resourceBuilder;
+ }
+
+ public Object load(Object key, Object context) throws CacheException {
+ CacheKey cacheKey = (CacheKey) context;
+
+ CachedResourceContext resourceContext = (CachedResourceContext) getResourceContext(cacheKey.getResource(), cacheKey.getRequest(),
+ cacheKey.getResponse());
+ resourceContext.setResourceData(cacheKey.getResourceData());
+ try {
+ getLifecycle().send(resourceContext, cacheKey.getResource());
+ } catch (IOException e) {
+ throw new CacheException(e.getMessage(), e);
+ }
+ resourceContext.release();
+
+ // TODO - set refresh interval ?
+ //cache.put(cacheKey, resourceContext.getContent());
+ return resourceContext.getContent();
+ }
+
+ public Properties loadProperties(String name) {
+ return getProperties(name);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,73 @@
+/**
+ * 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.resource;
+
+import java.io.InputStream;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * Class stoped all resources in application classpath.
+ * TODO - set last midified & expired values.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:00 $
+ *
+ */
+public class JarResource extends InternetResourceBase {
+
+ /**
+ * Default place for all static resources in Jar.
+ * to avoid access to any class in application, only allowed subpackages for
+ * META-INF/resources
+ */
+ public static final String RESOURCES_ROOT="META-INF/resources";
+
+ private String path;
+
+ public JarResource(){
+
+ }
+
+ public JarResource(String path) {
+ this.path = path;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return loader.getResourceAsStream(path);
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,135 @@
+/**
+ * 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.resource;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.ResourceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/01 15:31:57 $
+ *
+ */
+public class Java2Dresource extends InternetResourceBase {
+ private static final Log log = LogFactory.getLog(Java2Dresource.class);
+
+ /**
+ * Primary calculation of image dimensions - used when HTML code is
+ * generated to render IMG's width and height Subclasses should override
+ * this method to provide correct sizes of rendered images
+ *
+ * @param facesContext
+ * @return dimensions of the image to be displayed on page
+ */
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return new Dimension(1, 1);
+ }
+
+ /**
+ * Secondary calculation is used basically by {@link getImage} method
+ *
+ * @param resourceContext
+ * @return
+ */
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return new Dimension(1, 1);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ // TODO Auto-generated method stub
+ return super.getResourceAsStream(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResourceBase#send(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void send(ResourceContext context) throws IOException {
+ ImageRenderer renderer = (ImageRenderer) getRenderer(null);
+ try {
+ RenderedImage image = getImage(context);
+ if (null != image) {
+ renderer.sendImage(context, image);
+
+ }
+ } catch (Exception e) {
+ throw new FacesException(Messages
+ .getMessage(Messages.SEND_IMAGE_ERROR_2), e);
+ }
+ }
+
+ /**
+ * Create {@link RenderedImage} for send to client. can be used as Java2d or
+ * Java Advanced Imaging.
+ *
+ * @param context
+ * @return image to send.
+ */
+ protected RenderedImage getImage(ResourceContext context) {
+ ImageRenderer renderer = (ImageRenderer) getRenderer(null);
+ Dimension imageDimensions = getDimensions(context);
+ BufferedImage image = null;
+ if (imageDimensions.getHeight() > 0.0
+ && imageDimensions.getWidth() > 0.0) {
+ image = renderer.createImage(imageDimensions.width,
+ imageDimensions.height);
+ Graphics2D graphics = image.createGraphics();
+ paint(context, graphics);
+ graphics.dispose();
+
+ }
+ return image;
+ }
+
+ /**
+ * Template method for create image as Applet-like paint.
+ *
+ * @param context -
+ * current resource context.
+ * @param graphics2D -
+ * graphics to paint.
+ */
+ protected void paint(ResourceContext context, Graphics2D graphics2D) {
+ // TODO Auto-generated method stub
+
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,66 @@
+/**
+ * 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.resource;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
+ *
+ */
+public class JpegRenderer extends ImageRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/jpeg";
+ }
+
+ public void sendImage(ResourceContext context, RenderedImage image) throws IOException {
+ OutputStream outputStream = context.getOutputStream();
+ try {
+ ImageIO.write(image, "jpeg", outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ public int getImageType() {
+ // TODO Auto-generated method stub
+ return BufferedImage.TYPE_INT_RGB;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
+ *
+ */
+public class LogfileRenderer extends BaseResourceRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "pre";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "text/plain";
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
+ */
+ protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
+ // Encode style in page - read from resource.
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ InputStream in = resource.getResourceAsStream(resourceContext);
+ StringBuffer buff = new StringBuffer();
+ int input;
+ while((input = in.read())>0){
+ buff.append((char)input);
+ }
+ in.close();
+ // MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
+ // TODO - detect page content type ?
+ context.getResponseWriter().writeText(buff,resource.getKey());
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,66 @@
+/**
+ * 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.resource;
+
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 20.11.2006
+ *
+ */
+public class MimeRenderer extends BaseResourceRenderer {
+
+ private String contentType = null;
+
+ public MimeRenderer() {
+
+ }
+
+ public MimeRenderer(String contentType) {
+ super();
+ this.contentType = contentType;
+ }
+
+ public String getContentType() {
+ return this.contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+
+
+ protected String getTag() {
+ return null;
+ }
+
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,80 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for resources, rendered only one time in page ( JavaScript, CSS )
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
+ *
+ */
+public abstract class OneTimeRenderer extends BaseResourceRenderer {
+
+ private static final Log log = LogFactory.getLog(OneTimeRenderer.class);
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#encodeBegin(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
+ */
+ public void encodeBegin(InternetResource resource, FacesContext context, Object data, Map attributes) throws IOException {
+
+ if (!isRendered(resource,context)) {
+ super.encodeBegin(resource, context, data, attributes);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO_2, resource.getKey()));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#encodeEnd(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void encodeEnd(InternetResource resource, FacesContext context, Object data) throws IOException {
+ // TODO Auto-generated method stub
+ if (!isRendered(resource,context)) {
+ super.encodeEnd(resource, context, data);
+ context.getExternalContext().getRequestMap().put(resource.getKey(),Boolean.TRUE);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.MARK_AS_RENDERED_INFO, resource.getKey()));
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO_2, resource.getKey()));
+ }
+ }
+
+ /**
+ * Detect for resource rendered status. For cacheable, show key parameter in request Map.
+ * @param resource
+ * @param context
+ * @return - true, if resource already rendered.
+ */
+ private boolean isRendered(InternetResource resource, FacesContext context){
+ return null != context.getExternalContext().getRequestMap().get(resource.getKey()); // resource.isCacheable() &&
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,125 @@
+/**
+ * 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.resource;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
+ *
+ */
+public class Png8Renderer extends ImageRenderer {
+
+ /**
+ * Default web safe colors color model
+ */
+ public static IndexColorModel webColorModel;
+
+ // Build web safe 6x6x6 cube color model.
+ static {
+ byte[] webLevels = { 0, 51, 102, (byte) 153, (byte) 204, (byte) 255 };
+ byte[] r = new byte[256];
+ byte[] g = new byte[256];
+ byte[] b = new byte[256];
+ r[0] = g[0] = b[0] = 0;
+ for (int i = 0; i < webLevels.length; i++) {
+ for (int j = 0; j < webLevels.length; j++) {
+ for (int k = 0; k < webLevels.length; k++) {
+ int colorNum = i * webLevels.length * webLevels.length + j
+ * webLevels.length + k + 1;
+ r[colorNum] = webLevels[i];
+ g[colorNum] = webLevels[j];
+ b[colorNum] = webLevels[k];
+ }
+ }
+ }
+ webColorModel = new IndexColorModel(8, webLevels.length
+ * webLevels.length * webLevels.length + 1, r, g, b, 0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ImageRenderer#sendImage(org.ajax4jsf.resource.ResourceContext,
+ * java.awt.image.RenderedImage)
+ */
+ public void sendImage(ResourceContext context, RenderedImage image)
+ throws IOException {
+ OutputStream outputStream = context.getOutputStream();
+ // PNGEncodeParam param = new PNGEncodeParam.Palette();
+ // param.setBitDepth(8);
+ // param.setInterlacing(true);
+ // String[] encoders = ImageCodec.getEncoderNames(image,null);
+ // ImageEncoder encoder =
+ // ImageCodec.createImageEncoder("png",context.getOutputStream(),param);
+ // encoder.encode(image);
+ try {
+ ImageIO.write(image, "png", outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ImageRenderer#getImageType()
+ */
+ public int getImageType() {
+ return BufferedImage.TYPE_BYTE_INDEXED;
+ // return BufferedImage.TYPE_INT_ARGB;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ImageRenderer#createImage(int, int)
+ */
+ public BufferedImage createImage(int width, int height) {
+
+ // return new BufferedImage(width,height,getImageType());//,colorModel);
+ return new BufferedImage(width, height, getImageType(), webColorModel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/png";
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,63 @@
+/**
+ * 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.resource;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:05 $
+ *
+ */
+public class PngRenderer extends ImageRenderer {
+
+ public void sendImage(ResourceContext context, RenderedImage image)
+ throws IOException {
+ OutputStream outputStream = context.getOutputStream();
+ try {
+ ImageIO.write(image, "png", outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/png";
+ }
+
+ public int getImageType() {
+ // TODO Auto-generated method stub
+ return BufferedImage.TYPE_INT_ARGB;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,36 @@
+/**
+ * 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.resource;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
+ *
+ */
+public class PrototypeScript extends ClientScript {
+
+ public String getJavaScript() {
+ return "scripts/prototype.js";
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,589 @@
+/**
+ * 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.resource;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StreamCorruptedException;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.Deflater;
+import java.util.zip.Inflater;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.imageio.ImageIO;
+import javax.servlet.ServletContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.util.base64.Codec;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.ajax4jsf.resource.ResourceRenderer;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Produce instances of InternetResource's for any types - jar resource, dynamic
+ * created image, component-incapsulated etc. Realised as singleton class to
+ * support cache, configuration etc.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
+ *
+ */
+public class ResourceBuilderImpl extends InternetResourceBuilder {
+
+ private static final Log log = LogFactory.getLog(ResourceBuilderImpl.class);
+
+ private static final String DATA_SEPARATOR = "/DATA/";
+
+ private static Map renderers;
+
+ private static ResourceRenderer defaultRenderer = new MimeRenderer(null);
+
+ /**
+ * keep resources instances . TODO - put this map to application-scope
+ * attribute, for support clastering environment.
+ */
+ private Map resources = Collections.synchronizedMap(new HashMap());
+
+ private long _startTime;
+
+ private Codec codec;
+
+ static {
+ renderers = new HashMap();
+ // append known renderers for extentions.
+ renderers.put(".gif", new GifRenderer());
+ ResourceRenderer renderer = new JpegRenderer();
+ renderers.put(".jpeg", renderer);
+ renderers.put(".jpg", renderer);
+ renderers.put(".png", new PngRenderer());
+ renderers.put(".js", new ScriptRenderer());
+ renderers.put(".css", new StyleRenderer());
+ renderers.put(".log", new LogfileRenderer());
+ renderers.put(".html", new HTMLRenderer());
+ renderers.put(".xhtml", new MimeRenderer("application/xhtml+xml"));
+ renderers.put(".xml", new MimeRenderer("text/xml"));
+ renderers.put(".xcss", new TemplateCSSRenderer());
+ // renderers.put(".htc",new BehaviorRenderer());
+ // set in-memory caching ImageIO
+ ImageIO.setUseCache(false);
+
+ }
+
+ public WebXml getWebXml(FacesContext context) {
+ WebXml webXml = (WebXml) context.getExternalContext().getApplicationMap().get(WebXml.CONTEXT_ATTRIBUTE);
+ if (null == webXml) {
+ throw new FacesException(
+ "Resources framework is not initialised, check web.xml for Filter configuration");
+ }
+ return webXml;
+ }
+
+ public ResourceBuilderImpl() {
+ super();
+ _startTime = System.currentTimeMillis();
+ codec = new Codec();
+ }
+
+ /**
+ * @throws FacesException
+ */
+ protected void registerResources() throws FacesException {
+ try {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Enumeration e = loader
+ .getResources("META-INF/resources-config.xml");
+ while (e.hasMoreElements()) {
+ URL resource = (URL) e.nextElement();
+ registerConfig(resource);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ private void registerConfig(URL resourceConfig) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Process resources configuration file "+resourceConfig.toExternalForm());
+ }
+
+ InputStream in = resourceConfig.openStream();
+ try {
+ Digester digester = new Digester();
+ digester.setValidating(false);
+ digester.setEntityResolver(new EntityResolver() {
+ // Dummi resolver - alvays do nothing
+ public InputSource resolveEntity(String publicId,
+ String systemId) throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+ });
+ digester.setNamespaceAware(false);
+ digester.setUseContextClassLoader(true);
+ digester.push(this);
+ digester.addObjectCreate("resource-config/resource", "class",
+ JarResource.class);
+ digester.addObjectCreate("resource-config/resource/renderer",
+ "class", HTMLRenderer.class);
+ digester.addCallMethod(
+ "resource-config/resource/renderer/content-type",
+ "setContentType", 0);
+ digester.addSetNext("resource-config/resource/renderer",
+ "setRenderer", ResourceRenderer.class.getName());
+ digester.addCallMethod("resource-config/resource/name",
+ "setKey", 0);
+ digester.addCallMethod("resource-config/resource/path",
+ "setPath", 0);
+ digester.addCallMethod("resource-config/resource/cacheable",
+ "setCacheable", 0);
+ digester.addCallMethod(
+ "resource-config/resource/session-aware",
+ "setSessionAware", 0);
+ digester.addCallMethod("resource-config/resource/property",
+ "setProperty", 2);
+ digester.addCallParam("resource-config/resource/property/name",
+ 0);
+ digester.addCallParam(
+ "resource-config/resource/property/value", 1);
+ digester.addCallMethod("resource-config/resource/content-type",
+ "setContentType", 0);
+ digester.addSetNext("resource-config/resource", "addResource",
+ InternetResource.class.getName());
+ digester.parse(in);
+ } finally {
+ in.close();
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ } catch (SAXException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ /**
+ */
+ public void init()
+ throws FacesException {
+ // TODO - mace codec configurable.
+ registerResources();
+ }
+
+ /**
+ * Base point for creating resource. Must detect type and build
+ * appropriate instance. Currently - make static resource for ordinary
+ * request, or instance of class.
+ *
+ * @param base
+ * base object for resource ( resourcess in classpath
+ * will be get relative to it package )
+ * @param path
+ * key - path to resource, resource class name etc.
+ * @return
+ * @throws FacesException
+ */
+ public InternetResource createResource(Object base, String path)
+ throws FacesException {
+ // TODO - detect type of resource ( for example, resources location path
+ // in Skin
+ try {
+ return getResource(path);
+ } catch (ResourceNotFoundException e) {
+ try {
+ return getResource(buildKey(base, path));
+ } catch (ResourceNotFoundException e1) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_INFO,
+ path));
+ }
+ }
+ }
+ // path - is class name ?
+ InternetResource res;
+ try {
+ Class resourceClass = Class.forName(path);
+ res = createDynamicResource(path, resourceClass);
+ } catch (Exception e) {
+ try {
+ res = createJarResource(base, path);
+ } catch (ResourceNotFoundException ex) {
+ res = createStaticResource(path);
+ }
+ // TODO - if resource not found, create static ?
+ }
+ return res;
+ }
+
+ private String buildKey(Object base, String path) {
+ if (path.startsWith("/")) {
+ return path.substring(1);
+ }
+ if (null == base) {
+ return path;
+ }
+ StringBuffer packageName = new StringBuffer(base.getClass()
+ .getPackage().getName().replace('.', '/'));
+ return packageName.append("/").append(path).toString();
+ }
+
+ public String getUri(InternetResource resource, FacesContext context,
+ Object storeData) {
+ StringBuffer uri = new StringBuffer();// ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
+ uri.append(resource.getKey());
+ // append serialized data as Base-64 encoded request string.
+ if (storeData != null) {
+ try {
+ byte[] objectData;
+ if (!(storeData instanceof byte[])) {
+ ByteArrayOutputStream dataSteram = new ByteArrayOutputStream(
+ 1024);
+ ObjectOutputStream objStream = new ObjectOutputStream(
+ dataSteram);
+ objStream.writeObject(storeData);
+ objStream.flush();
+ objStream.close();
+ dataSteram.close();
+ objectData = dataSteram.toByteArray();
+ } else {
+ objectData = (byte[]) storeData;
+ }
+ uri.append(DATA_SEPARATOR);
+ byte[] dataArray = encrypt(objectData);
+ uri.append(new String(dataArray, "ISO-8859-1"));
+
+ // / byte[] objectData = dataSteram.toByteArray();
+ // / uri.append("?").append(new
+ // String(Base64.encodeBase64(objectData),
+ // / "ISO-8859-1"));
+ } catch (Exception e) {
+ // Ignore errors, log it
+ log.error(Messages
+ .getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
+ }
+ }
+ String resourceURL = getWebXml(context).getFacesResourceURL(context,
+ uri.toString());// context.getApplication().getViewHandler().getResourceURL(context,uri.toString());
+ if (resource.isSessionAware()) {
+ resourceURL = context.getExternalContext().encodeResourceURL(
+ resourceURL);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
+ resource.getKey(), resourceURL));
+ }
+ return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
+
+ }
+
+ /**
+ * @param key
+ * @return
+ */
+ public InternetResource getResourceForKey(String key)
+ throws ResourceNotFoundException {
+
+ int data = key.indexOf(DATA_SEPARATOR);
+ if (data >= 0) {
+ key = key.substring(0, data);
+ }
+ return getResource(key);
+ }
+
+ public Object getResourceDataForKey(String key) {
+ Object data = null;
+ String dataString = null;
+ int dataStart = key.indexOf(DATA_SEPARATOR);
+ if (dataStart >= 0) {
+ dataString = key.substring(dataStart + DATA_SEPARATOR.length());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.RESTORE_DATA_FROM_RESOURCE_URI_INFO, key,
+ dataString));
+ }
+ if (dataString != null) {
+ // dataString =
+ // dataString.substring(dataStart+ResourceServlet.DATA_PARAMETER.length()+1);
+ byte[] objectArray = null;
+ try {
+ byte[] dataArray = dataString.getBytes("ISO-8859-1");
+ objectArray = decrypt(dataArray);
+
+ ObjectInputStream in = new ObjectInputStream(
+ new ByteArrayInputStream(objectArray));
+ data = in.readObject();
+ } catch (StreamCorruptedException e) {
+ data = objectArray;
+ } catch (IOException e) {
+ log.error(Messages
+ .getMessage(Messages.DESERIALIZE_DATA_INPUT_ERROR), e);
+ } catch (ClassNotFoundException e) {
+ log.error(Messages
+ .getMessage(Messages.DATA_CLASS_NOT_FOUND_ERROR), e);
+ }
+ }
+ return data;
+ }
+
+ public InternetResource getResource(String path)
+ throws ResourceNotFoundException {
+
+ InternetResource internetResource = (InternetResource) resources
+ .get(path);
+ if (null == internetResource) {
+ throw new ResourceNotFoundException("Resource not registered : "
+ + path);
+ } else {
+ return internetResource;
+ }
+ }
+
+ public void addResource(InternetResource resource) {
+ resources.put(resource.getKey(), resource);
+ ResourceRenderer renderer = resource.getRenderer(null);
+ if (renderer == null) {
+ setRenderer(resource, resource.getKey());
+ }
+ }
+
+ public void addResource(String key, InternetResource resource) {
+ resources.put(key, resource);
+ resource.setKey(key);
+ // TODO - set renderer ?
+ }
+
+// public String getFacesResourceKey(HttpServletRequest request) {
+// return getWebXml(context).getFacesResourceKey(request);
+// }
+
+ public String getFacesResourceURL(FacesContext context, String Url) {
+ return getWebXml(context).getFacesResourceURL(context, Url);
+ }
+
+ /**
+ * Build resource for link to static context in webapp.
+ *
+ * @param path
+ * @return
+ * @throws FacesException
+ */
+ protected InternetResource createStaticResource(String path)
+ throws ResourceNotFoundException, FacesException {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (null != context) {
+ if (context.getExternalContext().getContext() instanceof ServletContext) {
+ ServletContext servletContext = (ServletContext) context
+ .getExternalContext().getContext();
+ InputStream in = servletContext.getResourceAsStream(path);
+ if (null != in) {
+ InternetResourceBase res = new StaticResource(path);
+ setRenderer(res, path);
+ res.setLastModified(new Date(getStartTime()));
+ addResource(path, res);
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ return res;
+ }
+ }
+ }
+ throw new ResourceNotFoundException(Messages.getMessage(
+ Messages.STATIC_RESOURCE_NOT_FOUND_ERROR, path));
+ }
+
+ private void setRenderer(InternetResource res, String path)
+ throws FacesException {
+ int lastPoint = path.lastIndexOf('.');
+ if (lastPoint > 0) {
+ String ext = path.substring(lastPoint);
+ ResourceRenderer resourceRenderer = (ResourceRenderer) renderers
+ .get(ext);
+ if (null != resourceRenderer) {
+ res.setRenderer(resourceRenderer);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.NO_RESOURCE_REGISTERED_ERROR_2, path,
+ renderers.keySet()));
+ }
+
+ // String mimeType = servletContext.getMimeType(path);
+ res.setRenderer(defaultRenderer);
+ }
+ }
+ }
+
+ /**
+ * Create resurce to send from classpath relative to base class.
+ *
+ * @param base
+ * @param path
+ * @return
+ * @throws FacesException
+ */
+ protected InternetResource createJarResource(Object base, String path)
+ throws ResourceNotFoundException, FacesException {
+ String key = buildKey(base, path);
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (null != loader.getResource(key)) {
+ JarResource res = new JarResource(key);
+ setRenderer(res, path);
+ res.setLastModified(new Date(getStartTime()));
+ addResource(key, res);
+ return res;
+ } else {
+ throw new ResourceNotFoundException(Messages.getMessage(
+ Messages.NO_RESOURCE_EXISTS_ERROR, key));
+ }
+
+ }
+
+ /**
+ * Create resource by instatiate given class.
+ *
+ * @param path
+ * @param instatiate
+ * @return
+ */
+ protected InternetResource createDynamicResource(String path,
+ Class instatiate) throws ResourceNotFoundException {
+ if (InternetResource.class.isAssignableFrom(instatiate)) {
+ InternetResource resource;
+ try {
+ resource = (InternetResource) instatiate.newInstance();
+ addResource(path, resource);
+ } catch (Exception e) {
+ String message = Messages.getMessage(
+ Messages.INSTANTIATE_RESOURCE_ERROR, instatiate
+ .toString());
+ log.error(message, e);
+ throw new ResourceNotFoundException(message, e);
+ }
+ return resource;
+ }
+ throw new FacesException(Messages
+ .getMessage(Messages.INSTANTIATE_CLASS_ERROR));
+ }
+
+ /**
+ * Create resource by instatiate {@link UserResource} class with given
+ * properties ( or got from cache ).
+ *
+ * @param cacheable
+ * @param session
+ * @param mime
+ * @return
+ * @throws FacesException
+ */
+ public InternetResource createUserResource(boolean cacheable,
+ boolean session, String mime) throws FacesException {
+ String path = getUserResourceKey(cacheable, session, mime);
+ InternetResource userResource;
+ try {
+ userResource = getResource(path);
+ } catch (ResourceNotFoundException e) {
+ userResource = new UserResource(cacheable, session, mime);
+ addResource(path, userResource);
+ }
+ return userResource;
+ }
+
+ /**
+ * Generate resource key for user-generated resource with given
+ * properties.
+ *
+ * @param cacheable
+ * @param session
+ * @param mime
+ * @return
+ */
+ private String getUserResourceKey(boolean cacheable, boolean session,
+ String mime) {
+ StringBuffer pathBuffer = new StringBuffer(UserResource.class.getName());
+ pathBuffer.append(cacheable ? "/c" : "/n");
+ pathBuffer.append(session ? "/s" : "/n");
+ if (null != mime) {
+ pathBuffer.append('/').append(mime.hashCode());
+ }
+ String path = pathBuffer.toString();
+ return path;
+ }
+
+ /**
+ * @return Returns the startTime for application.
+ */
+ public long getStartTime() {
+ return _startTime;
+ }
+
+ protected byte[] encrypt(byte[] src) {
+ try {
+ Deflater compressor = new Deflater(Deflater.BEST_SPEED);
+ byte[] compressed = new byte[src.length + 100];
+ compressor.setInput(src);
+ compressor.finish();
+ int totalOut = compressor.deflate(compressed);
+ byte[] zipsrc = new byte[totalOut];
+ System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
+ compressor.end();
+ return codec.encode(zipsrc);
+ } catch (Exception e) {
+ throw new FacesException("Error encode resource data", e);
+ }
+ }
+
+ protected byte[] decrypt(byte[] src) {
+ try {
+ byte[] zipsrc = codec.decode(src);
+ Inflater decompressor = new Inflater();
+ byte[] uncompressed = new byte[zipsrc.length * 5];
+ decompressor.setInput(zipsrc);
+ int totalOut = decompressor.inflate(uncompressed);
+ byte[] out = new byte[totalOut];
+ System.arraycopy(uncompressed, 0, out, 0, totalOut);
+ decompressor.end();
+ return out;
+ } catch (Exception e) {
+ throw new FacesException("Error decode resource data", e);
+ }
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * Lifecycle for simulate faces request processing for resource.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
+ *
+ */
+public class ResourceLifecycle extends Lifecycle {
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#addPhaseListener(javax.faces.event.PhaseListener)
+ */
+ public void addPhaseListener(PhaseListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#execute(javax.faces.context.FacesContext)
+ */
+ public void execute(FacesContext arg0) throws FacesException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#getPhaseListeners()
+ */
+ public PhaseListener[] getPhaseListeners() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#removePhaseListener(javax.faces.event.PhaseListener)
+ */
+ public void removePhaseListener(PhaseListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#render(javax.faces.context.FacesContext)
+ */
+ public void render(FacesContext arg0) throws FacesException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @param context
+ * @param resource
+ * @throws IOException
+ */
+ public void send(ResourceContext resourceContext, InternetResource resource) throws IOException{
+ resource.sendHeaders(resourceContext);
+ resource.send(resourceContext);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,150 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.javascript.JSMin;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
+ *
+ */
+public class ScriptRenderer extends OneTimeRenderer {
+
+ private static final String COMPRESS_SCRIPTS_PARAMETER = "org.ajax4jsf.COMPRESS_SCRIPT";
+
+ private static final Log _log = LogFactory.getLog(ScriptRenderer.class);
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "script";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return "src";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return new String[][]{{"type",getContentType()}};
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO - use configurable encoding ?
+ return "text/javascript";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
+ */
+ public int send(InternetResource base, ResourceContext context) throws IOException {
+ InputStream in = base.getResourceAsStream(context);
+ if (null == in) {
+ String message = Messages.getMessage(
+ Messages.NO_INPUT_STREAM_ERROR, base.getKey());
+ throw new IOException(message);
+ }
+ OutputStream out = context.getOutputStream();
+ // Compress JavaScript output by JSMin ( true by default )
+ if( ! "false".equalsIgnoreCase(context.getInitParameter(COMPRESS_SCRIPTS_PARAMETER))){
+ CountingOutputStream countingStream = new CountingOutputStream(out);
+ JSMin jsmin = new JSMin(in,countingStream);
+ try {
+ jsmin.jsmin();
+ } catch (Exception e) {
+ _log.error("Error send script to client for resource "+base.getKey(), e);
+ } finally {
+ in.close();
+ countingStream.flush();
+ countingStream.close();
+ }
+ int written = countingStream.getWritten();
+ if(_log.isDebugEnabled()){
+ _log.debug("Send "+written+" bytes to client for JavaScript resource "+base.getKey());
+ }
+ return written;
+ } else {
+ return sendStream(in, out);
+ }
+ }
+
+
+}
+
+class CountingOutputStream extends OutputStream {
+ private OutputStream outputStream;
+ private int written = 0;
+
+ CountingOutputStream(OutputStream outputStream) {
+ super();
+ this.outputStream = outputStream;
+ }
+
+ public void close() throws IOException {
+ outputStream.close();
+ }
+
+ public void flush() throws IOException {
+ outputStream.flush();
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ outputStream.write(b, off, len);
+ written += len;
+ }
+
+ public void write(byte[] b) throws IOException {
+ outputStream.write(b);
+ written += b.length;
+ }
+
+ public void write(int b) throws IOException {
+ outputStream.write(b);
+ written++;
+ }
+
+ int getWritten() {
+ return written;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,143 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
+ *
+ */
+public class ServletResourceContext extends ResourceContext {
+
+ private ServletContext context;
+ private HttpServletRequest request;
+
+ private HttpServletResponse response;
+
+ /**
+ * @param request
+ * @param response
+ */
+ public ServletResourceContext(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
+ this.context = context;
+ this.request = request;
+ this.response = response;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String, java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ response.setHeader(name,value);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
+ */
+ public void setIntHeader(String name, int value) {
+ response.setIntHeader(name,value);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
+ */
+ public void setDateHeader(String name, long value) {
+ response.setDateHeader(name,value);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ // TODO Auto-generated method stub
+ return response.getOutputStream();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
+ */
+ public String getQueryString() {
+ return request.getQueryString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
+ */
+ public String getPathInfo() {
+ return request.getPathInfo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
+ */
+ public Object getSessionAttribute(String name) {
+ return request.getSession(false).getAttribute(name);
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ // TODO Auto-generated method stub
+ return context.getResourceAsStream(path);
+ }
+
+ public String getRequestParameter(String data_parameter) {
+ // TODO Auto-generated method stub
+ return request.getParameter(data_parameter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException {
+ // TODO Auto-generated method stub
+ return response.getWriter();
+ }
+
+ public void setContentType(String contentType) {
+ response.setContentType(contentType);
+ }
+
+ public String getInitParameter(String name) {
+ // TODO Auto-generated method stub
+ return context.getInitParameter(name);
+ }
+
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return request.getServletPath();
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SmartPositionScript extends ClientScript {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ // TODO Auto-generated method stub
+ return "scripts/smartposition.js";
+ }
+
+ protected boolean isUsePrototype() {
+
+ return true;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.io.InputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
+ *
+ */
+public class StaticResource extends InternetResourceBase {
+
+ private String path;
+ private byte[] resourceData = null;
+
+ /**
+ *
+ */
+ public StaticResource() {
+ super();
+ }
+
+
+
+ public StaticResource(String path){
+ this.path = path;
+ setCacheable(true);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ return context.getResourceAsStream(path);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return true;
+ }
+
+
+
+ public String getUri(FacesContext context, Object data) {
+ // perform all encodings, suitable for JSF specification.
+ String src = context.getApplication().getViewHandler().getResourceURL(context,path);
+ return context.getExternalContext().encodeResourceURL(src);
+ }
+
+ public void encode(FacesContext context, Object data) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+ /**
+ * @return the path
+ */
+ public String getPath() {
+ return path;
+ }
+
+
+
+ /**
+ * @param path the path to set
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+
+/**
+ * Render style element with content in page. Warning - not use for head link element,
+ * it must be rendered separate.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
+ *
+ */
+public class StyleRenderer extends OneTimeRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ return "link";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ return "href";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ return new String[][]{{"type","text/css"},{"rel","stylesheet"}};
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO use configurable encoding ?
+ return "text/css";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
+ */
+ /*
+ protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
+ // Encode style in page - read from resource.
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ InputStream in = resource.getResourceAsStream(resourceContext);
+ StringBuffer buff = new StringBuffer();
+ int input;
+ while((input = in.read())>0){
+ buff.append((char)input);
+ }
+ in.close();
+ // MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
+ // TODO - detect page content type ?
+ context.getResponseWriter().writeText(buff,resource.getKey());
+ }
+*/
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
+import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
+import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author shura
+ *
+ */
+public class TemplateCSSRenderer extends StyleRenderer {
+
+ private static final String COMPILED_TEMPLATE_PROPERTY = "compiled-template";
+
+ private RendererBase renderer = new RendererBase() {
+
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIComponent.class;
+ }
+
+ };
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
+ */
+ public int send(InternetResource base, ResourceContext context) throws IOException {
+ PreparedTemplate template = null;
+ template = getTemplate(base, context);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if(null != facesContext) {
+ // Create responseWriter.
+ String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
+ if (null == defaultRenderKitId) {
+ defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+ RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
+ // TODO - handle response encoding
+ ResponseWriter responseWriter = renderKit.createResponseWriter(context.getWriter(),null,"UTF-8");
+ facesContext.setResponseWriter(responseWriter);
+ responseWriter.startDocument();
+ // TODO - parameters and mock renderer/component ?
+ // for first time, this template only allow skin or faces variables interaction
+ template.encode(renderer,facesContext,null);
+ responseWriter.endDocument();
+ responseWriter.flush();
+ responseWriter.close();
+ } else {
+ throw new FacesException("FacesContext for resource from template "+base.getKey()+" is null");
+ }
+ return 0;
+ }
+
+ /**
+ * @param base
+ * @param context
+ * @return
+ * @throws IOException
+ */
+ public PreparedTemplate getTemplate(InternetResource base, ResourceContext context) throws IOException {
+ PreparedTemplate template;
+ // if(base.isCacheable()){
+ template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
+ // }
+ if(null == template){
+ HtmlCompiler compiler = new HtmlCompiler();
+ InputStream resourceAsStream = base.getResourceAsStream(context);
+ template = compiler.compile(resourceAsStream, base.getKey());
+ base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
+ resourceAsStream.close();
+ }
+ return template;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ return true;
+ }
+
+ public Object getData(InternetResource base, FacesContext context, Object data) {
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ PreparedTemplate template;
+ try {
+ template = getTemplate(base, resourceContext);
+ } catch (IOException e) {
+ return null;
+ }
+ UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
+ TemplateContext templateContext = new TemplateContext(null,context,component);
+ Object value = template.getValue(templateContext);
+ if(null == value){
+ int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
+ value = ByteBuffer.allocate(4).putInt(hashCode).array();
+ }
+ return value;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,295 @@
+/**
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceRenderer;
+
+
+/**
+ * Class for create and send resources from template ( at most, used for CSS files )
+ * @author shura (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
+ *
+ */
+public class TemplateCSSResource implements InternetResource {
+
+ private String templateName;
+ private InternetResource _resource;
+ private static TemplateCSSRenderer templateCSSRenderer = new TemplateCSSRenderer();
+
+ public TemplateCSSResource(){
+
+ }
+ /**
+ * @param templateName
+ */
+ public TemplateCSSResource(String templateName) {
+ super();
+ setPath(templateName);
+ }
+ /**
+ * @param templateName
+ * @throws FacesException
+ */
+ public void setPath(String templateName) throws FacesException {
+ // remove leaded / - as need for ClassLoader.getResource call.
+ this.templateName = templateName.startsWith("/")?templateName.substring(1):templateName;
+ // Self-register resource in system.
+ _resource = InternetResourceBuilder.getInstance().createResource(null,this.templateName);
+ _resource.setRenderer(templateCSSRenderer);
+ try {
+ // Attempt to compile template at init time. Due to client-side caching,
+ // without registering resources requests can be not call rendering template.
+ templateCSSRenderer.getTemplate(_resource, null);
+ } catch (Exception e) {
+ // Do nothing - template will be compiled at rendering time.
+ // TODO log error.
+ }
+ }
+
+ /**
+ * @param context
+ * @param data
+ * @param attributes
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
+ */
+ public void encode(FacesContext context, Object data, Map attributes) throws IOException {
+ _resource.encode(context, data, attributes);
+ }
+
+ /**
+ * @param context
+ * @param data
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void encode(FacesContext context, Object data) throws IOException {
+ _resource.encode(context, data);
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param attrs
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs) throws IOException {
+ _resource.encodeBegin(context, component, attrs);
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void encodeEnd(FacesContext context, Object component) throws IOException {
+ _resource.encodeEnd(context, component);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getContentLength(ResourceContext)
+ */
+ public int getContentLength(ResourceContext resourceContext) {
+ return _resource.getContentLength(resourceContext);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getContentType(ResourceContext)
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return _resource.getContentType(null);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getExpired(ResourceContext)
+ */
+ public Date getExpired(ResourceContext resourceContext) {
+ return _resource.getExpired(null);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getKey()
+ */
+ public String getKey() {
+ return _resource.getKey();
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getLastModified(ResourceContext)
+ */
+ public Date getLastModified(ResourceContext resourceContext) {
+ return _resource.getLastModified(null);
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
+ */
+ public Object getProperty(Object key) {
+ return _resource.getProperty(key);
+ }
+
+ /**
+ * @param context
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getResourceAsStream(org.ajax4jsf.resource.ResourceContext)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ return _resource.getResourceAsStream(context);
+ }
+
+ /**
+ * @param context
+ * @param data
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public String getUri(FacesContext context, Object data) {
+ return _resource.getUri(context, data);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#isCacheable(ResourceContext)
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return _resource.isCacheable(null);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#isSessionAware()
+ */
+ public boolean isSessionAware() {
+ return _resource.isSessionAware();
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ return _resource.requireFacesContext();
+ }
+
+ /**
+ * @param context
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#send(org.ajax4jsf.resource.ResourceContext)
+ */
+ public void send(ResourceContext context) throws IOException {
+ _resource.send(context);
+ }
+
+ /**
+ * @param response
+ * @see org.ajax4jsf.resource.InternetResource#sendHeaders(org.ajax4jsf.resource.ResourceContext)
+ */
+ public void sendHeaders(ResourceContext response) {
+ _resource.sendHeaders(response);
+ }
+
+ /**
+ * @param key
+ * @see org.ajax4jsf.resource.InternetResource#setKey(java.lang.String)
+ */
+ public void setKey(String key) {
+ _resource.setKey(key);
+ }
+
+ /**
+ * @param key
+ * @param value
+ * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object, java.lang.Object)
+ */
+ public void setProperty(Object key, Object value) {
+ _resource.setProperty(key, value);
+ }
+
+ /**
+ * @param renderer
+ * @see org.ajax4jsf.resource.InternetResource#setRenderer(org.ajax4jsf.resource.ResourceRenderer)
+ */
+ public void setRenderer(ResourceRenderer renderer) {
+ _resource.setRenderer(renderer);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getRenderer(ResourceContext)
+ */
+ public ResourceRenderer getRenderer(ResourceContext resourceContext) {
+ return _resource.getRenderer(null);
+ }
+
+ /**
+ * @param cacheable
+ * @see org.ajax4jsf.resource.InternetResource#setCacheable(boolean)
+ */
+ public void setCacheable(boolean cacheable) {
+ _resource.setCacheable(cacheable);
+ }
+
+ /**
+ * @param expired
+ * @see org.ajax4jsf.resource.InternetResource#setExpired(java.util.Date)
+ */
+ public void setExpired(Date expired) {
+ _resource.setExpired(expired);
+ }
+
+ /**
+ * @param lastModified
+ * @see org.ajax4jsf.resource.InternetResource#setLastModified(java.util.Date)
+ */
+ public void setLastModified(Date lastModified) {
+ _resource.setLastModified(lastModified);
+ }
+
+ /**
+ * @param sessionAware
+ * @see org.ajax4jsf.resource.InternetResource#setSessionAware(boolean)
+ */
+ public void setSessionAware(boolean sessionAware) {
+ _resource.setSessionAware(sessionAware);
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,138 @@
+/**
+ * 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.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.resource.ResourceComponent;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @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.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.resource.InternetResourceBase#send(org.ajax4jsf.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.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: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached)
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/CachedResourceBuilder.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.io.IOException;
import java.io.InputStream;
@@ -29,8 +29,8 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.resource.ResourceNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/DualLRUMap.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.util.HashMap;
import java.util.Map;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/ResourceBean.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.io.Serializable;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/ResourceBytesDataBean.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.util.Arrays;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/ResourceDataBean.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
/**
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html (from rev 1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+
+
+
+
+ <meta content="text/html; charset=Windows-1251" http-equiv="content-type">
+
+
+
+
+ <title>Internet Resources</title>
+</head>
+
+
+<body>
+
+
+<h1>Package for manipulate page resources ( images, scripts, styles,
+applets etc ) at Java Server Faces render Phase and at request phase of
+concrete resource.</h1>
+
+Note: The resource framework implements the Lightweight design patter.
+Therefore, the resource classes should not contain data depends of
+the particular request. The data is taken from the {@link javax.context.FacesContext}
+and {@link javax.component.UIComponent}, that is passed as a parameter
+when html is generated.
+For passing the data with URI, the {@link InternetResourceBase} class
+has getDataToSave method. It is invoked when the generation is taken place.
+The returned object is serialized. Then, restoreData method de-serialize it back.
+The {@link InternetResourceBuilder} class controls this process.
+</body>
+</html>
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -32,10 +32,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -29,9 +29,9 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
public abstract class SliderArrowBase extends Java2Dresource{
Modified: trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-05 20:50:37 UTC (rev 1508)
@@ -6,7 +6,7 @@
<faces-config>
<factory>
- <render-kit-factory>org.ajax4jsf.renderkit.ChameleonRenderKitFactory</render-kit-factory>
+ <render-kit-factory>org.ajax4jsf.framework.renderer.ChameleonRenderKitFactory</render-kit-factory>
<lifecycle-factory>org.ajax4jsf.framework.DebugLifecycleFactory</lifecycle-factory>
</factory>
<application>
@@ -18,7 +18,7 @@
<state-manager>org.ajax4jsf.framework.ajax.AjaxStateManager</state-manager>
</application>
<lifecycle>
- <phase-listener>org.ajax4jsf.renderkit.AjaxPhaseListener</phase-listener>
+ <phase-listener>org.ajax4jsf.framework.renderer.AjaxPhaseListener</phase-listener>
<phase-listener>org.ajax4jsf.framework.ajax.InitPhaseListener</phase-listener>
</lifecycle>
<managed-bean>
@@ -55,7 +55,7 @@
</description>
<component-family>javax.faces.ViewRoot</component-family>
<renderer-type>javax.faces.ViewRoot</renderer-type>
- <renderer-class>org.ajax4jsf.renderkit.AjaxViewRootRenderer</renderer-class>
+ <renderer-class>org.ajax4jsf.framework.renderer.AjaxViewRootRenderer</renderer-class>
</renderer>
<!--
<renderer>
Copied: trunk/framework/impl/src/main/resources/META-INF/resources-config.xml (from rev 1507, trunk/ui/core/src/main/config/resources/resources-config.xml)
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/resources-config.xml (rev 0)
+++ trunk/framework/impl/src/main/resources/META-INF/resources-config.xml 2007-07-05 20:50:37 UTC (rev 1508)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resource-config>
+ <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
+ <name>org.ajax4jsf.framework.ajax.AjaxScript</name>
+ </resource>
+ <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
+ <name>ajax.js</name>
+ </resource>
+ <resource class="org.ajax4jsf.resource.PrototypeScript">
+ <name>prototype.js</name>
+ </resource>
+ <resource class="org.ajax4jsf.dnd.DnDScript">
+ <name>dnd.js</name>
+ </resource>
+ <resource >
+ <name>form.js</name>
+ <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
+ <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
+ </resource>
+ <resource >
+ <name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
+ <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
+ <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
+ </resource>
+</resource-config>
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -28,7 +28,7 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.FacesResourceContext;
+import org.ajax4jsf.resource.FacesResourceContext;
import org.apache.shale.test.mock.MockHttpServletResponse;
import com.gargoylesoftware.htmlunit.KeyValuePair;
Modified: trunk/framework/test/src/test/java/DnDScriptTest.java
===================================================================
--- trunk/framework/test/src/test/java/DnDScriptTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/DnDScriptTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -22,7 +22,7 @@
import java.io.IOException;
import org.ajax4jsf.dnd.DnDScript;
-import org.ajax4jsf.framework.resource.FacesResourceContext;
+import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -26,9 +26,11 @@
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.TemplateCSSResource;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockPrintWriter;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -25,6 +25,7 @@
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.InternetResourceService;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockServletOutputStream;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -24,6 +24,8 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.LogfileRenderer;
import org.ajax4jsf.resource.ResourceContext;
/**
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -2,6 +2,7 @@
import java.util.Arrays;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
public class ParametersEncodingTestCase extends AbstractAjax4JsfTestCase {
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -25,6 +25,7 @@
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.InternetResourceService;
import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
import org.apache.shale.test.mock.MockHttpServletRequest;
import org.apache.shale.test.mock.MockHttpServletResponse;
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,7 +1,12 @@
package org.richfaces.demo.datafilterslider;
-import java.util.*;
import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
/**
* Created by IntelliJ IDEA.
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,15 +1,13 @@
package org.richfaces.demo.datafilterslider;
-import org.richfaces.component.UIDataFltrSlider;
+import java.util.ArrayList;
+import java.util.List;
-import javax.faces.event.ActionEvent;
-import javax.faces.context.FacesContext;
import javax.faces.component.UIData;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.math.BigDecimal;
+import javax.faces.event.ActionEvent;
+import org.richfaces.component.UIDataFltrSlider;
+
public class DemoInventoryList {
DataFilterSliderDao dataFilterSliderDao = DataFilterSliderDaoImpl.getInstance();
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,9 +1,9 @@
package org.richfaces.demo.dnd;
- import org.ajax4jsf.dnd.event.DropEvent;
- import org.ajax4jsf.dnd.event.DropListener;
- import org.ajax4jsf.dnd.Dropzone;
+ import org.richfaces.component.Dropzone;
+import org.richfaces.event.DropEvent;
+import org.richfaces.event.DropListener;
public class EventBean implements DropListener {
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -4,7 +4,7 @@
import java.util.Iterator;
import java.util.Map;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Album implements TreeNode {
/**
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -4,7 +4,7 @@
import java.util.Iterator;
import java.util.Map;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Artist implements TreeNode {
private long id;
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -8,7 +8,7 @@
import java.util.Map;
import java.util.StringTokenizer;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Library implements TreeNode {
/**
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Song implements TreeNode {
/**
Deleted: trunk/ui/core/src/main/config/resources/resources-config.xml
===================================================================
--- trunk/ui/core/src/main/config/resources/resources-config.xml 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/core/src/main/config/resources/resources-config.xml 2007-07-05 20:50:37 UTC (rev 1508)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resource-config>
- <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
- <name>org.ajax4jsf.framework.ajax.AjaxScript</name>
- </resource>
- <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
- <name>ajax.js</name>
- </resource>
- <resource class="org.ajax4jsf.resource.PrototypeScript">
- <name>prototype.js</name>
- </resource>
- <resource class="org.ajax4jsf.dnd.DnDScript">
- <name>dnd.js</name>
- </resource>
- <resource >
- <name>form.js</name>
- <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
- <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
- </resource>
- <resource >
- <name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
- <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
- <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
- </resource>
-</resource-config>
Modified: trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
--- trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -42,11 +42,11 @@
import javax.faces.el.ValueBinding;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.event.DataFilterSliderAdapter;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -31,7 +31,7 @@
import org.ajax4jsf.dnd.DnDScript;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.resource.PrototypeScript;
+import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DragEvent;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -30,11 +30,11 @@
import org.ajax4jsf.dnd.DnDScript;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.resource.PrototypeScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DropEvent;
Modified: trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
===================================================================
--- trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -27,10 +27,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
Modified: trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
--- trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -24,11 +24,11 @@
import com.gargoylesoftware.htmlunit.KeyValuePair;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.html.*;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.renderkit.html.images.SliderArrowImage;
Modified: trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -25,10 +25,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
--- trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -24,11 +24,11 @@
import com.gargoylesoftware.htmlunit.KeyValuePair;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.html.*;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.renderkit.html.images.background.SpinnerButtonGradient;
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java
===================================================================
--- trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -9,10 +9,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -40,10 +40,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
Modified: trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
--- trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -41,10 +41,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.MockViewRoot;
Modified: trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java
===================================================================
--- trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -34,12 +34,12 @@
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.ImageRenderer;
-import org.ajax4jsf.framework.resource.InternetResourceBase;
-import org.ajax4jsf.framework.resource.JpegRenderer;
-import org.ajax4jsf.framework.resource.PngRenderer;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.ImageRenderer;
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.JpegRenderer;
+import org.ajax4jsf.resource.PngRenderer;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.resource.ResourceRenderer;
import org.apache.commons.logging.Log;
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -21,11 +21,11 @@
package org.richfaces.renderkit.html.images;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.component.UISeparator;
import org.richfaces.skin.Skin;
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -21,11 +21,11 @@
package org.richfaces.renderkit.html.images;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.component.UISeparator;
import org.richfaces.skin.Skin;
Modified: trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
===================================================================
--- trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -27,10 +27,10 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import com.gargoylesoftware.htmlunit.Page;
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -29,10 +29,10 @@
import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.framework.resource.TemplateCSSResource;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.TemplateCSSResource;
import org.richfaces.component.AjaxSuggestionEvent;
import org.richfaces.component.UISuggestionBox;
import org.richfaces.skin.Skin;
@@ -80,8 +80,8 @@
* Additional scripts.
*/
private final InternetResource[] additionalScripts = {
- new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.resource.SmartPositionScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.SmartPositionScript(),
getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
getResource("scripts/scriptaculo.js"),
getResource("scripts/suggestionbox.js")};
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -21,10 +21,10 @@
package org.richfaces.renderkit.images;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -25,10 +25,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
Modified: trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java
===================================================================
--- trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -26,11 +26,11 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.component.UIToolBar;
import org.richfaces.component.UIToolBarGroup;
import org.richfaces.skin.Skin;
Modified: trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
===================================================================
--- trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -25,10 +25,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import junit.framework.Assert;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import javax.faces.component.UICommand;
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -26,10 +26,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-05 19:11:50 UTC (rev 1507)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-05 20:50:37 UTC (rev 1508)
@@ -38,10 +38,10 @@
import javax.faces.event.PhaseId;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.component.state.events.ExpandAllCommandEvent;
17 years, 5 months
JBoss Rich Faces SVN: r1507 - branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-07-05 15:11:50 -0400 (Thu, 05 Jul 2007)
New Revision: 1507
Removed:
branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.xhtml
Modified:
branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp
Log:
Modified: branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp 2007-07-05 19:10:16 UTC (rev 1506)
+++ branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.jsp 2007-07-05 19:11:50 UTC (rev 1507)
@@ -13,12 +13,12 @@
<h:selectOneRadio binding="#{skinBean.component}" />
<h:commandLink action="#{skinBean.change}" value="set skin" />
- <pm:panelMenu>
+ <pm:panelMenu selectedChild="thisChild">
<pm:panelMenuGroup label="Group 1" iconExpanded="disc" iconCollapsed="chevron">
- <pm:panelMenuItem value="Item 1" icon="chevronUp">
+ <pm:panelMenuItem value="Item 1" icon="chevronUp" name="thisChild">
</pm:panelMenuItem>
- <pm:panelMenuItem value="Item "/>
- <pm:panelMenuGroup label="Group 2" >
+ <pm:panelMenuItem value="Item" mode="server" action="ddd"/>
+ <pm:panelMenuGroup label="Group 2" mode="server" action="ddwd">
<pm:panelMenuItem icon="triangleDown">
<f:verbatim>Item 3</f:verbatim>
</pm:panelMenuItem>
Deleted: branches/3.0.2/sandbox-samples/panelmenu-sample/src/main/webapp/pages/index.xhtml
===================================================================
(Binary files differ)
17 years, 6 months
JBoss Rich Faces SVN: r1506 - in branches/3.0.2/sandbox/panelmenu/src/main: java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-07-05 15:10:16 -0400 (Thu, 05 Jul 2007)
New Revision: 1506
Modified:
branches/3.0.2/sandbox/panelmenu/src/main/config/component/panelMenu.xml
branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java
branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java
branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/css/panelMenu.xcss
branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
branches/3.0.2/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
Log:
Modified: branches/3.0.2/sandbox/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/config/component/panelMenu.xml 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/config/component/panelMenu.xml 2007-07-05 19:10:16 UTC (rev 1506)
@@ -250,7 +250,14 @@
<classname>java.lang.String</classname>
<description></description>
<defaultvalue><![CDATA["dr-pmenu-hovered-element rich-pmenu-hovered-element"]]></defaultvalue>
- </property>
+ </property>
+ <property>
+ <name>selectedChild</name>
+ <classname>java.lang.String</classname>
+ <description>contain the name or the clientId of any of the item or group, the child defined in this attribute should be highlighted on PanelMenu rendering</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
&ui_component_attributes;
&html_events;
@@ -285,8 +292,6 @@
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
-
-
<property>
<name>onitemhover</name>
<classname>java.lang.String</classname>
@@ -370,7 +375,14 @@
If “true” sets state of the item to disabled state. “false” is default.
</description>
<defaultvalue>false</defaultvalue>
- </property>
+ </property>
+ <property>
+ <name>name</name>
+ <classname>java.lang.String</classname>
+ <description>'selectedChild' attribute of PanelMenu refers to group/item with the same name</description>
+ <defaultvalue>getId()</defaultvalue>
+ </property>
+
<!--property>
<name>value</name>
<classname>java.lang.Object</classname>
@@ -513,7 +525,13 @@
<name>value</name>
<classname>java.lang.Object</classname>
<description>Defines representation text for menuItem.</description>
- </property>
+ </property>
+ <property>
+ <name>name</name>
+ <classname>java.lang.String</classname>
+ <description>'selectedChild' attribute of PanelMenu refers to group/item with the same name</description>
+ <defaultvalue>getId()</defaultvalue>
+ </property>
<property>
<name>hoverClass</name>
<classname>java.lang.String</classname>
Modified: branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenu.java 2007-07-05 19:10:16 UTC (rev 1506)
@@ -1,11 +1,14 @@
package org.richfaces.component;
-import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIInput;
-public abstract class UIPanelMenu extends UIComponentBase{
+public abstract class UIPanelMenu extends UIInput{
public static final String COMPONENT_TYPE = "org.richfaces.panelMenu";
+ public static final String DEFAULT_SELECTED_CLASS = "dr-pmenu-selected-item";
+ public static final String USER_DEFINED_SELECTED_CLASS = "rich-pmenu-item-selected";
+
public abstract String getEvent();
public abstract void setEvent(String event);
public abstract String getMode();
@@ -104,6 +107,10 @@
public abstract void setOnmouseover(String string);
public abstract String getOnmouseover();
+ public abstract void setSelectedChild(String string);
+ public abstract String getSelectedChild();
-
+ public String getSelectedName(){
+ return getValue() != null ? getValue().toString() : getSelectedChild();
+ }
}
Modified: branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2007-07-05 19:10:16 UTC (rev 1506)
@@ -79,7 +79,10 @@
public abstract boolean isExpanded();
public abstract void setExpanded(boolean expanded);
+ public abstract void setName(String string);
+ public abstract String getName();
+
public UIPanelMenuGroup(){
setConverter(new BooleanConverter());
}
Modified: branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuItem.java 2007-07-05 19:10:16 UTC (rev 1506)
@@ -57,4 +57,7 @@
public abstract String getTarget();
public abstract void setTarget(String target);
+ public abstract void setName(String string);
+ public abstract String getName();
+
}
Modified: branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2007-07-05 19:10:16 UTC (rev 1506)
@@ -23,15 +23,16 @@
import java.io.IOException;
import java.util.Map;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.ConverterException;
import javax.faces.event.ActionEvent;
+
import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.richfaces.component.UIPanelMenu;
import org.richfaces.component.UIPanelMenuGroup;
-import org.richfaces.component.UISwitchablePanel;
import org.richfaces.renderkit.PanelMenuRendererBase;
public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
@@ -56,7 +57,7 @@
}
if(isSubmitted(context, component)){
new ActionEvent(component).queue();
- if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
+ if ("ajax".equals(getItemMode(component))) {
new AjaxEvent(component).queue();
}
}
@@ -243,12 +244,16 @@
public String getLabelClass(FacesContext context, UIComponent component) {
UIPanelMenuGroup group = (UIPanelMenuGroup)component;
UIPanelMenu parentMenu = findMenu(group);
+ StringBuffer resClass = new StringBuffer();
if(!group.isDisabled() && !parentMenu.isDisabled()){
if(isTopLevel(component)){
- return "rich-pmenu-group-self-label rich-pmenu-top-group-self-label";
- } else return "rich-pmenu-group-self-label";
+ resClass.append("rich-pmenu-group-self-label rich-pmenu-top-group-self-label");
+ } else resClass.append("rich-pmenu-group-self-label");
}
- return "";
+ if(isSelected(context, component)){
+ resClass.append(" ").append(UIPanelMenu.DEFAULT_SELECTED_CLASS).append(" ").append(UIPanelMenu.USER_DEFINED_SELECTED_CLASS);
+ }
+ return resClass.toString();
}
public String getIconClass(FacesContext context, UIComponent component) {
@@ -277,4 +282,11 @@
result = "dr-pmenu-group";
return result;
}
+
+ public boolean isSelected(FacesContext context, UIComponent component){
+ UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ UIPanelMenu parentMenu = findMenu(group);
+ return group.getName().equals(parentMenu.getSelectedName());
+ }
+
}
Modified: branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2007-07-05 19:10:16 UTC (rev 1506)
@@ -43,11 +43,10 @@
}
protected void doDecode(FacesContext context, UIComponent component) {
if(isSubmitted(context, component)) {
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
new ActionEvent(component).queue();
if ("ajax".equals(getItemMode(component))) {
new AjaxEvent(component).queue();
- } else {
-
}
}
}
@@ -56,12 +55,6 @@
}
- /*
- public String getOnClick(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- return ";PanelMenuStorage['" + clientId + "'].trigger(event);";
- }
- */
public void insertImage(FacesContext context, UIComponent component, Object data) throws IOException {
String from = (String)data;
UIPanelMenu panelMenu = findMenu(component);
@@ -169,14 +162,19 @@
}
public String getLabelClass(FacesContext context, UIComponent component) {
+ StringBuffer resClass = new StringBuffer();
UIPanelMenuItem item = (UIPanelMenuItem)component;
UIPanelMenu parentMenu = findMenu(item);
if(!item.isDisabled() && !parentMenu.isDisabled()){
if(isTopLevel(component)){
- return "rich-pmenu-item-label rich-pmenu-top-item-label";
- } else return "rich-pmenu-item-label";
+ resClass.append("rich-pmenu-item-label rich-pmenu-top-item-label");
+
+ } else resClass.append("rich-pmenu-item-label");
}
- return "";
+ if(isSelected(context, component)){
+ resClass.append(" ").append(UIPanelMenu.DEFAULT_SELECTED_CLASS).append(" ").append(UIPanelMenu.USER_DEFINED_SELECTED_CLASS);
+ }
+ return resClass.toString();
}
public String getIconClass(FacesContext context, UIComponent component) {
@@ -189,4 +187,10 @@
}
return "";
}
+
+ public boolean isSelected(FacesContext context, UIComponent component){
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
+ UIPanelMenu parentMenu = findMenu(item);
+ return item.getName().equals(parentMenu.getSelectedName());
+ }
}
Modified: branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-07-05 19:10:16 UTC (rev 1506)
@@ -23,13 +23,19 @@
import java.io.IOException;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+
+import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.richfaces.component.UIPanelMenu;
@@ -54,15 +60,21 @@
List flatList = new LinkedList();
Map levels = new HashMap();
- boolean expandSingle = ((UIPanelMenu)component).isExpandSingle();
+ Set itemNames = new HashSet();
+ UIPanelMenu parentMenu = (UIPanelMenu)component;
+
+ boolean expandSingle = parentMenu.isExpandSingle();
+
+ String selectedChild = parentMenu.getSelectedName();
+
flatten(component.getChildren(), flatList, levels, 0);
- panelMenu
- .append("new PanelMenu('")
+ panelMenu.append("new PanelMenu('")
.append(component.getClientId(context).toString())
.append("',")
.append(new Boolean(expandSingle).toString())
+ .append(",").append("'").append(selectedChild).append("'")
.append(");\n");
for (Iterator iter = flatList.iterator(); iter.hasNext();) {
@@ -81,7 +93,7 @@
child.getAttributes().put("rendered",Boolean.FALSE);
}
- UIPanelMenu parentMenu = findMenu(child);
+ //UIPanelMenu parentMenu = findMenu(child);
String event = parentMenu.getEvent();
if ("".equals(event))
@@ -112,10 +124,21 @@
else
targetString = target.toString();
-
-
if (childRendered && parentRendered){
if ( !isParentDisabled(child) ){
+ String childName;
+ if(child instanceof UIPanelMenuGroup){
+ childName = ((UIPanelMenuGroup)child).getName();
+ } else {
+ childName = ((UIPanelMenuItem)child).getName();
+ }
+
+ if(itemNames.contains(childName)){
+ throw new RuntimeException("Attibute \"name\" with value \"" + childName + "\" is already used in PanelMenu. It must be unique for every group/item.");
+ } else {
+ itemNames.add(childName);
+ }
+
buffer
.append("new PanelMenuItem({myId:'")
.append((String) child.getClientId(context))
@@ -126,11 +149,11 @@
.append(",event:\"" + event + "\"")
.append(",mode:\"" + mode + "\"")
.append(",target:\"" + targetString + "\"")
- .append(",disabled:" +
- new Boolean(childDisabled).toString())
+ .append(",disabled:" + new Boolean(childDisabled).toString())
+ .append(",target:\"" + targetString + "\"")
+ .append(",name:\"" + childName + "\"")
.append("},{");
-
for (int i = 0; i < hoveredStyles.length; i++)
if (!"".equals(hoveredStyles[i])) {
String [] temp = hoveredStyles[i].split(":");
@@ -273,8 +296,6 @@
try {
isNodeOpened = r.isOpened(context, child);
} catch (IOException e) {
- // TODO Auto-generated catch block
-// e.printStackTrace();
isNodeOpened = false;
}
buffer.append(",").append(String.valueOf(isNodeOpened));
@@ -329,7 +350,6 @@
defaultItemIconSrc = getIconByType(defaultItemIcon, isTopLevel,context, component);
}
-
customItemIcon = item.isDisabled() ? item.getIconDisabled() : item.getIcon();
if(customItemIcon != null && customItemIcon.equals("none")){
customIconSource = PANEL_MENU_SPACER_ICON;
@@ -433,5 +453,16 @@
}
buffer.append("\"");
}
+
+ public void doDecode(FacesContext context, UIComponent component) {
+ Map requestMap = context.getExternalContext().getRequestParameterMap();
+ String menuClientId = component.getClientId(context);
+ UIPanelMenu menu = ((UIPanelMenu)component);
+ Object selectedItemName = requestMap.get(menuClientId + "selectedItemName");
+ if(selectedItemName != null){
+ menu.setSubmittedValue(selectedItemName);
+ }
+ }
+
}
Modified: branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/css/panelMenu.xcss
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/css/panelMenu.xcss 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/css/panelMenu.xcss 2007-07-05 19:10:16 UTC (rev 1506)
@@ -83,7 +83,9 @@
.dr-pmenu-disabled-element {
cursor: default;
}
-
+ .dr-pmenu-selected-item {
+ font-style : italic;
+ }
</f:verbatim>
</f:template>
\ No newline at end of file
Modified: branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-07-05 19:10:16 UTC (rev 1506)
@@ -6,17 +6,20 @@
window.Richfaces = {};
}
-//TODO by nick - dima - better not to use global object to track panels
var PanelMenuStorage = new Object();
PanelMenu = Class.create();
PanelMenu.prototype = {
- initialize: function(myId,so){
+ initialize: function(myId, so, selectedChild){
this.childObj = new Array();
this.expandSingle = so;
this.lastExpanded = null;
- this.is = 'panelMenu';
+ this.selectedChild = selectedChild;
+ this.defaultSelectedClass = 'dr-pmenu-selected-item';
+ this.userDefinedSelectedClass = 'dr-pmenu-selected-item';
+ this.is = 'panelMenu';
+ this.selectedNameInput = $(myId + 'selectedItemName');
PanelMenuStorage[myId] = this;
}
};
@@ -31,6 +34,7 @@
this.onclose = options.onclose;
this.event = options.event;
this.disabled = options.disabled;
+ this.name = options.name;
this.mode = options.mode;
if (!this.mode)
@@ -58,6 +62,15 @@
}
parent = parent.parentObj;
}
+ // parent - root menu object
+ this.rootMenu = parent;
+
+ if(this.rootMenu.selectedChild == this.name){
+ this.selected = true;
+ } else {
+ this.selected = false;
+ }
+ this.clientId = ids.myId;
this.obj = $("tdhide" + ids.myId);
this.leftIcon = $('leftIcon' + ids.myId);
this.rightIcon = $('rightIcon' + ids.myId);
@@ -183,7 +196,8 @@
},
preTrigger: function(e){
- this.inputAction.setAttribute('value', this.obj.id);
+ //this.inputAction.setAttribute('value', this.obj.id);
+ this.inputAction.setAttribute('value', this.clientId);
},
postTrigger: function(e){
@@ -212,6 +226,11 @@
},
itemClicked: function(e){
+ this.globalClearSelection();
+ this.setSelectedClass();
+
+ this.rootMenu.selectedNameInput.value = this.name;
+
if(this.action){
if (this.action=='panelMenuNodeAction'){
if (this.expanded){
@@ -283,31 +302,55 @@
}
},
+ globalClearSelection: function(e) {
+ for(var key in PanelMenuStorage){
+ if(PanelMenuStorage.hasOwnProperty(key)){
+ if(PanelMenuStorage[key].type == 'node' || PanelMenuStorage[key].type == 'item'){
+ PanelMenuStorage[key].removeSelectedClass();
+ }
+ }
+ }
+ },
+
+
+
+ setSelectedClass: function(e){
+ this.labelArea.addClassName(this.rootMenu.defaultSelectedClass);
+ this.labelArea.addClassName(this.rootMenu.userDefinedSelectedClass);
+ },
+ removeSelectedClass: function(e){
+ this.labelArea.removeClassName(this.rootMenu.defaultSelectedClass);
+ this.labelArea.removeClassName(this.rootMenu.userDefinedSelectedClass);
+ },
+
+
addHoverStyles: function(e) {
- if(!this.hasInitialSylesChecked){
- this.initialStyles = this.tablehider.style.cssText;
- this.hasInitialSylesChecked = true;
- }
- if (this.hoveredStyles) {
- Element.setStyle(this.tablehider, this.hoveredStyles);
- }
- if (this.hoveredClasses)
- for (i = 0; i < this.hoveredClasses.length; i++) {
- this.tablehider.addClassName(this.hoveredClasses[i]);
+ if(!this.selected){
+ if(!this.hasInitialSylesChecked){
+ this.initialStyles = this.tablehider.style.cssText;
+ this.hasInitialSylesChecked = true;
}
-
+ if (this.hoveredStyles) {
+ Element.setStyle(this.tablehider, this.hoveredStyles);
+ }
+ if (this.hoveredClasses)
+ for (i = 0; i < this.hoveredClasses.length; i++) {
+ this.tablehider.addClassName(this.hoveredClasses[i]);
+ }
+ }
},
removeHoverStyles: function(e) {
- if (this.hoveredStyles && this.hasInitialSylesChecked) {
- this.tablehider.style.cssText = this.initialStyles;
- }
-
- if (this.hoveredClasses)
- for (var i = 0; i < this.hoveredClasses.length; i++){
- this.tablehider.removeClassName(this.hoveredClasses[i]);
+ if(!this.selected){
+ if (this.hoveredStyles && this.hasInitialSylesChecked) {
+ this.tablehider.style.cssText = this.initialStyles;
}
-
+
+ if (this.hoveredClasses)
+ for (var i = 0; i < this.hoveredClasses.length; i++){
+ this.tablehider.removeClassName(this.hoveredClasses[i]);
+ }
+ }
},
_getDirectChildrenByTag: function(e, tagName) {
Modified: branches/3.0.2/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
===================================================================
--- branches/3.0.2/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-07-05 19:01:59 UTC (rev 1505)
+++ branches/3.0.2/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-07-05 19:10:16 UTC (rev 1506)
@@ -31,7 +31,7 @@
onmousemove="#{component.onmousemove}"
onmouseout="#{component.onmouseout}"
onmouseover="#{component.onmouseover}" >
-
+ <input type="hidden" id="#{clientId}selectedItemName" name="#{clientId}selectedItemName" value="" />
<vcp:body>
<f:call name="renderChildren" />
</vcp:body>
17 years, 6 months