Cannot get facelets custom components to work

Hi,
I'm switching to facelets but I fail to get my custom components to work. I hope any of you can help me point out what is going wrong. My component is built into a seperate jar file:
package be.xxx.web.tag;
import java.io.IOException;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class IfTag extends UIOutput {
     public IfTag() {
          super();
          Log log = LogFactory.getLog(IfTag.class);
          log.debug("THIS IS THE IFTAG FACELETS IMPLEMENTATION");
          setRendererType(null);
     public boolean getRendersChildren() {
          return true;
     @Override
     public void encodeBegin(FacesContext facesContext) throws IOException {
          // We're rendering a table row
          facesContext.getResponseWriter().startElement("span", null);
     @Override
     public void encodeChildren(FacesContext facesContext) throws IOException {
          ResponseWriter writer = facesContext.getResponseWriter();
          writer.append("This if the IF tag");
     @Override
     public void encodeEnd(FacesContext facesContext) throws IOException {
          facesContext.getResponseWriter().endElement("span");
     @Override
     public String getFamily() {
          return COMPONENT_TYPE;
}The taglib file in META-INF of the jar file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
     <namespace>http://www.xxx.be/jsf/mw</namespace>
     <tag>
          <tag-name>menu</tag-name>
          <component>
               <component-type>be.xxx.web.Menu</component-type>
          </component>
     </tag>
     <tag>
          <tag-name>if</tag-name>
          <component>
               <component-type>be.xxx.web.If</component-type>
          </component>
     </tag>
</facelet-taglib>Also in META-INF of the same jar, a faces-config.xml:
<?xml version="1.0" encoding="utf-8"?>
<faces-config 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"
              version="1.2">
  <component>
    <component-type>be.xxx.web.Menu</component-type>
    <component-class>be.xxx.web.tag.MenuTag</component-class>
  </component>
  <component>
    <component-type>be.xxx.web.If</component-type>
    <component-class>be.xxx.web.tag.IfTag</component-class>
  </component>
</faces-config>Finally, in the main project where the jar with above files is used, I try to call a custom tag:
<html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:mw="http://www.xxx.be/jsf/mw"
     xmlns:ui="http://java.sun.com/jsf/facelets">
<mw:if></mw:if>
</html>The result is that the if tag just writed out nothing, so "<mw:if></mw:if>" in the output just becomes "".
I haven't found a way to debug this either (as in: I don't think the java code is even executed), so any tips would be greatly appreciated!
Thanks

Looks like I posted the wrong class. Here is the problematic one:
public class MenuTag extends FacesBean implements BodyTag {
     private transient PageContext pc = null;
     private transient Tag parent = null;
     private transient BodyContent bodyContent;
     public void setPageContext(PageContext p) {
          pc = p;
     public void setParent(Tag t) {
          parent = t;
     public Tag getParent() {
          return parent;
     public int doStartTag() throws JspException {
          String url = null;
          try {
               WebSession ws = (WebSession) getBean("ws");
               if (ws.isLoggedIn()) {
                    // Get the value of the applicable menu rule
                    url = ws.getPolicy().getMenu();
                    if (url != null && !"".equals(url)) {
                         // Some logic to get correct file
                         String inputLine;
                         while ((inputLine = in.readLine()) != null)
                              pc.getOut().write(inputLine);
                         in.close();
                         // We printed the menu, so skip the default menu
                         // that is in this tag's body.
                         return SKIP_BODY;
               } else {
                    getLog().info("The user is not logged in, reverting to default menu.");
          } catch (FileNotFoundException ex) {
               getLog().warn("Menu file not found (" + url + "), reverting to default menu.");
          } catch (Exception ex) {
               throw new JspTagException("Error when applying the menu rule.", ex);
          return EVAL_BODY_BUFFERED;
     public int doEndTag() throws JspException {
          try {
               if (bodyContent != null) {
                    bodyContent.writeOut(bodyContent.getEnclosingWriter());
          } catch (IOException e) {
               throw new JspException("Error: " + e.getMessage());
          return EVAL_PAGE;
     public void release() {
          pc = null;
          parent = null;
     private String resolveServerUrl() {
          HttpServletRequest req = (HttpServletRequest) FacesContext
                    .getCurrentInstance().getExternalContext().getRequest();
          String url = req.getScheme() + "://" + req.getServerName();
          if (req.getServerPort() != 80) {
               url += ":" + req.getServerPort();
          return url;
     public void doInitBody() throws JspException {
     public void setBodyContent(BodyContent bc) {
          bodyContent = bc;
     public int doAfterBody() throws JspException {
          return 0;
}So, problem is that this is not working in facelets as a component, while it did in JSP's.
Can I get any hints what I am doing wrong here?
Thanks

Similar Messages

  • Cannot get Photoshop elements 11 to work. Get the message that my serial number is wrong. I do not think it is.

    Cannot get Photoshop elements 11 to work. Get the message that my serial number is wrong. I do not think it is.

    If you are certain it is correct, you will need to contact Adobe:
    Contact Customer Care
    You may need to use the chat option.
    If you want to check your serial number, sign in to your Adobe account if you registered it.

  • I cannot get my iPad 2 to work with VPN provider.

    I cannot get my iPad 2 to work with my VPN service provider.  Using OS 4.3.3.  iPad purchased in the USA.  Have heard there are issues with iPad 2 and VPN support.  Any suggestions?

    You can try this ... hold down on the sleep button and the power button at the same time for about 10 seconds until you see the Apple logo on the screen, release the buttons and see if the iPad restarts and you can use it.

  • I cannot get the numerical keys to work on my Mac pro any ideas?

    HI
    I am trying to return something bought on line and need to fill out various information on the website. I cannot get the numerical keys to work anybody any ideas as to what I may be doing wrong?
    GL

    Hi Goostrey Lou,
    Thanks for visiting Apple Support Communities.
    Start with the tips in this article if some keys on your keyboard are not working:
    One or more keys on the keyboard do not respond
    http://support.apple.com/kb/ts1381
    All the best,
    Jeremy

  • I installed the new 7.0 on my ipad and now I cannot get my internet connection to work. Any ideas, I have already tried rebooting but no luck. Another useless apple update that doesnt work?

    I installed the new 7.0 on my ipad and now I cannot get my internet connection to work. Any ideas, I have already tried rebooting but no luck. Another useless apple update that doesnt work?

    1. Turn router off for 30 seconds and on again.
    2. Settings>General>Reset>Reset Network Settings.

  • I cannot get the Output Module to work. I was able to get the button to show up, but when I click on it, nothing happens. i need to export a PDF asap

    I cannot get the Output Module to work. I was able to get the button to show up, but when I click on it, nothing happens. i need to export a PDF asap. I am trying to export 33 PSD files in BRIDGE to a PDF like I used to do on my other computer with bridge.

    Let's start with the general things.
    When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
    (1) Bypass Firefox's Cache
    Use Ctrl+Shift+r to reload the page fresh from the server.
    Alternately, you also can clear Firefox's cache completely using:
    orange Firefox button (or Tools menu) > Options > Advanced
    On the Network mini-tab > Cached Web Content : "Clear Now"
    If you have a large hard drive, this might take a few minutes.
    (2) Remove the site's cookies (save any pending work first). While viewing a page on the site, try either:
    * right-click and choose View Page Info > Security > "View Cookies"
    * Alt+t (open the classic Tools menu) > Page Info > Security > "View Cookies"
    In the dialog that opens, you can remove the site's cookies individually.
    Then try reloading the page. Does that help?

  • HT2494 I cannot get my logitec speakers to work on my iMac

    I cannot get my Logitec speakers to work. They do not show up in the output section
    Thanks

    Hi. If the speakers are using a standard 3.5mm plug, they need to be plugged into the headphone jack. Please clarify which jack you are using.
    Stedman

  • Since upgrading my iPhone 5 to ios 7, I cannot get the internet, email to work on 3g.  I get the message ""could not activate mobile data network. You are not subscribed to a mobile data service".  How do I fix it?

    Since upgrading my iPhone 5 to ios 7, I cannot get the internet, email to work on 3g.  I get the message ""could not activate mobile data network. You are not subscribed to a mobile data service".  How do I fix it?
    I've contacted o2, tried all of their suggested updates and changes, reset my phone 3 times and still no luck.
    Any help appreciated.
    Thanks,
    Louisa

    Hi, l have the same problem, were you able to resolve?

  • I lost my internet last night and now i cannot get my airport express to work

    i lost my internet last night and now i cannot get my airport express to work it is blanking yellow on /off

    Have you tried AirPort Utility it the Utility folder? If so, what was the result?

  • I cannot get Adobe Reader 11 to work - what have I done wrong?

    I cannot get Adobe Reader 11 to work - what have I done wrong?

    Hi Pat,
    I usually don’t have trouble explaining my problems, but this one is confusing the heck out of me.  I just downloaded Reader 11.  It is installed, I believe.  This is the first time Reader has not worked for me after upgrading to a newer version.  I’ve been reading PDF files forever, but tonight when I went to read a pdf file that I received today, I clicked on the file, expecting Reader to open up and it never did.  Then I tried to read some older pdf files and nothing happened when I tried to open the file.  I’ve been using Acrobat Reader for years so that’s why I’m so confused.
    I downloaded the file from the adobe.com website. and everything seemed to be fine.  My question is indeed vague, but I don’t know any other way to explain what happened.  Should I uninstall and start over??
    Thanks, Elaine

  • I am using the trial version of CC and cannot get the auto blend layers working despite following many videos on youtube etc. I have selected all layers but no matter which order I select etc all I get is an output of the first file in the stack - help!!

    I am using the trial version of CC and cannot get the auto blend layers working despite following many videos on youtube etc. I have selected all layers but no matter which order I select etc all I get is an output of the first file in the stack - help!!

    <moved from Adobe Creative Cloud to Photoshop General Discussion>

  • HT5637 i cannot get my itunes match to work on my iPhone 4s

    i cannot get the itunes match to work with my iphone 4s

    It should only be bringing up Siri if you press and hold it. Do you think you might be holding it too long?
    Cheers,
    GB

  • HT204380 I cannot get any FaceTime calls to work.

    I cannot get any FaceTime calls to work. If I do manage to talk to the other person, I only see myself. One only sees himself. One sees nothing. What are we doing wrong?
    Thanks.

    Sounds like a catch 22 situation. I rekon you are in the UK trying to use the 3 USB wimax stick.
    In anycase an iMac is a big machine to lug around. It's a difficult situation.
    If you have a neighbor, politely ask them if you can use their broadband for a short while. If this is not practical then call 3 and let them know your circumstances.
    I might be stepping on my own feet here…wait. You need Java 6.
    Ok for now, try the standalone combo update for Lion client. We will try things the manual way. It's a big download, please make sure you are not going to reach your download cap on your phone becuase you are now tethered to your mobile phone and I wouldn't want to see you pay a premium for this.
    Here is the Lion Client combo update. Download it and double click the eventual DMG file. http://support.apple.com/kb/DL1524

  • Grr. Cannot get PHP contact form to work.

    Hi!
    I cannot get a PHP contact form working. I have tried
    everything i can think of (which isn't much!) and can't get it to
    work. This is what i am using. Can anybody see what's wrong with
    this please? As you can see, the form contains a fromname,
    fromemail, subject and message fields.
    I'm a complete newb when it comes to PHP. Please please
    please help.

    Thanks for your reply.
    I just used the PHP provided in
    this
    tutorial?! Is the tutorial wrong?
    Sorry. As i said, i know nothing about PHP. How do i define
    the variables.

  • I cannot get my instant messaging to work on my ipod touch

    I cannot get my instant messaging to work on my Ipod. I just got it and set it up but it will not let me send any messages. I have wi fi. It is working good.

    See:
    iOS: Troubleshooting Messages

Maybe you are looking for