Link to home
Start Free TrialLog in
Avatar of abstractionz
abstractionz

asked on

Creating a custom JSF component

I have a javascript editable combobox. I would like to make it into a JSF component. I am not sure where to begin. It is basically a dropdown menu, where the user can select one option, or type in anything they want. So the selected choice, or the user input is posted. It's a combination of a textbox and a menu. Is it possible to create a jsf component that just renders the javascript which i already have?
Avatar of Mayank S
Mayank S
Flag of India image

Do you know JSF? www.jsftutorials.net
Easy enough. You need to create four things:
1. A renderer. This simply spits out the appropriate javascript and associated HTML field(s)
2. A JSP Tag that allows you to embed it in the page
3. A faces-config.xml that describes the new widget
4. A concrete component class.

Actually, have a look at the standard Select widgets. You can have your selectable values as selectItem/selectItems, your component is the standard UISelect component, and all you need is a tweaked renderer - you can base it on the selectOne or selectMany renderer. If your items are encoded in a special way, then set your renderer's getRendersChildren to return true and iterate over the children.
Avatar of abstractionz
abstractionz

ASKER

Hi bpmurray,

I followed your steps and got the javascript to render.  However, the colon stuck in the id is causing a javascript warning.  I dont suppose there is anyway around that other than modifying all my javascript...

How could I tweak a renderer to allow the user to make a UISelect editable?

My javascript has to use the clientId as a variable name, but the colon messes it up:

var myform:fromDate
That's a completely legitimate ID - you should fix your JavaScript.
var myform:fromDate = 6;
alert(myform:fromDate);

would not work
ASKER CERTIFIED SOLUTION
Avatar of bpmurray
bpmurray
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial