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?
Java EE

Avatar of undefined
Last Comment
bpmurray
Avatar of Mayank S
Mayank S
Flag of India image

Do you know JSF? www.jsftutorials.net
Avatar of bpmurray
bpmurray
Flag of Ireland image

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?

Avatar of abstractionz
abstractionz

ASKER

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

var myform:fromDate
Avatar of bpmurray
bpmurray
Flag of Ireland image

That's a completely legitimate ID - you should fix your JavaScript.
Avatar of abstractionz
abstractionz

ASKER

var myform:fromDate = 6;
alert(myform:fromDate);

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Java EE
Java EE

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

18K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo