001    package edu.nrao.sss.webapp.faces.tag;
002    
003    
004    import javax.faces.application.Application;
005    import javax.faces.webapp.UIComponentTag;
006    import javax.faces.component.UIComponent;
007    import javax.faces.el.ValueBinding;
008    import javax.faces.context.FacesContext;
009    //import org.apache.log4j.Logger;
010    
011    import edu.nrao.sss.webapp.faces.component.AnchorUIComponent;
012    
013    public class AnchorTag extends UIComponentTag 
014    {
015            //private static final Logger log = Logger.getLogger(AnchorTag.class);
016            private String name = null;
017    
018            // Associate the renderer and component type. Same type as recorded in
019            // faces-config.xml.
020            public String getComponentType() { return "edu.nrao.sss.Anchor"; }
021            public String getRendererType() { return null; }
022    
023    
024            @SuppressWarnings("unchecked")
025            protected void setProperties(UIComponent component)
026            {
027                    super.setProperties(component);
028    
029                    // set name
030                    if (name != null) 
031                    { 
032                            if (isValueReference(name))
033                            {
034                                    FacesContext context = FacesContext.getCurrentInstance();
035                                    Application app = context.getApplication();
036                                    ValueBinding vb = app.createValueBinding(name);
037    
038                                    component.setValueBinding("name", vb);                  
039                            }
040                            else 
041                            {
042                                    ((AnchorUIComponent)component).setName(name);
043                            }
044                    }                         
045            }
046    
047            /**
048              * clear up any resources we've used.
049              */
050            public void release()
051            {
052                    super.release();
053                    name = null;
054            }
055    
056    
057            /**
058              * Bean method for our name attribute.
059              */
060            public void setName(String name)
061            {
062                    this.name = name;
063            } 
064    }