Writing own jsf component

Hello,
I'm writing my own JSF components.
I got a problem with a component of type: javax.faces.Command.
My component works well in Creator and after being deployed excepts that in the page navigation tab, when I drag a link from my component to another page, Creator defines a new action ("casex" for instance) but DO NOT affect this action to my component at the JSP level (i.e. the attribute "action "is not set on my component).
I have to do it myself for the navigation to work.
I think I miss something during component generation. Any idea ?
Tnxs for any help !
-- F

Hello Edwin,
Thanks for your answer ! In the mean time I rebuilt
my components on the blueprint basis from
bpcatalog/ui according to your blog and everything
works fine !
Now I have a new problem/question:
Is there a way to access the application's message
bundles (for localization) during the rendering of a
custom component ?
I have a custom component that should access -
through the rendering process (encodeBegin) - the
application localization's bundle in which it is
running to localize a message .
I tried the following:
encodeBegin(FacesContext f, UIComponent x) throws
IOException
/...Start of rendering process ../
String
tooltip=ResourceBundle.getBundle(FacesContext.getCurre
ntInstance().getApplication().getMessageBundle(),
FacesContext.getCurrentInstance().getExternalContext()
.getRequestLocale()).getString(<key>);
/..Rendering process continues ./}
That does not work... (always returning an empty
string)
Thanks for any help !
-- Fab
There should be a way to do what you want, but it's not my area of expertise and I would need to do some debugging.
-Edwin

