Saturday, January 24, 2009

How to generate a forced unique id in JSF

In JSF (Java Server Faces), we may face a scenario where we have to refer a element like textarea or input text box by unique id (as an example use document.getElementById in Javascript).

But as JSF has its own convention of generating ids, the id cannot be determined unless we use forceId="true" as an attribute as in the example below
 <h:inputTextarea id="questiondesc" forceId="true"  ....more attributes here

As this text area is within a form whose id is qtype
<h:form name="qtype" id="qtype" enctype="multipart/form-data">
we have to refer it in JavaScript as below.
var tarea=document.getElementById("qtype:questiondesc");

Tuesday, December 9, 2008

How to specify multiple URL pattern for Seam web:context-filter

To specify multiple URL patterns for web context filter in JBoss Seam, in components.xml we specify an entry as below

<web:context-filter regex-url-pattern="/services/*|/testng"/>

Please note that we are using regex-url-pattern. In the above example, CXF (web service) servlet listens at /services/* and a custom servlet (that runs in-container TestNG test cases) listens at /testng.