Author: nbelaevski
Date: 2007-04-18 06:17:34 -0400 (Wed, 18 Apr 2007)
New Revision: 98
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/templates/resources-config.vm
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java
Log:
Framework: resource builder sets renderer when configuring
Generator: class resources support added
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java 2007-04-18
09:56:56 UTC (rev 97)
+++
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java 2007-04-18
10:17:34 UTC (rev 98)
@@ -64,7 +64,14 @@
ResourceConfigGeneratorBean resourceConfig = new ResourceConfigGeneratorBean();
String name = resourceTemplateElement.getName();
resourceConfig.setKey(name);
- resourceConfig.setPath(resolvePath(name, packageName));
+
+ String resolvedPath = resolveResourcePath(name, packageName);
+ if (resolvedPath != null) {
+ resourceConfig.setPath(resolvedPath);
+ } else {
+ //couldn't resolve, treat as class name
+ resourceConfig.setClassName(name);
+ }
resources.add(resourceConfig);
}
@@ -75,27 +82,32 @@
}
}
- private String resolvePath(String name, String packageName) {
- String resolvedName = name;
- if (!name.startsWith("/") && name.contains("/")) {
- //need to resolve
- StringBuffer normalizedName = new StringBuffer();
- if (!packageName.startsWith("/")) {
- normalizedName.append('/');
- }
+ private String resolveResourcePath(String name, String packageName) {
+ if (name.contains("/")) {
+ String resolvedName = name;
- normalizedName.append(packageName.replace('.', '/'));
-
- if (!packageName.endsWith("/")) {
- normalizedName.append('/');
+ if (!name.startsWith("/")) {
+ //need to resolve
+ StringBuffer normalizedName = new StringBuffer();
+ if (!packageName.startsWith("/")) {
+ normalizedName.append('/');
+ }
+
+ normalizedName.append(packageName.replace('.', '/'));
+
+ if (!packageName.endsWith("/")) {
+ normalizedName.append('/');
+ }
+
+ normalizedName.append(name);
+
+ resolvedName = normalizedName.toString();
}
- normalizedName.append(name);
-
- resolvedName = normalizedName.toString();
+ return resolvedName;
}
- return resolvedName;
+ return null;
}
private void addResources(List<ResourceConfigGeneratorBean> resources,
RendererBean renderer, BuilderConfig builderConfig) throws CompilationException,
IOException, ClassNotFoundException {
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/resources-config.vm
===================================================================
---
trunk/cdk/generator/src/main/resources/META-INF/templates/resources-config.vm 2007-04-18
09:56:56 UTC (rev 97)
+++
trunk/cdk/generator/src/main/resources/META-INF/templates/resources-config.vm 2007-04-18
10:17:34 UTC (rev 98)
@@ -3,13 +3,10 @@
#foreach( $resource in ${resources})
<resource class="${resource.className}">
- <!-- renderer class="${resource.renderer.className}">
- <content-type>${resource.renderer.contentType}</content-type>
- </renderer -->
<name>${resource.key}</name>
+ #if(! ${resource.className})
<path>${resource.path}</path>
- <!-- content-type>${resource.contentType}</content-type -->
-
+ #end
</resource>
#end
Modified:
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java 2007-04-18
09:56:56 UTC (rev 97)
+++
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java 2007-04-18
10:17:34 UTC (rev 98)
@@ -42,8 +42,6 @@
import javax.faces.context.FacesContext;
import javax.imageio.ImageIO;
import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
import org.ajax4jsf.framework.util.base64.Codec;
import org.ajax4jsf.framework.util.config.WebXml;
@@ -375,6 +373,10 @@
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) {
@@ -423,7 +425,7 @@
Messages.STATIC_RESOURCE_NOT_FOUND_ERROR, path));
}
- private void setRenderer(InternetResourceBase res, String path)
+ private void setRenderer(InternetResource res, String path)
throws FacesException {
int lastPoint = path.lastIndexOf('.');
if (lastPoint > 0) {
Show replies by date