Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c01/h14/mnt/37629/domains/blog.evolutionarydawn.com/html/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c01/h14/mnt/37629/domains/blog.evolutionarydawn.com/html/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c01/h14/mnt/37629/domains/blog.evolutionarydawn.com/html/wp-includes/theme.php on line 540
Evolutionary Dawn » Custom JSF Component 1.2

Evolutionary Dawn

June 11, 2009

Custom JSF Component 1.2

Filed under: Uncategorized — admin @ 12:25 pm

Since I had a hard time finding a complete solution anywhere online I decided that I would post a simple how-to for a JSF Custom component.

The problem that this component seeks to address is that the <f:verbatim> tag does not work properly in a <ui:repeat> tag.

This presented a issue to me because I have RAW HTML stored in my data model to be used in my simple blog application.

1. The most confusing thing about JSF Custom components.  YOU NEED 3 SEPERATE CLASSES TO IMPLEMENT A CUSTOM COMPONENT.

Alot of other tutorials will teach you there is a method in which you can use only two classes to accomplish the task, although this is true the most straight forward approach is to use 3 classes to implement your component.

The are as follows:

  1.  The component class (For this tutorial: HTMLVerbatimComponent) This class is technically where the “DATA” resisdes
  2. The tag class (For this tutorial: HTMLVerbatimTag) This class is the ADAPTER piece between the “JSF Page” and the DATA Model “Your component”
  3. The renderer class (For this tutorial: HTMLVerbatimRenderer) This class is response for the actual rendering of the HTML or OUTPUT.

The component class:

package com.mdb.web.jsf.component;
 
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.el.ValueExpression;
 
public class HTMLVerbatimComponent extends UIComponentBase {
 
    public HTMLVerbatimComponent() { }
 
    //Properties you want exposed as tag values must be exposed using getters/setters
    private String value;
    public String getValue() {
        if(value != null)
            return value;
        //If the value has not already been set interpret the Expression language and get resulting object
        Object value = this.getValueExpressionValue("value");
        return value != null ? (String)value : null;
    }
 
    public void setValue(String value) { this.value = value;}
 
    //Honestly I am not sure what this method does besides link the component to the config files
    public String getFamily() {
        return "com.mdb.web.jsf.component.HTMLVerbatim";
    }
 
    //Method allows component state to be stored
    @Override
    public Object saveState(FacesContext context) {
        return new Object[] { super.saveState(context), value};
    }
 
    //Method allows component state to be restored
    @Override
    public void restoreState(FacesContext context, Object object) {
        Object state[] = (Object[]) object;
        super.restoreState(context, state[0]);
        value = (String)state[1];
    }
 
    //Helper method to simplify getters/setters
    //This helps the JSF Component use Expression Language
    private Object getValueExpressionValue(String name) {
        ValueExpression ve = super.getValueExpression(name);
        return ve.getValue(FacesContext.getCurrentInstance().getELContext());
    }
}

The tag class:

package com.mdb.web.jsf.component;
 
import javax.faces.webapp.UIComponentELTag;
import javax.faces.component.UIComponent;
import javax.el.ValueExpression;
public class HTMLVerbatimTag extends UIComponentELTag {
    //Temporary holder property hence if I put
    //&lt;tag:htmlVerbatim value="#{SomeBackingBean.htmlText}"/&gt;
    //information is stored in this object until the data is pushed into the component in setProperties method
    private ValueExpression value = null;
    public HTMLVerbatimTag() {}
    public ValueExpression getValue() { return this.value;}
    public void setValue(ValueExpression value) { this.value = value;}
 
    //This is where the action happens
    //Data is taken from the tag on the JSF Page and placed into the Component
    @Override
    protected void setProperties(UIComponent component) {
        super.setProperties(component);
        HTMLVerbatimComponent verbatimComponent = (HTMLVerbatimComponent)component;
        if(value != null) {
            verbatimComponent.setValueExpression("value", value);
        }
    }
 
    //Method links this tag object to the component in config files
    public String getComponentType() { return "com.mdb.web.jsf.component.HTMLVerbatim"; }
 
    //Method links this tag object to the renderer in config files
    public String getRendererType() { return "com.mdb.web.jsf.component.HTMLVerbatim";}
 
}

The renderer class:

package com.mdb.web.jsf.component;import javax.faces.render.Renderer;
 
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import java.io.IOException;
 
public class HTMLVerbatimRenderer extends Renderer {public HTMLVerbatimRenderer() {}
 
    //Render your HTML HERE
    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        HTMLVerbatimComponent verbatimComponent = (HTMLVerbatimComponent)component;
        ResponseWriter writer = context.getResponseWriter();
        writer.write(verbatimComponent.getValue());
        writer.flush();
    }
 
}

Now you must make some changes to your configuration files and I make the big assumption you are using Facelets.

Create a file in your WEB-INF directory called: custom.taglib.xml

Add the following content (Edit accordingly for your own component and domain):

 
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"&gt;
 
