>From: "Hasan Turksoy" <[EMAIL PROTECTED]> > > hi, > > i have a problem about using commons-validator(CV) with selectmanylistbox of > my JSF pages'.. the problem is; CV trying to convert my listboxes' value(an > Array of objects) to string to make a required validation... And it throws > below exception; > > javax.faces.ServletException: "You have requested a conversion for type [ > Lmy.app.CarType;, but there is no by-type converter registered for this > type" > > as you can understand from exception, it's trying to find a converter for > the "array of my.app.CarType".. and couldn't find as expected... > > however, instead of looking directly for a converter of the coming value's > type, ConverterHelper class should control the coming value's being > array/list condition and if so; traverse that array/list and convert each > element of it separately... In JSF RI, MenuRenderer class( > com.sun.faces.renderkit.html_basic.MenuRenderer) is working as this way > while converting coming array/list values to string or object... > > what do you think about this issue... i think this is an issue (and may be i > should enter it on shale-JIRA)... But is there any other solution? or > anybody used required validator with h:selectManyListBox component? >
The server-side "required" commons validator rule is kind of bogus. I've only seen it useful for client side validation. This is because JSF requires a value before it will even invoke the server side validation logic. A component's validator will not be invoked if the component doesn't have a value. There is a separate "required" attribute for components that are EditableValueHolders. The shale ValidatorScript component, that must be added at the end of the page, looks through the component tree and toggles on the required attribute for components that include the shale commons validator required server side rule. So, the ValidatorScript component is needed even if you are only using sever side rules. > my usage is as below; > ><h:selectManyListbox value="#{myPageCode.selectedCarTypesArray}" ...> > <f:selectItems value="#{myPageCode.carTypesList}"></f:selectItems> > <s:commonsvalidator type="required" ... /> ></h:selectManyListbox> > > > regards, > > hasan... Gary