Author: konstantin.mishin
Date: 2009-08-24 14:40:44 -0400 (Mon, 24 Aug 2009)
New Revision: 15288
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
Log:
NPE when call responseWriter.writeText has been fixed
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java 2009-08-24
17:38:53 UTC (rev 15287)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/BaseTemplateConsumer.java 2009-08-24
18:40:44 UTC (rev 15288)
@@ -280,7 +280,7 @@
}
protected MethodBodyStatement createWriteText(Characters characters) {
- return new MethodBodyStatement(MessageFormat.format("responseWriter.writeText({0},
component, null);",
+ return new
MethodBodyStatement(MessageFormat.format("responseWriter.writeText(convertToString({0}),
component, null);",
compileEl(characters.getData().trim())));
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java 2009-08-24
17:38:53 UTC (rev 15287)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateBodyConsumer.java 2009-08-24
18:40:44 UTC (rev 15288)
@@ -139,6 +139,13 @@
methodBody.addToBody(createGetComponentClassMethod(componentClassName));
getComponentClassMethod.setMethodBody(methodBody);
javaClass.addMethod(getComponentClassMethod);
+
+ JavaMethod convertToStringMethod = new JavaMethod("convertToString",
String.class, new Argument("obj", Object.class));
+ convertToStringMethod.getModifiers().add(JavaModifier.PRIVATE);
+ MethodBody convertToStringBody = new MethodBody(convertToStringMethod);
+ convertToStringBody.addToBody(new MethodBodyStatement("return obj == null ?
\"\" : obj.toString();"));
+ convertToStringMethod.setMethodBody(convertToStringBody);
+ javaClass.addMethod(convertToStringMethod);
}
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-08-24
17:38:53 UTC (rev 15287)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2009-08-24
18:40:44 UTC (rev 15288)
@@ -26,7 +26,6 @@
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@@ -85,7 +84,7 @@
return onClick.toString();
}
- public String getStringValue(UIComponent component) {
+/* public String getStringValue(UIComponent component) {
Object value = getValue(component);
return convertToString(value);
}
@@ -105,11 +104,11 @@
protected String convertToString(long b ) {
return b!=Long.MIN_VALUE?String.valueOf(b):"";
}
-/*
+
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException {
renderChildren(context, component);
- } */
+ }
public Object getValue(UIComponent component) {
if (component instanceof ValueHolder) {
@@ -118,7 +117,7 @@
return component.getAttributes().get("value");
}
- /*
+
public String getType(UIComponent uiComponent) {
String type;
if (uiComponent instanceof HtmlCommandButton) {
Modified:
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
===================================================================
---
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2009-08-24
17:38:53 UTC (rev 15287)
+++
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2009-08-24
18:40:44 UTC (rev 15288)
@@ -15,7 +15,7 @@
href="#"
class="#{component.attributes['styleClass']}"
- #{this.getStringValue(component)}
+ #{component.attributes['value']}
<cdk:body>
<cdk:call expression="renderChildren(context,component);" />
</cdk:body>