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

  • lesbian anal tongue sex
  • sexy ebony girls girls
  • african natives having sex videos
  • young natural girl free nude outside
  • skinny asian girl videos
  • sex large nipples
  • oriental men white shemale sex
  • free sex video stream forced
  • young sext naked bebes
  • teen lesbian threesome on redtube
  • sexiest japanese girls
  • chicks puking on dicks
  • amateur interracial vids
  • streaming girl sex porn
  • Teen latina sexy
  • anal vs oral
  • chubby young naked
  • hot naked nude girls
  • Mexican pussy photos
  • daily blowjob galleries
  • free pussy swingers northeast ohio xxx
  • fingering porn videos
  • sexy college asian
  • Nude tamil actress pictures
  • hot and sexy naked girls
  • Hot lesbian porn video
  • xxxxrated hardcore adult pics
  • girl gymnsatics ass
  • son and mothers tight pussy
  • shemale fucks shemales ass video
  • naked military pics female
  • free hairy pussy vidoes
  • skinny ass picture
  • teen girls and fatique
  • porn hub black pussy
  • free sex videos of guys masterbating
  • black mature fucks white young
  • fat women sex video trailers
  • sexe gratuit black
  • free mature drunk sex pictures
  • simpy bikini pics
  • oregon missing teenage girl
  • moms milf granny anal free video
  • amateur teen fuck machine
  • teen girls pictures free
  • Juicy ass fuck
  • free black mature mamas
  • party hardcore volume
  • amateur wife showing hairy pussy
  • free videos of doctor patient sex
  • hot sexy blonde sucks and fucks
  • Can you get chlamydia from oral sex
  • young and inocent sex
  • girls in bikini pale ass vid
  • Big phat ass
  • nude video porn large tits
  • Cum in mouth shots
  • young teens girl naked
  • galleries of hardcore lesbians thumbs
  • teens sex and movie
  • Ebony teens galleries
  • free amateur porn video gallery
  • farm girls suck s cock
  • japanese beauty secrets
  • vanessa blue blowjob video free
  • wild girls teen sluts thumbs
  • hd suck pictures
  • free old teach young lesbians
  • Nude pics of brittney spears
  • sex teachers nude videos
  • little girl nude porn play videos
  • erotic art gallery free
  • couples seduce teens tori
  • free celebrity cartoon porn videos
  • hot black girl gets fucked hard
  • tera patrick group sex
  • mother blowjob sex pictures
  • big teen butt porn
  • Perfect boobs pictures
  • mega teen babes
  • hot latina pussy getting fucked hard
  • erotic pussy story
  • free anal cum shot suprise videos
  • free videos of ashlynn brooke anal
  • vintage anal hardcore tube free
  • videos sexo amateur
  • girl gets fucked hard at party
  • slow blowjob teens
  • spank pussy or tits mmy pussy
  • young free teen
  • girlfriend lets boyfriend touch her boobs
  • Thai nude girls photos
  • pussy eating nikki charm
  • littl naked girl
  • japan chikan video
  • stories sexy erotic exhibitionism
  • asian sex galleries free videos
  • wives sex pictures
  • animated girls pictures
  • men cumming inside girls video
  • shemale self galleries
  • sexest naked girl sucking cock
  • free naked asian video
  • young looking teen girl porn pix
  • milky boy movie porn
  • sexy emo scene girls
  • Black homemade sex tapes
  • cream pie wife pictures
  • erotica lesbian sex
  • hotest asian girl porn star
  • salma hayek lookalike shower fuck video
  • free interracial sex taboo
  • massive ass milks dick
  • best lesbian hardcore forum
  • japan beautiful butt
  • ass stripper video
  • fat grannie pussy xxx
  • xxx girls showering videos
  • teens anal fuck amateur free videos
  • free masturbation orgasm video
  • Teen bra panty
  • free videos of naked asian woman
  • should i lick my sisters pussy
  • tiny tits pussy videos
  • suck my young cock free vidios
  • free young babes porn pics
  • licking pizza pussy
  • fat cocks big tits pictures
  • black shy teens
  • sexy firm teen body video
  • the hills girls hot pics
  • black bootylicious porn movies
  • mature black naked pics
  • Pinay sex scandals videos
  • Blonde natural pussy
  • wife gets playful pics
  • self pics young girls
  • fuck wife gang bang
  • digital sex hardcore music
  • hardcore xxx movie guys
  • porn best blowjob
  • lesbian fingering public
  • young firm big nipple tits
  • tori black how to fuck
  • shemale tranny party new york
  • black bbw with big fatty ass
  • Vagina vagina i want to have sex with your vagina
  • teens girls facesitting r
  • very young girl fuck movies
  • bikini hut the movie
  • Real sex doll video
  • free colassic porn movies online
  • extreem sex videos
  • Crazy sex photo
  • free mature hardcore orgy sex movies
  • Sweet nude models
  • anal lick les
  • the great sex video series
  • sexual for married couples
  • sexy chubby little girls
  • naughty young girl
  • mature housewie fucks young boy
  • real cp kiie porn pics
  • mature home anal photos free
  • muslim sex movies
  • Nude voyeur photos
  • younger girl galleries
  • teen blond pussy fuck
  • blackshear s beauty and wellness spa
  • swinger couples tube video
  • white and black babes kissing
  • videos of big tits
  • mature in sexy skirts
  • Nude lesbian teens
  • sexy hot blondes cumshots oral
  • hot sexy naked girls masterbating
  • pussy orgasm squirt teen
  • pictures of naked models
  • voyeur wife picture forum
  • virgins nude pics
  • naked pics of bridget marquardt
  • britney spears music video ass
  • ex wife ljc videos
  • ebony girls video media player free
  • sweet young pussy fucking
  • girls talking dirty onvideo
  • Sweet ass movies
  • mature woman ravished by young
  • naked young little japanese girls
  • lesbian sex video compition
  • convince girls to try anal
  • tanned wife threesome
  • asian forum teen
  • free vids mature in panties fucking
  • Indian sexy pussy
  • exercise dvd petite women
  • free la blue girl hentai videos
  • amateur ass lesbian
  • kinky wife black
  • ugly chicks hving sex videos
  • teen playing with ong with pussy
  • reality mature vids
  • large teen sex galleries
  • karla spice nude tits galleries
  • Pakistan lesbian girls
  • shemale movie powered by phpbb
  • free gallerys young and old sex
  • Lesbians lick pussy
  • true amateur outdoor beach sex video
  • solo girls sex galleries
  • free outdoor sex video
  • vids of tits
  • teenage with big black cock
  • black hommade porn
  • blonde girl gangbang
  • mature women sex amatuer free videos
  • black cock loveing prego pics
  • free real teen videos
  • Sex movie fucking
  • celbrity sex scandal videos
  • looking at grandmas pussy
  • sex with fat girls vids
  • video podcast sex free
  • asian teen forums
  • tiny little nude girl pics
  • smooth young teen legal
  • free teen webcam online
  • how to finger a girl teen
  • chicks withs dicks
  • Sex in north india
  • fat black girls blackdicks
  • perfect teen porn movies
  • pretty blonde girls bikini
  • big black in xxx
  • absolutely free hardcore movies
  • fattest girl sex pic galleries
  • Jiggly ass stocking anal threesome
  • free teen sex movies streaming
  • amateur teen lesbians on webcam
  • videos anal big tits
  • hot anal blonde
  • free mmf bi sexual porn
  • hot woman hot sex ffm
  • hardcor anal porn
  • free porn of girls and grampa
  • moms oral sex
  • boys lick young nude
  • sexy indian house wife
  • Black lesbians porn movies
  • nude blonde girls showing pubic hair
  • bizarre anal insertions petite girls video
  • porn tube black cumshots
  • pictures of mature women wearing bikinis
  • free to watch black sex videos
  • sucking lactating lesbian tits
  • moms i like to fuck pornstars
  • girl loses bet naked
  • reality galleries mature
  • free pics spreading ass
  • tight little girls fucking vids
  • free mature home made videos
  • blonde hardcore porn
  • free pics big tits and didcks
  • sex lesbian oral sex
  • see as mature movies
  • pornography with couples
  • sexy dress of girl
  • girl with a butt
  • asian bikini girl
  • japanese models sex photo
  • blonde hot czech teacher video
  • black sexi chicken heads
  • mature moms first time anal
  • galleries of teens in booty shorts
  • forcing wife to suck friends cock
  • free hardcore xxx pictures
  • amateur wife post big tits
  • personals naked girls
  • nice hot mature pussy naked babes
  • young girl and uncle nude pics
  • s europeon sex movies
  • totally nude girls videos
  • nasty naked goth girls
  • arab wife threesome
  • sex and the city movie mb
  • sex with unconscious girl porn
  • totally free asian sex videos
  • romero black and white movie
  • wifesucks black cocks
  • tiny petite girls youngest sex cp
  • free voluptuos naked girls
  • xanga pussy porn
  • whirlpool jet orgasm videos
  • petite teen black pussy
  • Black lesbian asslicking
  • free porn tits video
  • brazilian women sex videos
  • free mature ebony over videos
  • blonde sluts gallery
  • kinky fuck pussy double
  • blonde tgirl sexy
  • amatuer pussy closeup
  • pussy lords of acid
  • german goo girls free vids
  • asian facial movie
  • lingerie petite plus size womens
  • xxx free fuck s videos
  • beutifull teen girls
  • lesbians sucking each others pussy pics
  • free wild wife sex
  • Tiny tit teens
  • porn mother black lesbian
  • pics of missionary style sex
  • Wild teen movies
  • white guys black girls anal
  • Full hd sex movies
  • xxx and black women and
  • sexy fat girl cariures
  • Europe sex videos
  • showering lesbian blonde on blonde
  • old men young girls anal
  • show girls sex porn videos
  • blonde pornstar vieos
  • Indonesia sexy girl
  • wife best friend video
  • hardcore fantasy sex comics
  • mature white sex with black
  • blacking my wife
  • emily proctor topless video
  • free porn oldyoung tube
  • Very naked girl
  • teen discrace blowjob videos
  • milfs on young girl teens
  • tabitha stevens anal video
  • mile east free sex videos
  • d porn cartoon video
  • free movie post cumshots creampies
  • sexy solo asian teens
  • Big ass latino
  • portal youngest nude girls
  • sex video from blue film
  • Jennifer aniston naked videos
  • milf big lips ass pictures
  • Exploited black teen videos
  • latvian teen schoolgirl jpg
  • tight teen pussy pink
  • free amateur porn female audition
  • pornstar pics and movies
  • brown haired girl swimsuit pictures
  • free homade amateur sex movies
  • itzone young sex
  • hot girl getting pussy licked
  • teen tight wet shaved pussy
  • big latina anal sex
  • and boy sex video
  • free lesbian sex only
  • Big black booty sex videos
  • forbiden xxx sex movies
  • cute girl porn video
  • revealing bikini sex party
  • Big brother nude video
  • free nakd sexy girls
  • legal sexy fuck videos
  • asian pornstars that are dead
  • teen girls fisting pussy tube
  • teens wild girls
  • amatuar wife videos
  • Muscular girl sex
  • girl playing with pussy
  • horny busty pussy fuck
  • Big boobs expansion
  • Emo teens sex
  • health benefits of anal sex
  • free moms teaching teens sex pics
  • bikini string pics
  • xxx teennage sex videos
  • free amateur college party
  • old fucking young vids
  • free porn small blonde flash
  • drunk wife in party
  • free pictures pussy doctor exam
  • cute girl eats her first pussy
  • salt rock petite province
  • Teen pussy shots
  • local lesbian teens
  • aisan bizarre sex pics
  • free bikini model galleries
  • Girls fucking young
  • huge lesbian sex orgy video
  • college girls milking my dick
  • kate vibe in pussy
  • solo tits movies
  • free demi lovato porn pics
  • wife gets fucked at oktoberfest party
  • black girl fucking in club
  • real young girls fucked video
  • guys sucking shemale dick
  • free porn bbw lesbian orgy
  • petite mal seizures and ren
  • asian orn pics