Similar Messages

  • How to load a class dynamically (via reflection) in a jsf-component

    Hi all,
    I am writing my own jsf component and I would like to do it generically. Therefore I have an attribute, where the developer can pass a fully qualified classname, which I want to use to instantiate. But I have a Problem with the classloaders, everytime I get a ClassNotFound-Exception during debugging.
    Does anybody know how it is possible, to to get the most parent classloader?
    Currently I am even not able to load a class, which is in the same package like all other compontent-classes.
    Thank you very much in advance
    Thomas

    Within web applications, I believe it is recommended to use Thread.getContextClassLoader(). Keep in mind that web applications require different classloader semantics than regular Java applications. The class loader which gets resources from the WAR is favored over others, even when this violates the normal class loading conventions.

  • Just extended my first jsf component. but in the right way?

    Hi all,
    After days of trial and error, i finally managed to code my own JSF component, extending existing infrastructure. Since things just suddenly fell in place during a brute force approach to make it work, i'd like to ask for opinions of seasoned JSF veterans whether this makes sense or there is a better way to do things.
    The objective was to be able to render a collection of items as a comma separated list. To this end, I took an existing data iterator UIComponent from richfaces, added a custom renderer -- again extending on richfaces, and hooked things up in 2 config files, as follows:
    CsvRenderer.java:
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import org.ajax4jsf.component.UIDataAdaptor;
    import org.richfaces.renderkit.AbstractRowsRenderer;
    import org.richfaces.renderkit.TableHolder;
    /** Renders a richfaces UIDataList component as a comma separated list */
    public class CsvRenderer extends AbstractRowsRenderer {
         @Override
         public void encodeOneRow(FacesContext context, TableHolder holder)     throws IOException {
              UIDataAdaptor table = holder.getTable();
              ResponseWriter writer = context.getResponseWriter();
              renderChildren(context, table);
              if(holder.getRowCounter() < table.getRowCount() - 1) {
                   writer.write(", ");
         @Override
         protected Class<? extends UIComponent> getComponentClass() {
              return org.richfaces.component.UIDataList.class;
    added to faces-config.xml:
    <render-kit>
         <render-kit-id>HTML_BASIC</render-kit-id>
         <renderer>
              <component-family>org.richfaces.DataList</component-family>
              <renderer-type>ahui.CsvRenderer</renderer-type>
              <renderer-class>com.b2international.auctionhouse.jsf.ahui.CsvRenderer</renderer-class>
         </renderer>
    </render-kit>
    added to ahui.taglib.xml:
    <tag>
         <tag-name>csv</tag-name>
         <component>
              <component-type>org.richfaces.DataList</component-type>
              <renderer-type>ahui.CsvRenderer</renderer-type>
         </component>
    </tag>
    cheers,
    Greg

    Hi all,
    After days of trial and error, i finally managed to code my own JSF component, extending existing infrastructure. Since things just suddenly fell in place during a brute force approach to make it work, i'd like to ask for opinions of seasoned JSF veterans whether this makes sense or there is a better way to do things.
    The objective was to be able to render a collection of items as a comma separated list. To this end, I took an existing data iterator UIComponent from richfaces, added a custom renderer -- again extending on richfaces, and hooked things up in 2 config files, as follows:
    CsvRenderer.java:
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import org.ajax4jsf.component.UIDataAdaptor;
    import org.richfaces.renderkit.AbstractRowsRenderer;
    import org.richfaces.renderkit.TableHolder;
    /** Renders a richfaces UIDataList component as a comma separated list */
    public class CsvRenderer extends AbstractRowsRenderer {
         @Override
         public void encodeOneRow(FacesContext context, TableHolder holder)     throws IOException {
              UIDataAdaptor table = holder.getTable();
              ResponseWriter writer = context.getResponseWriter();
              renderChildren(context, table);
              if(holder.getRowCounter() < table.getRowCount() - 1) {
                   writer.write(", ");
         @Override
         protected Class<? extends UIComponent> getComponentClass() {
              return org.richfaces.component.UIDataList.class;
    added to faces-config.xml:
    <render-kit>
         <render-kit-id>HTML_BASIC</render-kit-id>
         <renderer>
              <component-family>org.richfaces.DataList</component-family>
              <renderer-type>ahui.CsvRenderer</renderer-type>
              <renderer-class>com.b2international.auctionhouse.jsf.ahui.CsvRenderer</renderer-class>
         </renderer>
    </render-kit>
    added to ahui.taglib.xml:
    <tag>
         <tag-name>csv</tag-name>
         <component>
              <component-type>org.richfaces.DataList</component-type>
              <renderer-type>ahui.CsvRenderer</renderer-type>
         </component>
    </tag>
    cheers,
    Greg

  • Tutorial on how to create an Ajax-enabled JSF component in Creator?

    Is there a tutorial on how to create (not use/import existing) an Ajax-enabled JSF component using Creator 2? I read somewhere that it was done during a presentation in 3 minutes! Now that I really want to see ;-
    thanks,
    -nikita

    As far as I remeber, Edwin Goei's examples are the
    closest thing to the info you are looking. He has an
    example component, but don't remember if they're
    AJAX enabled. Check it on
    http://wiki.java.net/bin/view/Javatools/CustomCompone
    tLibraries.
    Best regards
    Antonio.Thanks for the plug. I've been meaning to update that article. Writing an AJAX component is similar to writing other kinds of components but the developer uses AJAX techniques. The latest version of the popup calendar which is checked into the bpcatalog project of java.net uses Dojo which also has some support for AJAX. I haven't yet had time to update the article yet, unfortunately.
    -Edwin
    http://blogs.sun.com/edwingo/

  • 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

  • Making Your Own Map Component in crystal xcelsius

    Post Author: sunbrain
    CA Forum: Xcelsius and Live Office
    http://www.liwaili.com.cn support
    http://www.liwaili.com.cn support
    http://www.liwaili.com.cn support
    Making Your Own Map Component in crystal xcelsius
    Although the Map components in Crystal Xcelsius are cool, your choice ofmaps is severely limited. This might leave you wondering how you can createyour own Map components in Crystal Xcelsius. Although there is no way totechnically make a Map component, you do have a workaround that you canuse to create interactivity based on your own maps.As an example, I created the dashboard in Figure 13-25 to report on popula-tion data for the five counties in Rhode Island. In this dashboard, movingyour mouse from county to county changes the data that displays.
    Take a closer look at this dashboard to see that the map is nothing more thanan Image component that has a few Icon Selector components on top. Hereu2019show it works:1. Import an image of the map by adding an Image component onto yourdashboard and selecting the image using the Filename property, asshown in Figure 13-26.
    2. Add Icon Selectors on each point in the map where you want interactivity.These icon selectors provide the hot spot areas on your map (seeFigure 13-27): that is, the areas that give you interactivity at run-time.
    3. Expand the selectors to ensure that you optimize the hot spots on yourmap. (See Figure 13-28.)You can expand the Icon selectors by clicking on the bounding box han-dles and dragging them until the selector is the appropriate size andshape. Expanding the size of the selectors reduces the chance of hittingdead spots that donu2019t have interactivity at run-time.
    At this point, the icon selectors can be given some functionality basedon some scenario, but thatu2019s not your focus here. The point is that afteryou configure the icon selectors with some functionality, you haveessentially added interactivity to your map.Time for smoke and mirrors.4. Make the icon selectors invisible so that only the map is showing bygoing to the Appearance tab and adjusting the Transparency propertyto 0, as shown in Figure 13-29.The final effect is a custom map that has interactivity.
    Keep in mind that you can use this technique with any image; it doesnu2019t have tobe a map per se. For instance, you can use this technique with organizationalcharts, floor plans, park maps, and various types of diagrams. Incorporatingpictures into your dashboards in this way can help you add something extrato your dashboards.
    liwaili.com.cn
    http://www.liwaili.com.cn support

    Post Author: sam pewgo
    CA Forum: Xcelsius and Live Office
    Hiit is rather disappointing that one can not import maps into crystal xcelsius as this is my main operation, the alternative approach that you so in great detail, whilst it works is not sutable for the tasks I carryout. I have access to all the maps for our operations and some are quite detailed, however I cannot use them? becuase your programme cannot import them. Is there a tool or method that you guys use to get the maps in to crystal xcelsius that you would be willing to share, as I would hate to have to find an alternative product to do that job Thnx Sam

  • 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

  • How can I include a javaScript files from within jsf component

    Is there any way using which I can include javascript files from my jsf component. Because otherwise I have to write all the javascript commands using writer.write which is very tedious rather than this I just want to include the javascript file which contains all the functions required. Also I want that this file should be included only once irrespective of the number of components included.
    Thanx in advance

    This doesn't depend on JSF. You need to include a script tag, like:
    <script src="/path/script.js"
    language="JavaScript" type="text/javascript"></script>
    If you want to include this only once, make a file included into every page, into which you can put other resources to be included along with this script.
    HTH,
    rs.

  • How to make Javascript access standard JSF component

    Hello all,
    I'm in need of a proper javascript code that access standard jsf component.
    Like we do for html tags;
    if( el.tagName.toLowerCase() != 'select')
    I need to do the same thing for a jsf tag i.e; <h:selectOneMenu>. How to make javascript access <h:selectOneMenu> like it does with <select> tag ? Please let me know asap. Extremely sorry if the question is kind of stupid....cause I'm a beginner for JSF environment.
    Any sort of help, suggestion or advice would highly be appreciated.
    Thanks in advance.

    Ummmm, I may be off the beaten path, but by the time your javascript is called the h:selectOneMenu would be a select tag within the dom. You should be able to reference that tag as you normally would.

  • JSF component inside HTML table -- not rendering properly

    I have a HTML table like the one below. In one of those columns (td) I have a JSF component. When I run the app, the JSF component (even if its a simple inputText or panelGrid or panelGroup) is not getting inside the td. Instead, it forms a seperate table after this td.
    Code I have:
    <table border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td>... ..MULTIPLE Td's here - Deleted for simplicity </td>
    <td class="topNav">
    Blog Directory
    </td>
    <td>
    <img src="./images/top_button_right.gif"/>
    </td>
    <td class="topNav">
    <f:panelGroup>
    <h:inputText value="Username"/>
    <h:inputSecret value="Password"/>
    </f:panelGroup>
    </td>
    </tr>
    </tbody>
    </table>
    What I expected:
    username, passwd field inside the top level HTML table.
    What comes: (as a result of running thsi JSF page )
    <table> -- Original table
    <td> </td> -- -TD that had the inputText - comes empty here
    </table>
    <table>
    <tbody>
    <tr>
    <td><input type="text" name="_id1:header:EasyHeader:_id4" value="Username" /><input type="password" name="_id1:header:EasyHeader:_id5" value="" /></td>
    </tr>
    <tr>
    <td><table>
    I am a newbie to JSF & due to the complexity of the layout & page, I m unable to get rid of the HTML tags totally.
    Thanks in advance.
    Ganesh

    Found the solution to the problem.
    wrapped the entire HTML page till the JSF component ( panelGrid) under <f:verbatim>.
    something like this
    <f:verbatim>
    <table>
    <tr> <td>...</td>
    <td>
    </f:verbatim>
    <h:panelGrid> ... </h:panelGrid>
    <f:verbatim>
    </td>
    </table>
    </f:verbatim>

  • Can i use one JSF component's value for other component in the same page.

    Can i use one JSF component's value for other component in the same page.
    For example
    I have a <h:selectBooleanCheckbox id="myChk"> in my jsf page, i want to access its value for another component like:
    <h:commandButton disabled="#{myChk.checked}" action="myAction" value="myValue" />
    ** "myChk.checked" >> I am just asuming "checked" property is available...

    Bind the checkbox to a UIInput myChk property. Then you can reference this property from the page, e.g.
    <h:selectBooleanCheckbox binding="#{myBean.myChk}" onchange="submit();" />
    <h:commandButton disabled="#{myBean.myChk.value}" action="myAction" value="myValue" />

  • Writing a custom component with multiple fields.

    Does anyone have some pointers on writing a custom component that properly handles multiple input fields?
    An example usage might be as follows:
    Assume the following java classes:
    public interface Address {
        //... getters/setters for Address.
    public class Company{
        Address getAddress(){...};
    }The tag usage might be something like the following:
    <custom:address value="#{myCompanyBean.address}" />
    Extending UIComponentBase I can easily render the output and create all the needed input elements. I'm also able to properly retrieve the submitted values in the decode method. But I'm unsure how to handle the "UpdateModelValues" step. Do I simply over-ride processUpdates, or is there more housekeeping to be done?
    Thanks.

    I'm guessing that doing addChild inside createChildren causes an infinite loop.
    Why aren't you just doing this with MXML?  it would be a lot simpler.

  • Relative positioning of JSF component

    Hi,
    How can I place a JSF component relative to another component, say I want to place a table below another table whose number of rows may vary.
    Thanks,
    Bob

    Have two differnt tables or use frames and place the controls(tableand button in this case) in different frames.
    <table width="100%" height="350"> -outertable
    <table .................................................><tr> any number of rows. </tr>-inner table
    </table>- - close outer
    </tr </table> - close inner
    <table> -new table
    command button
    </table> - close new table

  • Doucmentation/Guide on Writing a custom component (a DSC)

    Hello,
    I'd like to learn more about writing a custom component (a DSC), does any one know if there is documentation/guide/tutorial on how to start on it? Please share your comments.
    Thanks in advance,
    Han Dao

    Hello,
    Thank you for all replies, they are very helpful for starting to learn more about DSC.
    I do have another question, is it possible to re-write an already built-in service to customize it in a different way. e.g. The Service Operation "Read Document" in Foundation > FileUtilsService to accept a different type of its Input?
    Thanks,
    Han Dao

  • Setting focus to a jsf component inside a tab.

    Hi,
    How can I set focus to a jsf component that is placed on some tab other then the first. Suppose that on the 2nd tabitem of the tab. there are some components on this tab . How can I set the focus to any one of these components on tabitem2 when the jsf page is opened.
    Any ideas..
    Thanks in advance..

    Use Javascript.var el = document.getElementById('elementId');
    if (el && el.focus) {
        el.focus();
    }

Maybe you are looking for

  • How to load data in a oracle-datapump table ...

    I have done following steps, 1) I have created a external table locating a .csv file CREATE TABLE TB1 ( COLLECTED_TIME VARCHAR2(8) ORGANIZATION EXTERNAL( TYPE oracle_loader DEFAULT DIRECTORY SRC_DIR ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE BA

  • How to hide WebI report in infoview

    Hi, I have created a sub-report which opens when user clicks on hyperlink in main report. To get it to work, I uploaded both reports to Infoview. Now both of the reports are showing so a user could potential run the sub-report first which I don't wan

  • Internet explorer opens a new window when using firefox

    When using Firefox, Internet explorer sometimes opens the same website or opens up a pop up advertisement. == This happened == A few times a week == Noticed it for the last week or so

  • Can you sort bookmarks?

    Half my bookmark list is sorted alpha by the bookmark name, and half is not (the most recent additions).  Is there a way to sort all? Thanks

  • Rescue and Recovery 4.3 on Win7 doesn't see a backup on external USB hard drive - Model W510

    I've run the Rescue and Recovery utility within Windows 7 on two different external USB hard drives thinking that maybe it was a usb drive issue.  When I open the R And R utility in expert mode I can see that both backups exist on their respective dr