Even though my example wrapped the element, it should work the same if
it wasn't wrapping the element.
<!-- start externally generated content -->
<input id="bbb" name="bbb" type="text" value=""/>
<!-- end externally generated content -->
<my:customComponent forInputId="bbb"/>
The key is to associate the id in your external element to your jsf
component. Wrapping them just makes it obvious that the id is in the
same location/namespace.
In fact, you can probably just use id="bbb" for both. The jsf tag
won't appear in the generated output.
<my:customComponent id="bbb">
<!-- start externally generated content -->
<input id="bbb" name="bbb" type="text" value=""/>
<!-- end externally generated content -->
</my:customComponent>
As for what component to extend, I guess that would depend on what you're doing.
It could be as simple as specifying a custom renderer for an existing
component that didn't render anything.
Ie, if I were using something that generated an external hidden input,
<input id="form:hidden1" name="form:hidden1" type="hidden"
value="Hidden Value"/>
I might simply create
<my:nonRenderingInputHidden id="hidden1" value="#{myBean.hiddenValue}" />
Do note that your JSF generated ids will be nested inside any jsf
container ids, like h:form.
I can't teach you how to write an component from scratch, but this
example gives a good start on replacing a renderer. Your replacement
class would be much more trivial.
https://blueprints.dev.java.net/bpcatalog/ee5/ajax/extendingRenderFunctionality.html
faces-config.xml
<render-kit>
<renderer>
<description>
Renderer for ajax fileupload component
</description>
<component-family>javax.faces.Form</component-family>
<renderer-type>FileUploadForm</renderer-type>
<renderer-class>com.sun.javaee.blueprints.components.ui.fileupload.FileUploadRenderer</renderer-class>
</renderer>
</render-kit>
On Tue, Sep 15, 2009 at 9:25 AM, Dvora <[email protected]> wrote:
>
> That was fast :-)
>
> I'm doing my first steps in JSF, can you please add some details regarding
> the implementation? Which component should I extends? How do I make that
> this custom component will read the wrapped element ('bbb' in the example)?
>
> Thanks for your help!
>
>
> Mike Kienenberger wrote:
>>
>> You can probably make that work, but it may take a little effort. Jsf
>> Rendering (generating of html) is independent of form value
>> processing.
>>
>> You could create a jsf component that didn't output any tags in the
>> rendering stage but still worked with the submitted values of the
>> externally-generated html inputs, so long as you could somehow
>> associate the clientId of the component with the actual id generated
>> by the external content.
>>
>> Probably would look something like this on your page template:
>>
>> <my:customComponent forInputId="bbb">
>> <!-- start externally generated content -->
>> <input id="bbb" name="bbb" type="text" value=""/>
>> <!-- end externally generated content -->
>> </my:customComponent>
>>
>
> --
> View this message in context:
> http://www.nabble.com/MyFaces---can-backing-beans-access-native-html-elements--tp25453164p25454002.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>