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

  • free blonde bukkake movies
  • free mature women pissing videos
  • tiffany amber theisen sex video
  • xtube eating pussy
  • asian native sex
  • Hot girls shorts
  • online celebreity sex videos
  • white leatherette black velveteen display
  • Black boy sex video
  • most popular stars black
  • girl getting hardcore fingered
  • megarotic deep lesbian ass licking
  • kinky erotic bondage forced sex
  • pussy girls kissing
  • retro sex tube celeste anal
  • Rough sex pictures
  • Cum face sex
  • ebony facial movie streaming
  • nude bikini girls video
  • nice ass of girls
  • Female masturbation
  • teen bikini nonnude
  • cowgirl amateur video
  • older mature sex movies free
  • Big boobs pop out
  • sturgis sexy biker babes
  • young pussy play
  • black women with sexy ligerie
  • Pretty girl dresses
  • black bad girlz
  • pictures of sarah abrahams wife
  • trisha actress sex pictures
  • you tube oral sex
  • young naked blonds
  • free video web site
  • completely naked pics of male celebrities
  • young chubby girls pics
  • petite black ass
  • group sex slave art
  • shaved pussy squirts
  • close up teen pussy fisting
  • crazy girls videos
  • erotic hypnosis videos free
  • asian massage parlors hien video cameras
  • hardcore nun
  • anal girls streaming
  • topless ohio state girls
  • subway grope sex video
  • amatuer fuck my wife tube
  • kate beckensale tits in the movies
  • free teen arab videos
  • no licks pussy
  • silay city philippines pussy
  • free teen gangbang anal video
  • celeberties nude pics and sex tapes
  • girls showing pussy in public
  • young teen spanking
  • pussy wet teen
  • Real teen cuties
  • tiffany teen nude pics
  • medgit anal
  • lactating sex pictures
  • ethnic arabian
  • free mature interracial anal vidoes
  • scandanavian girl videos
  • black booty tranny
  • Sexy army girl fancy dress
  • free hardcore toon fucking movies
  • free sex movie orgasm
  • hairy mature brunette videos
  • gy style blonde vids
  • lesbian girls big breast sucking
  • free to make me orgasm
  • lick my anal
  • free shemale movies and gallery
  • petite sirah macaroni and cheese
  • beauties having sex
  • girl from atlanta sex picks
  • free pics of female orgasm
  • tiger woods girls frend pics
  • Naked teen photo
  • adults couples live cams
  • free group sex videos
  • some good young
  • Indian ass movies
  • teen crystal fuck
  • pictures of vannessa hudgens naked
  • pics young grils in thongs
  • teen homemade sex movie
  • small dick hubby fuck
  • amateur bodybuilder pics
  • Erotic sex poems
  • hot female stripper videos naked
  • islam naked girl
  • murga punishment to girls pictures
  • Teen sex pic
  • Amateur home sex pics
  • asian gets scared o dick
  • Teenage mutual masturbation
  • Asian lesbian sex pics
  • free nature sex movies
  • asian met models galleries
  • free movies fulll length
  • bigphat black ass tube
  • Beautiful nude teens
  • ruined orgasm pictures
  • black sister
  • anal sex hiv
  • pretty petite milf fucking
  • britney spears fuck this
  • Sex video sharing
  • free hot sexy vids
  • free amateur deepthroat vids
  • xxx naked eskimos
  • horny ebony schoolgirls
  • black sex for women
  • Younger nude teens
  • messy lesbian sex videos
  • promise black star
  • very very very young nude girls
  • free interracial oral sex
  • good girls pussy
  • dry hump sex free video
  • strawberry blonde hairy teen mastubate movie
  • amateur teen hardcore sex
  • pussy sex pics free
  • anal fuck until cum video
  • stepmom and stepson sex videos
  • classic teen sex vids
  • Indian sex world
  • mature jizz handjob vids
  • huge sexy tits and ass
  • amateur home videos pantyhose
  • free videos boobs
  • big booty ebony facesitting streaming videos
  • young emo naked videos
  • mature women seducing young studs
  • teen girl want to fuck tiny
  • free sex photos free sex pictures
  • mom please fuck me movies
  • video wife fuck
  • nursing girls
  • teen asian boys wanking
  • fuck teen ass high hd
  • sex at sea pics
  • best orgasm in the world
  • black cocks her pussy
  • free star hardcore sex
  • free pics double ass penetration
  • Girl looking for threesome
  • hot busty amateur girls
  • breastfeeding babes pictures
  • indian girls dick suck
  • blonde cheerleaders having sex
  • nude woman pussy babes
  • latino fan ciub movie
  • free amater video
  • girls first time lesbian
  • sex amateur videos
  • thong haiy pussy
  • rodox old young movies
  • free cum on ass pics
  • Indian ladies for sex
  • old pussy with dick
  • black gang fuck wife
  • girl upskirt video
  • celebrity lesbian sex video
  • bib cock young girl
  • stocking movie sex
  • free black women strapon fuck guys
  • erotic black stories
  • jaimy from sweetnaturalgirl naked pussy
  • free videos black on white
  • pictures of women with no nipples
  • baseball bat anal video
  • amateur party girls nude
  • blonde vaginal pics
  • gallerys girl next door pics
  • oral sex jell
  • black family reunion pictures
  • blonde teen chick fuck pussy slutload
  • watch movies online for free
  • petite marigold seeds
  • boysboysboys sex pics vids
  • asian hairy video
  • busty mature movie free
  • amatuer sex videos dancing bear
  • free amateur nude girl
  • teen pussy gp
  • jonathan ross intro petite
  • free sex stories the preachers wife
  • best black ass list
  • oral allie sin
  • nikki fritz videos
  • sex video on cell phine
  • ukraine women sex video
  • real black hookers having sex
  • piss bikini video
  • karla luna boobs video
  • anal sex positions video
  • first time anal virgen teens
  • tubby girls xxx
  • couples submitted videos
  • large black dicks fucking asian women
  • sweet babes sex
  • pics of teen girls in underwear
  • up young girls skirts
  • mexican teen girls
  • ebony big tit cum in pussy
  • only teen blowjobs facial pictures
  • couples sex therapy retreats
  • abused asian street girl
  • pregnant young asian
  • sex video emo girl
  • gilmore girls season video set
  • Man inserts his head into vagina
  • Full lesbian sex video
  • the movie celebrity sex
  • free sex portal ameture teens
  • group fuck of black aunty
  • black husbands white wives
  • girl gives motorcyclist handjob
  • nude girls with huge boobs
  • old black women with saggy boobs
  • old erotic movies free watch online
  • teen cumshots amai liu
  • neil young movie greendale on tv
  • young girl slut
  • free sreaming amateur
  • lisa kudrow naked pics
  • hot sexy blond girls
  • mod le amateur sexy
  • naked espn video
  • big black ass sistas preview free
  • amatuer young girl model pics
  • young naked sluty babes
  • asian fantasy video
  • lovely nude babes videos
  • Emo girls fucked
  • spread your pussy photo rate
  • alexander angelna jolie sex video
  • free lesbian orgasm squirting videos
  • homemade anal movie galleries
  • anal sex complications
  • sex with s free videos
  • black ebony mama
  • video of my wife
  • Big breasted sluts
  • asian teens free galleries
  • videosz anal mpeg free
  • photo gratuite asian
  • Beastiality sex pictures
  • Sexy nude girls pics
  • Teens at nude beach
  • prom dress video
  • hardcore and suffoion
  • sex group public party
  • amateur girl fridays jessica
  • sex swingers in gearhart oregon
  • husbands spanking their wives wife spanking
  • amateur cheating video
  • black lesbians in tampa florida
  • home video
  • free erotic videos for women
  • sexy nude black ts males
  • xxx threesome video
  • big blakc dick
  • free bubble butt pictures