Validation Error - JSF Custom Component

I am trying to create a Custom Component. It is a pre-populated list of selection items. So all that the page author would have to do is use a tag like
<jsfcust:mySelectOneComponent  value="#{requestScope.selectedItem}/>and this should display a drop-down list from which only one item can be selected. I got this working except for the final stretch.
I created the following...
1. tag in the .tld file
2. CustSelectOneTag.java (set the value as a ValueBinding in setProperties() method)
3. CustSelectComponent.java
4. CustSelectRenderer.java (In the decode() method, called setSubmittedValue(value) on the component)
5. updated the faces-config.xml file
The display seems to be working fine. The problem is when I click on a Submit button and go to the next page where I want to display the selected value. It shows up as null. All that I want to do is be able to select an item from the custom drop down and display it in the next page after hitting submit.
What is the proper way to send the value back in the response? In my case, I was merely trying to pass the value so that the next page can access it from the request scope and display it.
I was not sure if I had to implement the getConvertedValue() method in my renderer. Can someone help?
Thanks,
JM

Thanks for your reply! Your answer fixed my problems, so definitely thanks! I need to use escaped values for things like "<,&,#, etc", like the pound "amp" semicolon stuff. If I try to type out strings like these the forum unescapes them - fun part of posting forum questions about HTML escaping on HTML-based forums! :) I didn't realize an escaped querystring would still work as expected in a <a href ... />. You actually fixed both of my problems, and I... I do feel appropriately foolish now :) Had a feeling this might be a slaps forehead one. Thanks for the quick answer!,
Jim

Similar Messages

  • Can't instantiate JSF Custom Component

    I'm hoping some of you expert (or at least seasoned) JSF custom component developers might be able to lend some insight into the "Can't instantiate class" problem. I have a custom component which extends another component (which happens to be Oracle ADF's panelGroup), and I've verified that everything is in place:
    1. Component class uses correct component type referenced by faces-config.xml and tag class
    2. Renderer type referenced in faces-config.xml matches that of the renderer type in component class
    3. There is a default constructor (no args) for the component class, which also sets the renderer type
    4. TLD with tag is correct
    All classes are definitely in the classpath, as I have another custom component in the same packages which loads and is used just fine.
    Any ideas would be appreciated.
    Thanks,
    Shawn Bertrand
    Tyco Electronics

    So, is no one else having any problems when using the new JSF components from Java Studio Creator 2 in their existing projects? I can make simple projects in Creator and run them on PointBase and Tomcat and can deploy and run from Eclipse using MyEclipse but I cannot get my existing project working and I am wondering if their is some sort of conflict between the new JSF components and legacy Struts stuff in that project or if perhaps Spring is someone interferering. Kind of at a loss right now...

  • Jsf custom component issue

    I am creating a custom component and extending the renderer like the following. My custon component is similar to h:messages but inaddition to that it has hyperlink(clicking error focuses individual input box). I have extended the renderer as follows, every thing works fine but the problem is the form gets null or looses its all value when error occured, however the component works fine. I dont know why is that hapening.
    Any help would be highly appreciated.
    public class CustomErrorRenderer extends Renderer {
    @Override
    public void encodeEnd(FacesContext context,
    UIComponent component) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    writer.startElement("div", component);
    writer.writeAttribute("id", component.getClientId(context), "id");
    writer.writeAttribute("style", "color: red", null);
    writer.startElement("ul", null);
    Iterator<String> clientIds = context.getClientIdsWithMessages();
    while (clientIds.hasNext()) {
    String clientId = clientIds.next();
    Iterator<FacesMessage> messages = context.getMessages(clientId);
    if (!messages.hasNext()) { continue; }
    String javaScript = "var field = document.getElementById('"
    +clientId+ "');" +"if(field == null) return false;"+
    "field.focus(); return false;";
    writer.startElement("li", null);
    writer.startElement("a", null);
    writer.writeAttribute("onclick", javaScript, null);
    writer.writeAttribute("href", "#", null);
    while (messages.hasNext()) {
    writer.writeText(messages.next().getSummary(), null);
    writer.endElement("a");
    writer.endElement("li");
    writer.endElement("ul");
    writer.endElement("div");
    }

    The problem is, the form values that are tied to input boxes are null once validation error occurs.
    I think when I am overriding that encodeEnd, this is causing the problem for the form values getting null.
    IF I want to see, what are the submitted values then isn't this the way, I am getting null here also:
              FacesContext context = FacesContext.getCurrentInstance();     
                  UIViewRoot viewRoot= context.getViewRoot();
                 HtmlInputText input = (HtmlInputText)viewRoot.findComponent("formId:InputboxId");
              System.out.println("input  sub value" + input.getSubmittedValue());

  • Custom Validator for a Custom Component

    I am having troubling passing values from my custom component
    to my custom validator (via a model). For some reason when the
    validate() function is called for the validator the value parameter
    passed to the validator is not showing the value from my custom
    component.
    I have attached some example code to illustrate.
    Here is my model:
    <mx:Model id="myModel">
    <root>
    <mod>
    <name>{myTextInput.text}</name>
    <date>{myDateField.selectedDate.getTime()}</date>
    <length>{myComp.getLength()}</length>
    </mod>
    </root>
    </mx:Model>
    When I update the value of myTextInput or myDateField the
    model (as sent to the validator) shows the correct value. When I
    change the value of myComp the change is not reflected.
    Is there a particular event (or something) being dispatched
    in the other components to cause the model to get the new value
    that I need to include in my custom component? I am pretty stuck
    and would appreciate any help.
    Many thanks

    Does myComp extend EventDispatcher (or any class which does)?
    You need to flag the getLength() function as bindable and to
    dispatch an event:
    [Bindable('getLengthChange")]
    public function getLength() : Number
    // does whatever it does
    When you update myComp have it dispatchEvent( new
    Event("getLengthChange") ) and I think it will work.

  • JSF custom component

    Hi
    I have created a JSF cutom component , which has some javascript files. If i use the component within the same project my path for accessing the JS files is :- js/task.js (Its in public/html folder) .
    My problem is that when I use this custom component in some other project i am not able to access the js file ( Js file are deployed with other source file in ADF Library Jar) . As I have to hard code the path of JS files in the render can any one please tell me what will be the path for accessing the JS files.
    i heard ADFLibraryFilter is used for the purpose. Anyone please shed more light on it.

    Thanx Frank for your help .
    I am generating html from the rendererm, in the encodeBegin method i have now written <script type="text/javascript" src="adflibResources/js/task.js"></script>
    But still the script isn't loading on the page
    I added the following code in web.xml but Jdeveloper (Studio Edition Version 11.1.1.1.0) is complaining that "refernce oracle.adf.library.webapp.LibraryFilter and oracle.adf.library.webapp.ResourceServlet not found. I am using Fusion Web Application (ADF) as the application template.
    <filter>
    <filter-name>ADFLibraryFilter</filter-name>
    <filter-class>oracle.adf.library.webapp.LibraryFilter</filter-class>
    <init-param>
    <param-name>provider-lazy-inited</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>ADFLibraryFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <servlet>
    <servlet-name>adflibResources</servlet-name>
    <servlet-class>oracle.adf.library.webapp.ResourceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>adflibResources</servlet-name>
    <url-pattern>/adflib/*</url-pattern>
    </servlet-mapping>

  • JSF Custom component for table pagination and sorting

    hi
    i want such a custom component that render a table and table has the features of pagination and column sorting.
    any one know from where i can get such a custom component.
    (if this component is available with source then it would be more help full for me)
    thnks & regards,
    Haroon
    Message was edited by:
    HaroonAnwarPADHYAR

    I know two companies that offer JSF component for table pagination and sorting and AJAX based :
    http://www.teamdev.com/quipukit/demo/datatable/DataTable_filteringAndPaging.jsf
    http://java.samples.infragistics.com/NetAdvantage/JSF/2006.1/
    The problem? They are not open source..
    And I am too looking forward on this subject, because I want to develop my own custom component and add some features. If someone has any tips, references or samples of their own, it would be really appreciated.
    Thank you.
    Paul

  • 1st jsf custom component.. getting nullpointer Ex, what's wrong?

    hi guys
    I'm following this ex to create a custom component
    http://today.java.net/pub/a/today/2004/07/16/jsfcustom.html
    but I'm having problems like
    java.lang.NullPointerException
         at javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:929)
         at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:310)
         at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:70)
         at org.apache.jsp.Simple_jsp._jspx_meth_f_view_0(org.apache.jsp.Simple_jsp:114)
         at org.apache.jsp.Simple_jsp._jspService(org.apache.jsp.Simple_jsp:89)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:477)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:371)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
         at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
         at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
         at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
         at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
         at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
         at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
         at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
         at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
         at org.mortbay.jetty.Server.handle(Server.java:313)
         at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
         at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
         at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
         at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)do you know what's the problem
    thanks ;)

    hi guys
    I'm following this ex to create a custom component
    http://today.java.net/pub/a/today/2004/07/16/jsfcustom.html
    but I'm having problems like
    java.lang.NullPointerException
         at javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:929)
         at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:310)
         at org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:70)
         at org.apache.jsp.Simple_jsp._jspx_meth_f_view_0(org.apache.jsp.Simple_jsp:114)
         at org.apache.jsp.Simple_jsp._jspService(org.apache.jsp.Simple_jsp:89)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:477)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:371)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
         at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
         at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
         at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
         at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
         at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
         at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
         at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
         at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
         at org.mortbay.jetty.Server.handle(Server.java:313)
         at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
         at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
         at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
         at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)do you know what's the problem
    thanks ;)

  • JSF custom component: value not binding to component

    I have a custom UIInput component which is not able to bind to the value of the component from a backing bean. Here is the JSF code snippet:
    <tw:validateInputText id="locationIdStopInput" table="location" column="location" styleClass="wideSingleInput" value="#{currentStop.customer.customer}" rendered="#{loadTypeView.renderWarehouse or (currentStop.stopNumber gt 1 and loadTypeView.renderOutbound) or (currentStop.stopNumber eq 1 and loadTypeView.renderInbound)}"/>
    tw is the custom tag and validateInputText is the custom UiInput component.
    On posting the form the decode method is not able to get the value from the requestParameter map. Following is the decode() I wrote:
    public void decode(FacesContext context,
    UIComponent component) {
    // assertValidInput(context, component);
    if (context == null || component == null) {
    throw new NullPointerException();
    ValidateInputTextComponent map = (ValidateInputTextComponent) component;
    String key = map.getId();
    if (component instanceof UIInput) {
    UIInput input = (UIInput) component;
    String clientId = input
    .getClientId(context);
    Map requestMap = context
    .getExternalContext()
    .getRequestParameterMap();
    String newValue = (String) requestMap
    .get(clientId);
    if (null != newValue) {
    input.setSubmittedValue(newValue);
    Also providing the setProperties() from the custom tag class:
    protected void setProperties(UIComponent component){
    super.setProperties(component);
    if (getValue()!=null){
    if (isValueReference(getValue())){
    ValueBinding vbTarget = FacesContext.getCurrentInstance().getApplication().
    createValueBinding(getValue());
    component.setValueBinding(VB_VALUE, vbTarget);
    System.out.println(component.getValueBinding("value").getValue(FacesContext.getCurrentInstance()));
    } else{
    ((UIInput) component).setValue(value);
    // component.getAttributes().put("value",getValue());
    if (getCompValue()!=null){
    if (isValueReference(getCompValue())){
    ValueBinding vbCompTarget = FacesContext.getCurrentInstance().getApplication().
    createValueBinding(getCompValue());
    component.setValueBinding(VB_COMPONENT_VALUE, vbCompTarget);
    } else{
    // ((UIInput) component).setValue(compValue);
    component.getAttributes().put(VB_COMPONENT_VALUE,getCompValue());
    if (getTable() != null && isValueReference(getTable())){
    ValueBinding vbTable = FacesContext.getCurrentInstance().getApplication().
    createValueBinding(getTable());
    component.setValueBinding(VB_TABLE, vbTable);
    } else{
    component.getAttributes().put(VB_TABLE, getTable());
    if (getColumn() != null && isValueReference(getColumn())){
    ValueBinding vbColumn = FacesContext.getCurrentInstance().getApplication().
    createValueBinding(getColumn());
    component.setValueBinding(VB_COLUMN, vbColumn);
    } else{
    component.getAttributes().put(VB_COLUMN,getColumn());
    if (getStyleClass() != null && isValueReference(getStyleClass())){
    ValueBinding vbClass = FacesContext.getCurrentInstance().getApplication().
    createValueBinding(getStyleClass());
    component.setValueBinding(VB_STYLE_CLASS, vbClass);
    } else{
    component.getAttributes().put(VB_STYLE_CLASS, getStyleClass());
    if(getRendered() != null && isValueReference(getRendered())){
    ValueBinding vbRendered = FacesContext.getCurrentInstance().getApplication().
    createValueBinding(getRendered());
    component.setValueBinding(VB_RENDERED, vbRendered);
    } else{
    Boolean a = new Boolean(getRendered());
    component.getAttributes().put(VB_RENDERED, new Boolean(getRendered()));
    Please let me know If I am missing something here to retrieve the value from the component.
    Thanks

    See this tutorial:
    http://www.jsftutorials.net/components/index.html

  • JSF-Custom Component with EventHandling

    Dear All,
    I wanted to write my own component with event handling.
    This is my requirement:
    In my JSP, I'll put my cusom component tag for displaying 10 records and with prev and next buttons. after clicking prev button, i should get previouse 10 records and if i click next button, i should get next 10 records.
    so, my component should render
    1. 10 records
    2. Prev button
    3. Next button.
    After clicking prev button it should render previouse 10 records and also prev and next button.
    I do not know whether it is possible with JSF or not and also i'm not finding any example which explaining above situation.
    My jsp should contain only my custom tag like
    <mine:listRecords/>
    Tag Handler of listRecords tag should render 10 records and prev and also next button. After clicking prev, i should get 10 previouse records and and both the buttons and so on.
    advanced thanks,
    ram

    It is certainly possible to write a component that embeds its own navigation and paging as you describe. On the other hand, you can also assemble this kind of functionality out of a combination of the existing simple components. The "repeater" example illustrates exactly the kind of application you are talking about (and the same techniques will work fine with the standard <h:dataTable> component as well).
    Craig

  • JSF custom component: repear child components

    I want to create something like this
    <custom:mycomp var="item" value="#{aBean.TheArrayList}">
    ___<f:facet name="child">
    ______<h:commandLink actionListener="#{item.doSomething}">
    _________<h:ouputText value="#{item.name}"/>
    ______</h:commandLink>
    ___</f:facet>
    </custom:mycomp>
    I know how to make a basic component with encodebegin and encodeend. But how can I make it repeat the facet for every object in the arraylist?

    Create a custom ActionListener, implementing javax.faces.event.ActionListener, and calling it like this:
    <h:commandButton action="doThis" value="Do This">
         <f:actionListener type="my.package.MyActionListener" />
    </h:commandButton>When the button is pressed, the processAction() method of MyActionListener is automatically executed.
    Maybe this wasn't what you were looking for?
    Edited by: bjornie on Aug 5, 2008 2:50 AM

  • Nesting JSF components in a  custom component

    I'm creating a new JSF custom component. my component needs to include an input text and a list box. my question is : how do I add these components to my JSF component ? I want to use to JSF component to render them rather then encoding the HTML myself. how can I do it ?
    I was told I need to use encodeChildren method somehow but I don't know how ?

    I finally found how to set a default skin to a custom component so that users of my component will not have to set again the skinClass value of my component.
    You have to create a defaults.css file at the root of your library and tell the compiler to take it into account.
    The remaining problem is about the compiler. There are some steps before success and they are a bit mysterious/unclear....
    I found 2 or 3 blog articles explaining those steps but the compiler arguments to use are all differents in each article...
    Here are the links I found:
    http://www.unitedmindset.com/jonbcampos/2010/05/12/creating-custom-spark-components/
    http://www.betadesigns.co.uk/Blog/2010/05/14/default-skin-for-custom-flashbuilder-componen ts/
    http://flexdevtips.blogspot.com/2009/06/default-stylesheet-in-swc-flex-library.html
    Following the first article guidelines has been successful for me but I'm not marking this topic as Resolved because I'd like some answers about this whole thing...

  • Validations in JSF

    Hi All,
    I have 4 input fields in my JSP. Atleast one is required and not all are mandatory. So i have added a hidden input field and written a custom validator that is called for every submit.
    For a particular field, i have a validation for numbers. I do this using the Shale validator's "mask". And in the custom component i validate for zeroes.
    Now if i give the input as "aaaaaaa", then the error message from "mask" is displayed. If i now enter "0000000", then the validation message from custom component is displayed. Now after this, if i enter "aaaaaaa", it shows both messages.
    the reason is that i have used UIInput.getValue() in my custom component. The getValue() is "0000000" and UIInput.getSubmittedValue() is "aaaaaaa". Why is the previous input retained?
    Can someone provide a solution?

    abhi004 wrote:
    I tried using the attribute readonly="true", but I am losing the data held by these fields from the corresponding bean when I click submit.Then there's a bug somewhere. This behaviour (losing value) should only occur when you used the disabled attribute. The readonly attribute should still send the value to the server side.

  • JSF custom renderer executes multiple times

    I have just created a jsf custom component to render three input texts next to each other (for SSN input). My custom renderer extends javax.faces.render.Renderer, and I am writing out the elements in the encodeEnd method. The problem I encountered is - upon saving the form and the screen refreshes, the renderer gets called two times. So what I end up seeing on the screen are two sets of the three input texts component. Does anyone know why the renderer gets called more than once? Any insight is much appreciated.

    To the best of my knowledge, the standard does not specify the default renderer class for any components.
    I would take a wrapper/decorator approach. Add a field to your renderer for the default renderer. Before configuring your renderer, obtain the default renderer and set it on your renderer, then configure it.
    OTOH, there might be easier ways for you to accomplish what you want to do. You could use a PhaseListener to add components to the view whenever a commandButton is encountered in the tree.

  • JSF, NetBeans and customizing of Standard Validation Errors

    Hello together,
    i want to use german Standard Validation Errors via a own .properties File:
    1.
    Here is my faces-config.xml ( the entries are uncommented ! ):
    <faces-config>
    <application>
    <locale-config>
    <default-locale>de</default-locale>
    <supported-locale>de</supported-locale>
    <supported-locale>en</supported-locale>
    </locale-config>
    *<message-bundle>alles.mymessages</message-bundle>*
    </application>
    </faces-config>
    2.
    Here is mymessages.properties-File in package alles:
    javax.faces.validator.NOT_IN_RANGE=Das angegebene Attribut liegt nicht zwischen den erwarteten Werten {0} und {1}.
    javax.faces.validator.NOT_IN_RANGE_detail="{2}"\:Eingegebener Wert liegt nicht im erwarteten Bereich von {0} bis {1}.
    javax.faces.validator.LongRangeValidator.LIMIT=Validierungsfehler
    javax.faces.validator.LongRangeValidator.LIMIT_detail=Eingegebener Wert kann nicht in den korrekten Typ umgewandelt werden.
    javax.faces.validator.LongRangeValidator.MAXIMUM=Validierungsfehler
    javax.faces.validator.LongRangeValidator.MAXIMUM_detail="{1}"\:Wert ist gr\u00F6\u00DFer als das erlaubte Maximum"{0}".
    3.
    Here the part of the JSF-View with the Validator:
    <ui:textField binding="#{WorkTypeEdit.textFieldBeschartKzSoll}" converter="#{WorkTypeEdit.bigIntegerConverter1}"
    id="textFieldBeschartKzSoll" required="true" style="height: 24px; width: 48px" validator="#{WorkTypeEdit.longRangeValidator1.validate}"/>
    The application still shows the standard englisch validation error text. What is wrong here ?
    I' am using NetBeans 5.5.1 with VWP and the deploment is to Glassfish server.
    Thanks a lot.
    HJA

    Hello Raymond,
    i did some coding and create additional a custom validator:
    My JSF-View part:
    <ui:textField binding="#{WorkTypeEdit.textFieldBeschartKzSoll}" converter="#{WorkTypeEdit.integerConverter1}"
    id="textFieldBeschartKzSoll" maxLength="2" required="true" style="height: 24px; width: 48px" *validator="#{MyValidation.validateInput}">*
    *<f:validateLongRange minimum="1" maximum="9"></f:validateLongRange>*
    </ui:textField>
    My custom validator in Myvalidation class:
    public void validateInput (FacesContext facescontext, UIComponent component, Object value) throws ValidatorException
    long min = 0, max = 0;
    Locale locale = facescontext.getViewRoot ().getLocale ();
    String mb = facescontext.getApplication ().getMessageBundle ();
    ResourceBundle rb = ResourceBundle.getBundle (mb, locale);
    Validator[] validator = ((UIInput) component).getValidators ();
    for (int i=0; i < validator.length; i++)
    if (validator[i] instanceof LongRangeValidator)
    LongRangeValidator lv = (LongRangeValidator) validator;
    long lvalue = Long.valueOf ((String)value.toString ());
    min = lv.getMinimum ();
    max = lv.getMaximum ();
    if (lvalue < min || lvalue > max)
    ((UIInput) component).setValid (false);
    *String message = rb.getString ("javax.faces.validator.NOT_IN_RANGE");*
    *String messageDetail = rb.getString ("javax.faces.validator.NOT_IN_RANGE_detail");*
    *facescontext.addMessage (component.getClientId (facescontext), new FacesMessage (FacesMessage.SEVERITY_ERROR,message,messageDetail));* }
    What happen now is, at first i get the german message because of rb.getString........ so the locale is working
    and then the englisch message follows in the message component.
    Sorry that i take your time so long...
    HJA

  • Validation error message in JSF 1.2

    I am testing my Web application inside Tomcat 6.0.2 and using JSF 1.2. I was surprised to see that validation error messages do not only display the custom error message, but also the id tag and a "Validation Error: " text. For instance, if an input text component has the required property set to true and the user does not fill in value, the following error message will be displayed on page submiision: "hello:test: Validation Error: Value is required." instead of just "Value is required.". I am wondering if there is a way to silence the id tag and the "Validation Error: " text. hello:test id tag reflects the fact that the form has an id of "hello" and the input text component an id equal to "test".

    Hello
    I'm quite new to this technology. Would like to know how can we replace the 'annoying component id' with label while generationg validation/conversion error message.
    E.g:
    'for:compID' some error message
    must be formated as
    'compLabel' some error message
    I happened to know that this feature is supported in JSF 1.2 impl. But didn't work for me with Sun RI.Can any body give me some sample code snippet for the same
    Thanks
    Jobinesh

Maybe you are looking for