How to add properties to a custom JSF component?

Hello, everybody!
I've just developed my first custom JSF component. It's a data pager and it is working pretty well. But now I want to be able to use some of it attributes in my backing beans at runtime. I mean, I want to bind it to component in the JSF page. It already has a binding attribute in the tld file, but I want to be able to accesss two values that the renderer of my custom component calculate inside it, which would relieve me from calculating these values manually in the backing beans. So, I would like to know how to make these values external to the component.
By now this is my custom pager class:
import javax.faces.component.UICommand;
public class UIPaginadorDados extends UICommand
}You can see that it has no logic because all the logic is in the renderer class:
import javax.faces.render.Renderer;
public class PaginadorDadosRenderer extends Renderer
    // logic here
}As I said I want to be able to do the following in my backing beans:
private UIPaginadorDados pager = new UIPaginadorDados();
// and later...
pager.getCurrentPage();
pager.getPageCount();In the JSF page:
// I already can do this, because I have a binding attribute
<urca:paginadorDados binding="#{backingBean.pager}" />I suppose that I'll have to create the properties getCurrentPage() and getPageCount() in the component class, UIPaginadorDados, but I don't know how to get the values to the properties from the renderer class. I don't even know if this is how I should do it.
So I would appreciate a lot your help about this subject.
Thank you.
Marcos

Marcos_AntonioPS wrote:
RaymondDeCampo wrote:
I neglected to mention: do not forget to implement the methods in StateHolder to preserve the properties you added to your component.Hello, Raymond. Could you elaborate a little more on that? If you could give a short example, it would be helpful.
MarcosNo problem. I have already found out how.
Thank you very much, Raymond.
Marcos