<facelet-taglib>
    <namespace>http://mechdrives.com/web/jsf/component/tags</namespace>
    <tag>
        <tag-name>htmlVerbatim</tag-name>
        <component>
            <component-type>com.mdb.web.jsf.component.HTMLVerbatim</component-type>
            <renderer-type>com.mdb.web.jsf.component.HTMLVerbatim</renderer-type>
        </component>
    </tag>
</facelet-taglib>

Edit your faces-config.xml and add the following content(Edit accordingly for your own component and domain):

 
<faces-config version="1.2">
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"&gt;
    <component>
        <component-type>com.mdb.web.jsf.component.HTMLVerbatim</component-type>
        <component-class>com.mdb.web.jsf.component.HTMLVerbatimComponent</component-class>
    </component>
    <render-kit>
        <renderer>
            <component-family>com.mdb.web.jsf.component.HTMLVerbatim</component-family>
            <renderer-type>com.mdb.web.jsf.component.HTMLVerbatim</renderer-type>
            <renderer-class>com.mdb.web.jsf.component.HTMLVerbatimRenderer</renderer-class>
        </renderer>
    </render-kit>
    <application>
        <locale-config>
            <default-locale>en</default-locale>
        </locale-config>
        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    </application>
</faces-config>

Edit your web.xml and add the following content:

    <context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/custom.taglib.xml;</param-value>
    </context-param>

Now you should be able to use your new component/tag simply by adding a namespace to your JSF Page as such:

 

then using the tag as such:

<custom:htmlverbatim value="#{SomeBackingBean.htmlText}">
</custom:htmlverbatim>

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress

  • sexy young teenie
  • fuck he girls movies
  • about first anal sex
  • alexis pussy gets ploughed
  • asian playmate stars
  • students study dick
  • amature teen home movies
  • the handover movie screenshots naked
  • Big boobs beauties
  • ebony teens white cock
  • gallery bikini candid
  • real interracial sex stories
  • girls rubbing g posts
  • young girl s
  • free fuck me hard video scream
  • Pussy licking and fingering
  • little pale white blonde galleries
  • homemade amateur lesbian
  • heather van deven school girl video
  • masterbating young girl
  • naked milf mini skirt fucking videos
  • lesbians interracial free video
  • sexy cheerleader girl
  • very young girls with s
  • streaming couples sex
  • Big asses ebony
  • thai anal video
  • stunning picture of brazilian girls
  • free softcore tube videos
  • girl eating cum out of ass
  • nice latin pussy pics
  • youngest boys hardcore movies
  • real movies with sex
  • babysitter pussy licked
  • naked girls from nazareth
  • mature couples and girls
  • hot teen sex ffm
  • hot young husbands xxx
  • free erotic pics of mature women
  • Voyer beach sex
  • japan pic rental cgi girl
  • close up anal pictures
  • fuck my wifes snatch
  • kelli macarthy movies
  • pictures of eary japan
  • candid teen oral
  • sex free ass tit
  • saudi girls sex video
  • amateur legal videos
  • free mature sex galore tube
  • erotic couples black white photos
  • free ebony shemales
  • peeping tom sex videos
  • teen babe erotic
  • lesbians suck cock
  • Ftv nude movies
  • women seducing young girl videos
  • pussy make up
  • layla kayleigh boobs videos
  • anime girl with boobs on head
  • girls eating cum out of ass
  • petite latina cameltoe
  • couger pussy pics
  • pics of young guys wearing speedos
  • exploted movies black
  • sex therapy free video
  • Extreme pussy sex
  • latino pussy licking
  • Porn arab teen
  • xxx erotic sex stories
  • free interracial movies mpegs jpegs
  • non nude young models gallery
  • sucking tits videos
  • sarah young movie flash
  • sexy girl parties
  • free amateur video and xxx
  • teen asian lesbians
  • topless teen girl friend
  • granny anal movies tubes
  • teen slut petite tube
  • girls with guns video
  • Free online videos of hot sexy teens getting fucked
  • sex hardcore free video
  • mature fuck
  • tonya harding bikini pictures
  • pussy shaved and open
  • young teenie girls nudists
  • how to gang bang girlfriend
  • big tit mature lesbian
  • asian teens riding dicks
  • old lesbian and young girl
  • Desi boobs sucking videos
  • kara monaco naked pics
  • horny anal sex
  • effective oral sex for women
  • black bubble butt creampies
  • marykate and ashley hardcore
  • ravens wood petite sirah
  • emma starr videos free
  • free asian orgy vids
  • erotic teen boys
  • ass pump video
  • stories wifes threesome
  • denmark young
  • japanese fuck video
  • giada de laurentiis bikini pictures
  • fuck stepmom
  • amateur video watch my japanese wife
  • make money topless pics
  • black sex and xxx
  • girls squirts sex video
  • young black s fucking
  • priya lesbian
  • big tit latina sex videos
  • sara evans bikini pics
  • young girls licking tits
  • small teen tit pics
  • old japanese men fuck girls
  • synergy girl naked
  • jackie guerrido pics naked nude bikini
  • rusian girls hot
  • erotic pictures from pompeii
  • free sex position videoes
  • high heel fuck videos
  • college girl bikini models
  • Different sex positions photos
  • mature party plump
  • nasty asian girls dancing
  • lesbian erotic reads
  • comedies for young teens
  • girls with nipples protruding through shirt
  • black hair busty teen
  • free wife homade videos free
  • fantasy fuck videos in vineyard
  • extreme teen pain video
  • school girl young love
  • teenagers nude ethnic girls
  • black smaal teen fucker videos only
  • disappears in pussy
  • Miss nevada nude pics
  • teen school girl asses short skirts
  • d blonde emanuel movie
  • hot black teen
  • young pussy milked
  • young naked solo masterbating school girls
  • anime pussy squirt
  • Sexy black girl getting fucked
  • erotic anal nude photos
  • sex with young teen stories
  • mfm sex pictures
  • bullwhipped girls pics
  • free hd black pussy
  • bbw facial movies
  • deep throat movie club
  • anal karma video
  • Peters cum shots
  • completely free sexy oral
  • christine nguyen hardcore
  • sho me your pussy
  • Lesbian sex full videos
  • blind date with sex videos
  • mature interracial riding cock
  • asian fighting girls
  • mexico young girl escorts pics
  • girl emo and punk hairstyle pictures
  • free teen glrl pictures
  • Girls kiss in the bed
  • fucking busty young teen videos
  • pics of girl wearing panties
  • Nhs teen pregnancy video
  • older amateur sex tapes
  • Lindsay lohan nude and topless pictures
  • big black cock gallery
  • long blonde girl
  • black girl orgies
  • brazilian beauties gallery
  • fuck my wifes sister hard
  • free high res pics huge tits
  • sex stories grandma young
  • crossdressing beauty pics
  • interracial comic
  • Two teens fuck
  • fucking hairy black pussy hub
  • extremely young teen xxx
  • teenage safe sex pictures
  • racheal handjob movies
  • Amateurs sex movie
  • sex of desi cute girls
  • sexy built teen boys
  • facial sex cams
  • hijab anal fuck
  • www housewife interracial sex
  • anal bleeching pictures
  • not willing to fuck facials
  • free theater sex video
  • free videos of virgins online
  • Nude british model
  • amateur videos pierre woodmore
  • peanutbutter lick video
  • Asin nude videos
  • lick the pussy
  • pictures of hentai pokemon
  • senior citizens oral sex jokes
  • sex boobs nude videos
  • free nude young girl pic
  • puberty girl boobs
  • slave sub cock suck forced movie
  • girls poo video
  • blonde cum in pussy
  • kim trall naked tits sex fucking
  • rimming sex pics
  • real orgasism oral sex
  • dumb girl sex videos
  • famous woman japanese naked
  • chubby teen girl fucks
  • Teen fucked in public
  • wife first lesbian free video
  • anal rough sex
  • christina ricci black snake moan pictures
  • best teen fuck movie
  • pictures free sex
  • forced lesbian attack video
  • girls changing at swimming baths video
  • korean teen lesbians
  • sucks black cocks interracial double facials
  • wife want talk about sex
  • amateur free video girl
  • boat pics boobs
  • Malay girl fucking
  • black man impregnates white girl
  • young couples holding hands
  • glamour nude video handjobs
  • girls videos oil wrestling
  • thong babes vids
  • fuck dick free boob
  • favorite cars teen girls
  • Hot bad girls
  • Pussy worship videos
  • free gyno videos
  • Teen pussy orgasm
  • shemale anal trailer
  • Sex video pic
  • real amateur gystyle videos
  • amateur videos of australian nude women
  • hardcore flash
  • home handjob videos
  • tiny petite teeny
  • husband whips wife vids
  • asian swimsuit pictures
  • Pics of brad pitt naked
  • free young black nude girls
  • sexy curves naked girls
  • Deep anal cumswap orgy
  • tiny breasted young teen blowjob torrent
  • japanese tit fuck
  • pussy circle fucking
  • dorm party fuck
  • oral sex demonstrated
  • free lesbian sappho sex pics
  • amatuer asian girl
  • lesbian boobs video preview
  • webcam teen videos
  • screaming video
  • girl dildo shaved pussy
  • mature russian panty model pics
  • public nudity videos videos
  • abused sex galleries
  • ebony ass video thread
  • sarah fuck dildo video
  • young european teens
  • teens sticking objects up there pussy
  • free of virgin pussy
  • ear nose throat anatomy pictures
  • xxx asian juciy fuck
  • free group sex stories wife swapping
  • old young girl
  • trans gender sex pics
  • young mums naked
  • senior naked pictures of women
  • sussex reality winnipeg
  • mature pussy models
  • Porn nude models
  • monster cock in anal girl
  • nude young sexe
  • moms and daughters fuck black guys
  • best amateur wife
  • soft core asian teen
  • topless girls and cars