Required not working with SelectOneRadio in 3.0.M4

UI Components for JSF
Post Reply
rubus
Posts: 517
Joined: 01 Oct 2010, 09:41
Location: Belgium

28 Nov 2011, 11:45

Hi,

I have a <p:selectOneRadio> where the user needs to select one of the proposed values defined by the <f:selectItems>. However, adding the attribute required="true" doesn't trigger a validation error.

<p:selectOneRadio value="#{simulator.simulationData.investmentPortfolio}"
id="investmentPortfolio" required="true" requiredMessage="#{messages.error_portfolio_required}"
layout="pageDirection">
<f:selectItems value="#{data.investmentPortfolioList}" var="investmentPortfolio"
itemLabel="#{e:retrieveLabel(investmentPortfolio)}"
itemValue="#{investmentPortfolio}"/>
</p:selectOneRadio>

When the users submits the page with the above tag on, the error message error_portfolio_required isn't shown.

The problem is situated in the method org.primefaces.component.selectoneradio.SelectOneRadioRenderer#decode where the value null is set when no selection is made.

Later on, the validation isn't performed because the value of the component is null.

The method org.primefaces.component.selectoneradio.SelectOneRadioRenderer#decode should place an empty string ("") when it doesn't find the data in the request map.

Workaround:
Extend the renderer and fix the decode method. This new renderer then needs to be registered in faces config file.

Best regards,

Rudy De Busscher
http://www.c4j.be
PrimeFaces version 3.5, Tomcat 7, Mojarra 2.1.13
PrimeFaces version 4.0, Glassfish 4.0
PrimeFaces version 5.0, WLS 12.1.2
If you haven't read the forum rules read them now : viewtopic.php?f=3&t=1194

cebatista
Posts: 1
Joined: 05 Dec 2011, 14:04

05 Dec 2011, 14:18

Rubu,

Can you post the code about the solutions that you found?

The workaround that I did to solve immediately, I change the component from p:selectOneRadio to h:selectOneRadio.

thanks!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests