Replace JSF tag by an own tag

Hi,
I'm trying to replace a <h:inputText> by my own tag. The used HtmlInputText component should not be replaced.
The reason is, that i want to pass permissions to the tag and map them to readonly and rendered attributes. My Problem is, that my own tag doesn't reolv bean values. If i use the <h:inputText> the bean values show up correctly. If i use my own tag, the input text shows "#{myBean.value}".
What could be the problem?
Thx in advance
Henrik
Here is my tag:
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlInputText;
import javax.faces.context.FacesContext;
import javax.faces.webapp.UIComponentTag;
import com.arvato.jsf.security.JSFSecurity;
import com.arvato.jsf.security.Permissions;
import com.sun.faces.taglib.html_basic.InputTextTag;
public class ArvatoTextFieldTag extends InputTextTag {
    private String role;
    private String onkeypress;
    private String id;
    private String value;
    public String getRole() {
        return role;
    public void setRole(String permissions) {
        this.role = permissions;
    protected void setProperties(UIComponent component) {
        super.setProperties(component);
        if(id != null) {
            component.getAttributes().put("id", id);
        if(onkeypress != null) {
            component.getAttributes().put("onkeypress", onkeypress);
        if(value != null) {
            component.getAttributes().put("value", value);
        if(role != null) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            Permissions p = JSFSecurity.getInstance().getPermissionsForRole(role, facesContext);
            if(!p.isWritable()) {
                component.getAttributes().put("readonly", true);
            if(!p.isReadable()) {
                component.getAttributes().put("rendered", false);
        } else {
            component.getAttributes().put("readonly", false);
            component.getAttributes().put("rendered", true);
    @Override
    public String getComponentType() {
        return "javax.faces.HtmlInputText";
    @Override
    public String getRendererType() {
        return null; // no standalone renderer
    @Override
    public void release() {
        super.release();
        role = null;
    public String getValue() {
        return value;
    public void setValue(String value) {
        this.value = value;
    public String getOnkeypress() {
        return onkeypress;
    public void setOnkeypress(String onkeypress) {
        this.onkeypress = onkeypress;
    public String getId() {
        return id;
    public void setId(String id) {
        this.id = id;
}and my tld definition:
<taglib>
   <tlib-version>0.03</tlib-version>
   <jsp-version>1.2</jsp-version>
   <short-name>arvato-jsf</short-name>
   <uri>http://arvato.com/jsf/component/tags</uri>
   <description>Arvato JSF tags</description>
   <tag>
      <name>textfield</name>
      <tag-class>com.arvato.jsf.tag.ArvatoTextFieldTag</tag-class>
      <attribute>
         <name>id</name>
      </attribute>
      <attribute>
         <name>role</name>
      </attribute>
      <attribute>
         <name>value</name>
      </attribute>
      <attribute>
         <name>onkeypress</name>
      </attribute>
   </tag>
</taglib>

In the setProperties method, you've got to resolve the valuebinding (#{blah.whatever}) to get the actual value. But you only want to do that if the attribute is set to a valuebinding.
Here's an example:
      * @see javax.faces.webapp.UIComponentTag#setProperties(UIComponent)
     protected void setProperties(UIComponent component) {
          super.setProperties(component);
          //Set the field reference property
          if (fieldRef != null) {
               if (UIComponentTag.isValueReference(fieldRef)) {
                    ValueBinding vb = getFacesContext().getApplication().
                         createValueBinding(fieldRef);
                    component.setValueBinding("fieldRef", vb);
               } else {
                    component.getAttributes().put("fieldRef", fieldRef);
     }This example shows how to determine if the "fieldRef" attribute is a value binding, and extracts the value accordingly. But there's one more step. In your component class, or anywhere you access the attributes of your custom tag, use the following code:
     public String getFieldRef() {
          if (fieldRef != null)
               return fieldRef;
          ValueBinding vb = getValueBinding("fieldRef");
          if (vb != null)
               return (String)vb.getValue(getFacesContext());
          else
               return null;
     }The above snippet is what you would put in your custom component getter method.
JSF is open source. Something I found very helpful while learning how to create custom components was looking at how the JSF developers created theirs. You should go ahead and download the JSF source code.
CowKing

Similar Messages

  • How to create own tags in JSF?

    I am using xhtml, So I need to create own tags for retrieving data from database & query for data. So Just explain me the procedure for doing so. I m using hsql database...
    Thanking you
    --Mansingh Shitole                                                                                                                                                                                                                                                                                                                                                                                                                           

    ms_shitole wrote:
    I am using xhtml, So I need to create own tags for retrieving data from database & query for data. So Just explain me the procedure for doing so. I m using hsql database...It sounds to me that 1) using are using Facelets and 2) you are looking for a replacement for the JSTL SQL tags. If this is the case, I'll quote the J2EE Tutuorial:
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL7.html says:
    The JSTL SQL tags for accessing databases listed in Table 14-8 are designed for quick prototyping and simple applications. For production applications, database operations are normally encapsulated in JavaBeans components.

  • How can i create and paste my own tags into source page of a html editor

    I download ekit and try to customize.
    I wrote a similar code:
    TagEditor extends HTML
    , and inner class:
    ExtendedTag extends Tag
    by following similar structure with javax.swing.text.html
    I added my own tags into tagList in HTMLUtilities class which is in com.hexidec.ekit.component. Because it is initialized three times when i run the program.
    I add a button to multitoolbar, and wrote a insertMyTag method in class EkitCore:
    private void insertMyTag() throws IOException, BadLocationException, RuntimeException {
    int caretPos = jtpMain.getCaretPosition();
    // htmlKit.insertHTML(htmlDoc, caretPos, "<VAZIFE>", 0, 0, TagEditor.ExtendedTag.VAZIFE);
    jtpMain.setText("<HTML><BODY><VAZIFE></BODY></HTML>");
    jtpSource.setText(jtpMain.getText());
    jtpMain.setText does display in the source editor but the default HTMLEditorKit creates the unkown tags and inserts them into the html view output with box-like borders. I want to keep the tags in the source but remove them from the output view so the user only sees the normal HTML output and my app sees the XML tags.
    What do I need to do in insertMyTag to turn off the strange display of
    unknown tags? Is there an easier way to do this?
    Thanks

    Or, take a ScreenHunter image of the list and email that to yourself.

  • How can I create my own tag name while creating a partition table.

    I have X4500 running Solaris 10. I have formatted a disk and created partition table as given below.
    Specify disk (enter its number): 0
    selecting c0t0d0
    [disk formatted]
    /dev/dsk/c0t0d0s0 is part of active ZFS pool zpool1. Please see zpool(1M).
    FORMAT MENU:
    disk - select a disk
    type - select (define) a disk type
    partition - select (define) a partition table
    current - describe the current disk
    format - format and analyze the disk
    fdisk - run the fdisk program
    repair - repair a defective sector
    label - write label to the disk
    analyze - surface analysis
    defect - defect list management
    backup - search for backup labels
    verify - read and display labels
    inquiry - show vendor, product and revision
    volname - set 8-character volume name
    !<cmd> - execute <cmd>, then return
    quit
    format> partition
    PARTITION MENU:
    0 - change `0' partition
    1 - change `1' partition
    2 - change `2' partition
    3 - change `3' partition
    4 - change `4' partition
    5 - change `5' partition
    6 - change `6' partition
    select - select a predefined table
    modify - modify a predefined partition table
    name - name the current table
    print - display the current table
    label - write partition map and label to the disk
    !<cmd> - execute <cmd>, then return
    quit
    partition> print
    Current partition table (original):
    Total disk sectors available: 1953508749 + 16384 (reserved sectors)
    Part Tag Flag First Sector Size Last Sector
    0 usr wm 34 4.00GB 8388641
    1 usr wm 8388642 2.00GB 12582945
    2 usr wm 12582946 200.00GB 432013345
    3 usr wm 432013346 175.00GB 799014945
    4 usr wm 1166180386 375.43GB 1953508748
    5 usr wm 799014946 175.00GB 1166016545
    6 usr wm 1166016546 80.00MB 1166180385
    8 reserved wm 1953508749 8.00MB 1953525132
    partition>
    I am unable to specify my own tag name. How can I change the tag name to one of my interest.
    I need to create 3 partitions as told below
    partitions:
    /earth
    /mars
    /work
    /earth and /work should be roughly equal in size, /mars should be twice the size of the others, if that is possible. If not 3 partitions of equal size will do.
    Please, help me .
    Thank you.

    Exactly 1TB? Slightly under/slightly over?
    Traditional Solaris disk labels are in VTOC format, but this format cannot describe disks larger than 1TB. So EFI labels must be used on disks larger than 1TB. Setup is slightly different.
    Are these physical disks or LUNs from a SAN array? If they are array LUNS, it is often the case that they don't have a Sun label of any type. So...
    #1 Apply a Solaris label
    If the LUNS don't have a label (when selected in 'format', it gives a warning that no label is present and offers to apply a label immediately). When run non-interactively, format assumes "yes" for any questions. So all you'd have to do is select every disk to have it apply labels to any unlabled disk. Run 'format' once and find the highest number (maybe it's 50 for you). Create a text file that looks like this:
    disk 1
    disk 2
    disk 3
    disk 50Then feed that to format like this:
    # format -f /tmp/disklist or whatever you've named the file.
    #2 Apply the partition layout to all disks you want.
    You asked if you should do the same procedure, but I don't see that you've actually done anything above other than print out the existing layout. Take one of your 48 drives and partition it the way you want manually (set the slices to the sizes that you want). Then you can copy the layout of that disk to others. You only want to do this between disks/LUNs of the same size. As an example, if you've explicitly partitioned c1t0d0 and you want to apply this to c1t1d0, do this:
    # prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2Repeat for all of your other disks.
    Darren

  • How to use my own tag in XMP

    I have translated HTML to PDF. It is working properly if I use only DC Metadata.
    But if I write other tag in XMP and load this file in PDF, I cannot see right information.
    I want to use my own tag such as "co-author" and "related paper".
    I define this kinds of tags as namespace and XML Schema.
    Then I want to use this tag in PDF. But I don't know how to do after this.
    How can I do? How can I use my own tag(element or attribute) in XMP?
    Actually I don't have much experience to deal with XMP.
    please help.

    Will you clarify where you are looking for your custom information.
    It should display in Acrobat.
    Acrobat 7 File menu > Document Properties... > Additional Metadata... > Advanced > {list of namespaces}
    Your tags should appear under the namespace you used.

  • JSF 2.0: Facelets: No tag libraries (TLDs)?

    Hi, I'm currently concerned with JSF 2.0 and Facelets. I found:
    - Tags are no longer defined in taglibs (TLDs) (instead they appear to be hard-coded in Java code)
    - On the other hand, jsf-impl.jar does ship two taglibs (for HTML and JSF Core), however, these solely include tags that have been existing since JSF 1.2 (the new tags are not defined there)
    OK, that may be fine. Nonetheless, now there's a problem with code completion and validation in IDEs (Eclipse in my case).
    Any ideas on how to get over that?
    Thanks

    [1] https://mojarra.dev.java.net/source/browse/mojarra/trunk/jsf-api/doc/web-facelettaglibrary_2_0.xsd?rev=6738&view=log
    Excuse me, that's the XSD schema for facelet-taglib. I'd be requesting TLDs or XSDs that contain definitions for commandButton, button, etc.
    [2] https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/index.html
    That's not a XSD or TLD definition file but just documentation. Moreover, it only covers JSF 1.2 tags, not JSF 2.0 tags. (I do know that it does ship with the JSF 2.0 specification.)
    - Please remember that my final goal would be to have code completion and validation for JSF 2.0 in common IDEs, including Eclipse.
    Thanks

  • Own tag in code templates of the abap editor

    Hi,
    i think you all know the code hints and that you can define own code templates in the abap editor (at the options screen). As an information I dont mean the code patterns.
    So does somebody know how to define own tags for these code templates? Or where the logic is located for the code hints?
    Bye
    Richard

    Hi Richard,
    I know its pretty late to answer the question but just in case if you have not figured it out then see,
    Regards,
    Ankit.

  • Add Explicit Tag To Your Own Recordings?

    In iTunes, when you purchase a song from the iTunes Store, or download a podcast, some of the content shows up with a red EXPLICIT label next to the song Name.
    Well, what I'd like to know is, Is it possible to add this EXPLICIT tag to your own recordings? If so, how? For example, suppose you recorded your own piece of music (in GarageBand) that contained lots of swear words, it would be useful to add the EXPLICIT tag to it. And for all the CDs you Imported into iTunes that contain swear words, it would be useful to tag those as well.

    Well, what I'd like to know is, Is it possible to add
    this EXPLICIT tag to your own recordings?
    No, you cannot add on this information yourself.

  • ADF Faces: is mixing JSF RI and ADF Faces tags supported?

    Hi,
    I'm looking at ADF Faces as a future possibility for our application that is currently based on JSF RI.
    When looking at the ADF Faces demo it strikes me that all pages are almost completely built up from ADF Faces tags.
    For instance
    af:form
    af:commandButton
    af:inputText
    are used instead of the equivalent core jsf tags f:form, f:commandButton and f:inputText
    I'm wondering if this is mandatory if we would like to use some ADF Faces components mixed within our existing application.
    In other words: are ADF Faces tags supported in the environment of conventional JSF tags? And mixing ADF Faces JSF components with JSF components by other vendors?
    Another thing that strikes me is that pages are constructed using ADF Faces tags for any and all markup content.
    I guess this is meant to support several different clients (normal browser applications, mobile clients, voice activation over telephone) using different renderers.
    In my experience abstracting markup this way inherently means loss of control over the exact markup that is sent to the client. This is not acceptable for all projects and customers.
    Is embedding ADF Faces tags within template HTML, within f:verbatim tags or not, supported?
    Regards,
    Joost de Vries

    You absolutely can mix JSF RI and ADF Faces tags. This is very much supported! You can swap in <h:form> and <h:commandButton> and <h:inputText>. Our versions support some features that the JSF tags do not, as described in our release notes.
    Your point about using tags to produce all markup is a very cogent one. For some projects, absolute control over HTML will be a necessary requirement, so we do support that style of development. But we believe strongly that the future does not lie in constant handcoding of HTML, but instead in building more powerful, flexible, and reusable components and assembling those into pages. This was one of the themes of a talk I gave with two coworkers at this past JavaOne.
    -- Adam Winer (JSF EG member and ADF Faces lead)

  • UIX replacment for isUserInRole tag from the “Request Tag Library,”

    Is there a UIX replacement for the isUserInRole which is provided by the “Request Tag Library”?
    This tag checks if the user has the correct security roles.
    thanks
    Marcel

    Is there a UIX replacement for the isUserInRole which is provided by the “Request Tag Library”?
    This tag checks if the user has the correct security roles.
    thanks
    Marcel

  • Custom Tag: pass my own type in as attribute

    I thought I can pass any type as attribute into my custom tag. I tried, but failed. The exception is:
    org.apache.jasper.JasperException: Unable to convert '${myType}' to class MyTpye for attribute myAttribute: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager.
    I know I can pass the value in using PageContext attribute. However, still want to figure out how to do it through custom tag attribute.
    Here's my taglig file:
    <tag>
    <name>myTag</name>
    <tag-class>MyTagClass</tag-class>
    <body-content>empty</body-content>
    <attribute>
    <name>myAttribute</name>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    <type>MyType</type>
    </attribute>
    </tag>
    What am I missing here? Thanks.

    Hi
    Pls tell me how did you resolve this issue. I am also facing the same problem.
    Thanks
    Prakash

  • Replace an image in a XML tag

    I have an image that is tagged with an XML tag. I want to change the image with a script. If I change image manually the href in my XML changes, if I change the href the image doesn't.
    I've managed to get a return that the image excists, but if I try to do something with it, I get invalid object error.
    Any suggestions?
    cheers

    hi larsthoren,
    can you elaborate more? 'coz i got an xml with the right path of image and when i load it to indesign it works fine. no need for a script.
    thanks,
    Kratos

  • How to use h:selectOneRadio tag  inside h:dataTable tag

    Hi All,
    Can any one tell me how to use <h:selectOneRadio> tag inside <h:dataTable> tag and how to get selected radio button value in bean ?

    JSF<h:selectOneMenu value="#{myBean.selectedItem}">
        <f:selectItems value="#{myBean.selectItems}" />
    </h:selectOneMenu>MyBeanprivate String selectedItem;
    public String getSelectedItem() {
        return selectedItem;
    public void setSelectedItem(String selectedItem) {
        this.selectedItem = selectedItem;
    public List getSelectItems() {
        List selectItems = new ArrayList();
        selectItems.add(new SelectItem("key1", "value1"));
        selectItems.add(new SelectItem("key2", "value2"));
        selectItems.add(new SelectItem("key3", "value3"));
        return selectItems;
    }String selectedItem should contain the key (key1, key2 or key3) when selected. The values (value1, value2 and value3) are the options as shown in the list.

  • No tag "output_text" defined in tag library imported

    Dear All,
    I have the following jsp file.
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <html>
    <head>
    <title>Welcome to PizzaRia!!!</title>
    <link rel="stylesheet" type="text/css"
    href="<%= request.getContextPath() + "/Styles.css" %>">
    </head>
    <body>
    <f:view>
    <h:form id="myForm">
    <table border="0" cellspacing="4" cellpadding="0"
    width="<h:output_text value="#{initParam.pageWidth}"/>">
    <tr>
    <td colspan="2">
    <%-- The header --%>
    <%@ include file="header.jsp"%>
    </td>
    </tr>
    <tr>
    <td valign="top">
    <%-- The menu --%>
    <%@ include file="menu.jsp"%>
    </td>
    <td valign="top">
    <!--------------- the beginning of the Welcome page ------------->
    <br>
    <div class="NormalLarge">Welcome to PizzaRia!!!</div>
    <br>
    <div class="NormalSmall">Try our tasty pizzas today!</div>
    <!--------------------- the end of the Welcome page ------------->
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <%-- The footer --%>
    <%@ include file="footer.jsp"%>
    </td>
    </tr>
    </table>
    </h:form>
    </f:view>
    </body>
    </html>
    When it comes to deployment, tomcat gives the following error saying that the tag is not defined.
    Any suggestions. highly appreciated.
    org.apache.jasper.JasperException: /index.jsp(14,9) No tag "output_text" defined in tag library imported with prefix "h"
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Jaliya

    thnx BalusC,
    I'm new to this stuff. That was the problem.
    Thanks again,
    Jaliya

  • Move tags to from imported tags?

    I had my PC crash & I reinstalled PSE 10.  Since I could not find my old B/U at this time or the catalogue I just told the program to look in an old 'My Pictures' folder & import from there.  This worked OK & all the pictures were imported including the tags.
    My current problem is that all of these old tags appear as imported tags rather that where you normally create tags which is further up that same column.  Is there anyway to get the tags back to there normal state & not appear as being imported & if so how is this done?
    Thanks in advance,

    You can re-create the original tags and categories hierarchies, but it's a manual task involving 'editing' everyone of the imported tags.
    First, try to re-create as much as possible your categories hierarchies. By default, you have only the main categories : people, places etc. Re-create the categories and subcategories you can remember (don't worry if that is only a part of the initial tree).
    Then, for each tag in the 'imported keywords' category, right click on the category and choose ' edit keyword'. In the dialog, replace the default (imported...) category by the correct one in the drop down list of existing categories/subcategories.
    Edit:
    You did the right thing when you saved the metadata to files. Another useful feature of the Organizer is that you can save the categories tree to a text file, and recreate it in a new catalog or add it to an existing catalog.
    In the keyword panel, next to the + sign, you have a small triangle : click on it to see a drop-down menu with one option 'Save keyword tags to file'. This will save the tree (hierarchy) either to restore it or to add it to an existing category hierarchy.
    If you have to repeat your procedure by reimporting your media in a new catalog, restore the categories before you reimport your media.

Maybe you are looking for