Similar Messages

  • How to add search help to custom infotype listbox??

    Hi All,
    How to add search help to custom infotype listbox??
    Thanks in advance

    Hi Vinay,
    We have search help and list box as 2 different options.
    At a time we can make a field a list box or a search help.List box is restricted and we can pick values from the defined list whereas in search help we can allow more entries and then validate the value entered later.
    Implementing a listbox or search help in infotype is same as that of implementing it in a modulepool .
    for search help..we can create a custom search help or check for existing search help in se11
    then in the screen on infotype field..assign the search help direcly at the screen painter level..
    double click on the field in screen painter -> change mode and then in the space for "search help" enter the search helps name
    for list box..in the screen painter ,make sure the field is selected as list box..then in PAI of screen we do a
    (Process on value-request..field fieldname module module name)..check syntax and other details...
    Using function module vrm_set_value fill the field and populate it as required
    Pls check and revert
    Regards
    Byju

  • How to add .js link in custom list form through sharepoint designer 2013

    hi friends
    so far i was adding jquery code to script editor webpart in custom list form.
    but i need to know how to add .js link in custom list form through sharepoint designer 2013
    please help me.

    Hi,
    We can add the "JS Link Property" in the “WebPart” node in the custom list form page through SharePoint designer 2013.
    Here is an example for your reference:
    <JSLink xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm">~site/Style Library/js/custom.js</JSLink>
    Noticed that, we should not lose the 'xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm' attribute.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • YouTube - How to add videos from youtube on jsf-adf

    YouTube - How to add videos from youtube on jsf-adf.
    when i using iframe i can't send data from beans.

    you can use a <f:verbatim> tag in your page and in it just write the HTML code for embedding a video.
    and can i send data from beans class in html components?
    i wrote this
    <af:iterator id="i2" var="row"
    value="#{MyBean.src_items}"
    varStatus="st">
    <af:showDetail disclosed="false" id="sd1"
    styleClass="AFStretchWidth"
    disclosedText="#{row}">
    <f:verbatim>
    <iframe id="ifv" src="#{row}"/>
    </f:verbatim>
    </af:showDetail>
    </af:iterator>
    but that were not worked .
    Edited by: Vakhushti on May 9, 2011 12:40 PM

  • Custom JSF Component tags ignored after converting to Facelets layout

    I am currently using JDeveloper 10.1.3.3.
    I have a project consisting of .jspx pages. These pages mainly use components from ADF faces core. I also created my own custom JSF component that I use in several of these pages.
    Then, I needed to use Facelets so that I could apply a standard layout to all my .jspx pages. I looked at all the tutorials, and I created a layout.xhtml for my .jspx pages to use. This worked great for my .jspx pages that don't have my custom JSF component.
    Now, when I run my page with my custom component <img:newimage ...etc >
    the tag is ignored and it appears in the page's source as is when it should render as <img.src=...etc>. Attributes of newimage are changed on the page appropriately like width and height, but my component's tag, component, and servlet java files are never accessed.
    How can I fix this? Please help!
    Thanks.

    Hi,
    did you post this issue to the Facelets open source site ? Sounds like an issue with using Facelets
    Frank

  • Custom JSF component with custom value datatype

    I've created a simple custom JSF component with a decode, encodeBegin as follows:
    public void decode(FacesContext context) {
        Map<String, String> requestParameters = context.getExternalContext().getRequestParameterMap();
        String clientId = getClientId(context);
        String value = requestParameters.get(clientId);
        setSubmittedValue(value);
        super.decode(context);
    public void encodeBegin(FacesContext context) throws IOException {
        ResponseWriter response = context.getResponseWriter();
        String clientId = getClientId(context);
        response.startElement("input", this);
        response.writeAttribute("name", clientId, "id");
        response.writeAttribute("type", "text", null);
        String value = (String) getValue();
        if (null != value) {
             response.writeAttribute("value", value, "value");
        response.endElement("input");
    }With also:
    setRendererType(null);as part of the constructor.
    This component works just fine both inside and outside of a dataTable component, as expected.
    What I would like to do now is to replace the String value datatype with a custom class, for example MyDataType. For this I do:
    public void decode(FacesContext context) {
        Map<String, String> requestParameters = context.getExternalContext().getRequestParameterMap();
        String clientId = getClientId(context);
        String value = requestParameters.get(clientId);
        MyDataType myData = (MyDataType) getValue();
        MyDataType newData = (MyDataType) myData.clone();
        newData.setValue(value);
        // copy old object and only update the changed field of this object
        setSubmittedValue(newData);
        super.decode(context);
    public void encodeBegin(FacesContext context) throws IOException {
        ResponseWriter response = context.getResponseWriter();
        String clientId = getClientId(context);
        response.startElement("input", this);
        response.writeAttribute("name", clientId, "id");
        response.writeAttribute("type", "text", null);
        MyDataType value = (MyDataType) getValue();
        if (null != value) {
             response.writeAttribute("value", value.getValue(), "value");
        response.endElement("input");
    }Now this works perfect outside of a dataTable component, but inside it fails to update the property on the BB.
    Are there somewhere examples on how to properly use custom datatypes as values for UIInput components? Also how to only partially update the value (like I do, I only want to update the value field of the MyDataType object)

    Even if I encode the entire MyDataType via hidden input elements and decode it again (i.e. not using a cloned getValue) it's still not working side a dataTable.
    Could it have to do something with me using Facelets?

  • Creating a custom JSF Component

    Hi,
    I am trying to create a custom JSF Component. My ultimate goal is to pass a bean to my custom component and have the component render some HTML output based on the info contained in the bean. Before I attempt that I am trying to get a simple custom component to just work. This component is based on the tutorial found here: http://www.jsftutorials.net/components/index.html
    This tutorial just creates a component that outputs a <div> tag around the body contents of the custom component.
    To keep this short I have done the following items from the tutorial link above:
    1) I have created the tld file defining the tag class, name, uri and shortname
    2) I have also created the tag class called TickerTag.java along with the component class UITicker.java. These classes are straight copy-and-paste jobs from the tutorial link and compile fine.
    3)My faces-config.xml file has the proper component definition of
    <component>
    <component-type>ticker</component-type>
    <component-class>ticker.UITicker</component-class>
    </component>
    This was the easy part. The example then goes on to use the custom component in a JSP page. I managed to get the custom component to work in a JSP page BUT my problem is getting the custom component to work in an XHTML file.
    I thought all I had to do was define an xml namespace using the uri from my tld file like so:
    Note: My uri is www.fubar.com/tags and is defined in the tld file.
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:u="http://www.fubar.com/tags">
    I then try to use the tag like so <u:ticker> <f:verbatim>Hello JSF Component</f:verbatim></u:ticker>
    I am expecting the following output: <div>Hello JSF Component
    </div>
    but instead I get
    <u:ticker>Hello JSF Component</u:ticker>
    It seems the tag is not even processed. This is my first jump into custom components. I have done custom JSP tags in the past but I never tried to display them on an XHTML page.
    If you are wondering why I am using XHTML pages, this was setup a while back by a previous developer. Changing everything to a JSP would take a long time and probably break some stuff I am not aware of yet. As such the web.xml file of this JSF web app has the following:
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    So all *.jsf files are processed and sent to the corresponding .xhtml file.
    I have looked up creating custom components on google and every last example uses their newly created components in a jsp file. No XHTML uses so far.
    Below are my tld files and xhtml file if that helps:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>u</short-name>
    <uri>http://www.fubar.com/tags</uri>
    <tag>
    <name>ticker</name>
    <tag-class>ticker.TickerTag</tag-class>
    <body-content>JSP</body-content>
    </tag>
    </taglib>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:u="http://www.fubar.com/tags">
    <html>
    <head>
    <title>Show Custom Component</title>
    </head>
    <body>
    <f:view>
    <u:ticker> <f:verbatim>Hello JSF Component</f:verbatim></u:ticker>
    </f:view>
    </body>
    </html>
    Any suggestions/help are much appreciated,
    Nick
    </div>

    Thanks Ray. I'll take a look at that site.
    I managed to figure out my problem. I never created a .taglib.xml file that reference the component I defined in the faces-config.xml file. Once I did that everything work perfectly.
    I managed to use this forum post as a guide.
    http://osdir.com/ml/java.facelets.user/2006-12/msg00042.html
    I hope this helps anyone else.
    Nick

  • Create a custom JSF component

    Hi,
    I want to create a custom JSF component. I've setup a new application containing 2 projects:
    - a 'components' project, containing all the custom components
    - a 'view' project, to test the created custom components.
    There is dependency between the components project and the view project. In the view project, I added the
    the Tld, in order to use my components in the project.
    From the component palette, I can drop a component onto a .jspx page but after running the page, no output
    is printed onto the screen. The HTML source code only contains my 'tag-name' (eg: <ctb:mytag/>)
    Am I doing something wrong?
    UIComponent:
    import java.io.IOException;
    import javax.faces.component.UIComponentBase;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    public class BasicComponent extends UIComponentBase {
        public String getFamily() {
            return "BasicComponent";
        public void encodeBegin(FacesContext context) throws IOException {
            ResponseWriter out = context.getResponseWriter();
            out.write("Hello World");
    }Tag
    import javax.faces.component.UIComponent;
    import javax.faces.webapp.UIComponentTag;
    public class BasicComponentTag extends UIComponentTag {
        public String getComponentType() {
            return "BasicComponent";
        public String getRendererType() {
            return null;
    }Tld entry:
      <tag>
        <name>BasicComponent</name>
        <tag-class>BasicComponentTag</tag-class>
        <body-content>JSP</body-content>
      </tag>Thanks in advance,
    Koen Verhulst

    The body tag should be as follows
    <bodycontent>JSP</bodycontent>
    but the JSP will not work. Here is the file:
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:af="http://xmlns.oracle.com/adf/faces"
    xmlns:afh="http://xmlns.oracle.com/adf/faces/html"
    xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable"
    xmlns:cf="/WEB_INF/helloWorldLib.tld">
    <jsp:output omit-xml-declaration="true" doctype-root-element="HTML"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
    <jsp:directive.page contentType="text/html;charset=windows-1252"/>
    <f:view>
    <html>
    <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1252"/>
    <title>List of Values</title>
    </head>
    <body><h:form>
    <cf:jsfhello hellomsg="This is it" />
    </h:form></body>
    </html>
    </f:view>
    </jsp:root>
    Edited by: bongo2 on Oct 28, 2008 2:58 PM

  • How to add properties to Channels in Portal Server 7

    hi,
    When in the Portal Server Console in the Manage Containers and Channels section I can easily edit the properties for the configured items. Now I want to add a property to, let's say, the SearchProvider or the preconfigured Search of the DeveloperSample portal. How would I go about that? PS6 had a nice big "New" button on the property pages to add properties, how can I do the same with PS7?
    What I want to do is add a property to the Search that I can then access from within the jsp files, but that can easily be set and changed from the server console.
    any hints are appreciated ;)
    thanks!

    The "New" button was removed from the UI for the console in PS 7 to avoid confusion caused by adding properties to channels that are then not referenced by the code for the channel. The only way that a named property can be used is if the property is referenced by the code for the Provider, e.g., in the Java code or in the JSP. When the code is modified to start referencing a new property, the intent is that the developer also modify the <Provider> definition in the display profile to also list a default value for that property. Then the property will show up in the property edit page for channels created from that Provider.
    Editing of the Provider definition requires actually editing the display profile XML.
    HTH.
    Tom

  • How to add more fields to Customer sales report

    I want to add some fields to customer sales report generating through S_ALR_87012186 like,Invoice number,Invoice date,Tax registration number,tax amount,before tax amount..etc.
    Please let us know the best possible method to add these details.

    It is not suggested to alter a standard SAP report. Still if the requirement persists, then copy the standard program into a zprogram and add required fields.

  • How we add parter function in customer sales area usinf xd02

    how we add parter function.in xd02.any function module or user exit is there.
    it check first whether parter exit or not if not exit then add to atb partner function tab in XD02.any bdc how we add at run time this

    u can check with lsmw

  • How to add f4 help to customized SO

    Hi Experts,
    Could u please help; how to add f4 help to my SO.
    my req.  is ,I have created my SO in my report, i want have f4 help on below filed in my report.
    select-options: s_ihrez for vbak-ihrez.
    Could please help indetails(step by step).
    Thnx.
    POINTS REWARDED immediately.
    Regards. Vishnu.

    hi,
    check the example
    TABLES: mara, makt.
    DATA mat LIKE mara-matnr.
    DATA: BEGIN OF itab OCCURS 0,
    matnr LIKE mara-matnr,
    END OF itab.
    DATA : BEGIN OF btab OCCURS 0,
    maktx LIKE makt-maktx,
    END OF btab.
    DATA : return LIKE ddshretval OCCURS 0 WITH HEADER LINE.
    SELECT-OPTIONS: so_matnr FOR mara-matnr,
    so_maktx FOR makt-maktx.
    INITIALIZATION.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_matnr-low.
    PERFORM matnr.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_matnr-high.
    PERFORM matnr.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_maktx-low.
    PERFORM maktx.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_maktx-high.
    PERFORM maktx.
    *& Form matnr
    text
    FORM matnr.
    REFRESH itab.
    SELECT matnr FROM mara INTO TABLE itab.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    retfield = 'MATNR '
    dynprofield = 'P_MATNR '
    dynpprog = sy-repid
    dynpnr = sy-dynnr
    value_org = 'S'
    TABLES
    value_tab = itab
    return_tab = return.
    mat = return-fieldval.
    UNPACK mat TO mat.
    so_matnr = return-fieldval.
    REFRESH return.
    CLEAR return.
    ENDFORM. "matnr
    *& Form maktx
    FORM maktx.
    REFRESH btab.
    SELECT maktx FROM makt INTO TABLE btab WHERE matnr = mat AND spras =
    sy-langu.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    retfield = 'MAKTX'
    dynprofield = 'SO_MAKTX '
    dynpprog = sy-repid
    dynpnr = sy-dynnr
    value_org = 'S'
    TABLES
    value_tab = btab
    return_tab = return.
    so_maktx = return-fieldval.
    REFRESH return.
    CLEAR return.
    ENDFORM. "maktx
    if helpful reward points

  • How to add modules to my Customer Project?

    Hello,
    I've created a new Customer Project on an existing track for the ICSS_B2B application. After the creation, I want to add modules to my CP but this aint
    working. When I right click on my CP in the J2EE DC Explorer and press 'Add
    Modules', I can't specify any Web- and EJB-Modules. It's an empty list.
    What did I do wrong? Can anyone help me?
    thank you in advance,
    kind regards...

    how to change the class name after the project is created.In NetBeans, right click the class name either in the declaration or constructor, select Refactor --> Rename... and follow the dialog.
    You can refactor --> rename anything that is not in a guarded block. For those, there are options via the properties window.
    db

  • How to add the User in customized Group.

    Hi All,
         If we create any User in SAP Portal then that user is assigned to
    everyone group by default.Now i have one custom group,say 'ABC'.what i
    want is, which ever user is being created through SAP Portal should be
    added to this group.
    one way i think, is to create a webDynpro application which will add
    all the portal users to the customized group but the problem is how to
    run this appl.Continuously.
    regards,
    Mithileshwar

    Hi!
    I do the test here, try this:
    In group ABC, add Everyone role in Assigned Roles.
    In my case I’m using a role XXX in group Everyone and I configured all iViews for this role.
    Regards,
    Edson Thomaz

  • How to add New fields to Customer Master Record Screen

    Hi All,
    As per our business requirment we need to add some new fields the BP screen.
    Could you suggest me how can I customize the new fields in BP creation screen.
    I change the screen sequence with the help of VCT, but I need to add some more new fields. Your suggestions will be highly appreciated.
    Thank you and Best regards

    Venkat,
    Your best bet is to read the documentation at:
    http://help.sap.com/saphelp_crm40/helpdata/en/20/a4ffee7e0fcc4ebb7e5466d3903d38/frameset.htm
    This gives you an overview of the Easy Enhancement workbench.
    Your steps to use it will be the following setup the customizing in transaction EEWC.  You can search this forum for help on how to setup this customizing.
    Then create the new extension using transaction EEWB, and follow the steps in the help documentation above, also read note: 484597.
    After you have read the doucmenation, and if you get stuck, then let me know and I will try to answer those questions.  The EEWB is very simple, so I don't think you will have too many problems using it.
    Good luck,
    Stephen

Maybe you are looking for