Per EG's latest request, please review the changes for the additional
ResourceHandler.createAjaxResource method:
M 5035 jsf-api/src/javax/faces/application/ResourceHandler.java
--- Add createAjaxResource() that will create the Ajax resource with name
--- "ajax.js" in library "javax.faces"
M 5035
jsf-api/src/javax/faces/application/ResourceHandlerWrapper.java
--- Add createAjaxResource() (calls through to
ResourceHandler.createAjaxResource()
M 5035
jsf-ri/test/com/sun/faces/application/resource/TestResourceHandlerImpl.java
--- test case
M 5035
jsf-ri/src/com/sun/faces/application/resource/ResourceHandlerImpl.java
--- implementation
Kito D. Mann wrote:
> After reviewing the EDR spec, I think we should give the Ajax integration
> library special support. So, I propose the following (all of this refers to
> ...
>
> 2. Provide a convenience method on ResourceHanlder so that a developer can
> write t his:
>
> Resource resource = context.getApplication().getResourceHandler()
> .createAjaxResource();
>
> Instead of this:
>
> Resource resource = context.getApplication().getResourceHandler()
> .createResource("ajax.js", "javax.faces");
>
>
Index: jsf-api/src/javax/faces/application/ResourceHandler.java
===================================================================
--- jsf-api/src/javax/faces/application/ResourceHandler.java (revision 5035)
+++ jsf-api/src/javax/faces/application/ResourceHandler.java (working copy)
@@ -278,8 +278,20 @@
String libraryName,
String contentType);
-
/**
+ * <p class="changed_added_2_0">Create an instance of the Ajax
+ * <code>Resource</code> with the <em>resourceName</em>
+ * <code>ajax.js</code> that is a member of the library
+ * <code>javax.faces</code> as specified in section 13.1 of the spec
+ * prose document <a
+ * href="../../../overview-summary.html#prose_document">linked in
+ * the overview summary</a>.
+ *
+ * @return a newly created Ajax <code>Resource</code> instance.
+ */
+ public abstract Resource createAjaxResource();
+
+ /**
* <p class="changed_added_2_0">This method specifies the contract
* for satisfying resource requests. This method is called from
* {_at_link javax.faces.webapp.FacesServlet#service} after that method
Index: jsf-api/src/javax/faces/application/ResourceHandlerWrapper.java
===================================================================
--- jsf-api/src/javax/faces/application/ResourceHandlerWrapper.java (revision 5035)
+++ jsf-api/src/javax/faces/application/ResourceHandlerWrapper.java (working copy)
@@ -69,6 +69,17 @@
/**
* <p class="changed_added_2_0">The default behavior of this method
+ * is to call {_at_link ResourceHandler#createAjaxResource()} on the
+ * wrapped {_at_link ResourceHandler} object.</p>
+ */
+ public Resource createAjaxResource() {
+
+ return getWrapped().createAjaxResource();
+
+ }
+
+ /**
+ * <p class="changed_added_2_0">The default behavior of this method
* is to call {_at_link ResourceHandler#createResource(String)} on the
* wrapped {_at_link ResourceHandler} object.</p>
*/
Index: jsf-ri/test/com/sun/faces/application/resource/TestResourceHandlerImpl.java
===================================================================
--- jsf-ri/test/com/sun/faces/application/resource/TestResourceHandlerImpl.java (revision 5035)
+++ jsf-ri/test/com/sun/faces/application/resource/TestResourceHandlerImpl.java (working copy)
@@ -93,8 +93,13 @@
assertTrue(handler != null);
assertTrue(handler instanceof ResourceHandlerImpl);
- Resource resource = handler.createResource("duke-nv.gif");
+ Resource resource = handler.createAjaxResource();
assertTrue(resource != null);
+ assertTrue("javax.faces".equals(resource.getLibraryName()));
+ assertTrue("ajax.js".equals(resource.getResourceName()));
+
+ resource = handler.createResource("duke-nv.gif");
+ assertTrue(resource != null);
assertTrue(resource.getLibraryName() == null);
assertTrue("duke-nv.gif".equals(resource.getResourceName()));
assertTrue("image/gif".equals(resource.getContentType()));
Index: jsf-ri/src/com/sun/faces/application/resource/ResourceHandlerImpl.java
===================================================================
--- jsf-ri/src/com/sun/faces/application/resource/ResourceHandlerImpl.java (revision 5035)
+++ jsf-ri/src/com/sun/faces/application/resource/ResourceHandlerImpl.java (working copy)
@@ -95,6 +95,15 @@
/**
+ * @see ResourceHandler#createAjaxResource()
+ */
+ public Resource createAjaxResource() {
+
+ return createResource("ajax.js", "javax.faces", null);
+
+ }
+
+ /**
* @see ResourceHandler#createResource(String)
*/
public Resource createResource(String resourceName) {