JSF

This page (revision-8) was last changed on 19-Sep-2018 13:22 by Dieter Käppel

This page was created on 22-Oct-2010 13:36 by Dieter Käppel

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
8 19-Sep-2018 13:22 8 KB Dieter Käppel to previous
7 19-Sep-2018 13:22 8 KB Dieter Käppel to previous | to last
6 19-Sep-2018 13:21 8 KB Dieter Käppel to previous | to last
5 09-Jan-2014 11:03 8 KB Dieter Käppel to previous | to last
4 04-Nov-2010 15:47 6 KB Dieter Käppel to previous | to last
3 03-Nov-2010 14:20 4 KB Dieter Käppel to previous | to last
2 29-Oct-2010 17:16 2 KB Dieter Käppel to previous | to last
1 22-Oct-2010 13:36 2 KB Dieter Käppel to last

Page References

Incoming links Outgoing links
JSF

Version management

Difference between version and

At line 1 changed one line
!!!Parameterisierter Validator Tag
!Parameterisierter Validator Tag
At line 108 changed one line
!!!ViewHandler
!ViewHandler
At line 161 removed 168 lines
!!!Einfache Komponente
Component:
{{{
public class OutputStream extends UIComponentBase {
private String url;
@Override
public String getFamily() {
return "javax.faces.Output";
}
public String getUrl() {
ValueExpression expression = getValueExpression("url");
if (expression != null)
return (String)expression.getValue(getFacesContext().getELContext());
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
}}}
Renderer:
{{{
public class OutputStreamRenderer extends Renderer {
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
OutputStream outputStream = (OutputStream)component;
ResponseWriter writer = context.getResponseWriter();
URL url = new URL(outputStream.getUrl());
InputStream inputStream = null;
try {
inputStream = url.openStream();
IOUtils.copy(inputStream, writer);
} finally {
if (inputStream != null)
inputStream.close();
}
}
}
}}}
faces-config.xml:
{{{
<component>
<component-type>intersult.OutputStream</component-type>
<component-class>com.intersult.OutputStream</component-class>
</component>
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>intersult.OutputStream</renderer-type>
<renderer-class>com.intersult.OutputStreamRenderer</renderer-class>
</renderer>
</render-kit>
}}}
intersult.taglib.xml:
{{{
<tag>
<tag-name>outputStream</tag-name>
<component>
<component-type>intersult.OutputStream</component-type>
<renderer-type>intersult.OutputStream</renderer-type>
</component>
</tag>
}}}
!!!ClearValuesActionListener
ClearValuesActionListenerHandler:
{{{
public class ClearValuesActionListenerHandler extends TagHandler {
public static class ClearValuesActionListener implements ActionListener, Serializable {
private ValueExpression forValue;
public ClearValuesActionListener() {
}
public ClearValuesActionListener(ValueExpression forValue) {
this.forValue = forValue;
}
public ValueExpression getFor() {
return forValue;
}
public void setFor(ValueExpression forValue) {
this.forValue = forValue;
}
@Override
public void processAction(ActionEvent actionEvent) {
String id = (String)forValue.getValue(FacesContext.getCurrentInstance().getELContext());
UIComponent component =
RendererUtils.getInstance().findComponentFor(actionEvent.getComponent(), id);
clearValues(component);
}
private void clearValues(UIComponent component) {
if (component instanceof UIInput) {
UIInput input = (UIInput)component;
input.setSubmittedValue(null);
}
for (UIComponent child : component.getChildren()) {
clearValues(child);
}
}
}
private TagAttribute forAttribute;
public ClearValuesActionListenerHandler(TagConfig config) {
super(config);
forAttribute = getRequiredAttribute("for");
}
@Override
public void apply(FaceletContext context, UIComponent parent) {
if (!(parent instanceof ActionSource))
throw new TagException(tag, "Parent component must be action source");
ActionSource actionSource = (ActionSource)parent;
ValueExpression forValue = forAttribute.getValueExpression(context, String.class);
actionSource.addActionListener(new ClearValuesActionListener(forValue));
}
}
}}}
Taglib:
{{{
<tag>
<tag-name>clearValuesActionListener</tag-name>
<handler-class>com.intersult.ClearValuesActionListenerHandler</handler-class>
</tag>
}}}
!!!RES_NOT_FOUND finden
Wenn im HTML-Code Stylesheets, Javascripts oder andere Resourcen als
{{{
<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND"/>
}}}
gerendert werden, ist die Quelle des Fehlers oft schwer zu finden. Dazu kann ein Breakpoint in
{{{ com.sun.faces.renderkit.html_basic.HtmlResponseWriter.writeURIAttributeIgnoringPassThroughAttributes(String, Object, String, boolean)
}}}
gesetzt werden mit der Condition
{{{
"RES_NOT_FOUND".equals(value)
}}}
und dann entsprechend im Stack zur Ursache zurückgegangen werden, etwa zu
{{{
com.sun.faces.renderkit.html_basic.ScriptStyleBaseRenderer.encodeEnd(FacesContext, UIComponent) line: 249
}}}
dort findet man
{{{
Resource resource = resourceHandler.createResource(name, library);
}}}
den Name und Library der angeforderten Resources.