Ignacio
Ignacio

Reputation: 131

Passing argument to Resource file in o:validateOrder OmniFaces 2.0

Hi I'm developing and application with:

.JSF 2.1 .OmniFaces 2.0

I have a resource file with placeholder

comun.abm.fecha.factura.menor.ultimo.comprobante=La fecha de la Factura tiene que ser mayor o igual a la ultima fecha de emision del ultimo comprobante: {0}

and I have this validation:

<h:outputLabel value="#{msgs['facturacion.abm.generacion.padron.fecha.factura']}" 
               for="fechaFactura"/>

<rich:calendar
    id="fechaFactura"
    datePattern="dd/MM/yyyy"
    showWeeksBar="false"
    enableManualInput="true"
    value="#{generacionPadronController.padronBean.fechaFactura}" />

<h:panelGroup>
    <rich:message for="fechaFactura"/>

    <o:outputFormat value="#{msgs['comun.abm.fecha.factura.menor.ultimo.comprobante']}" 
                    var="_validacion">
        <f:param value="#{generacionPadronController.fechaEmisionComprobanteUltima}" />
    </o:outputFormat>

    <o:validateOrder id="validacionFechaFacturaMayorAFechaEmisionUltimoComprobante"
                     type="lte"
                     components="fechaFactura fechaEmisionComprobanteUltima"
                     message="#{_validacion}"
                     showMessageFor="fechaFactura">
    </o:validateOrder>
</h:panelGroup>

the validation works and send me empty message probably because the variable doesnt have a value, any other idea to accomplish this (passing argument to a bundle with o:validateOrder).

PD: I print the #{_validacion} and works ok in the page, but is empty when the validation is fired.

Upvotes: 2

Views: 64

Answers (1)

BalusC
BalusC

Reputation: 1109222

The <o:outputFormat var> is set during render response phase. However, the <o:validateXxx message> is evaluated during validations phase, which is too early.

Better use #{of:format1()} function instead.

<o:validateOrder id="validacionFechaFacturaMayorAFechaEmisionUltimoComprobante"
                 type="lte"
                 components="fechaFactura fechaEmisionComprobanteUltima"
                 message="#{of:format1(msgs['comun.abm.fecha.factura.menor.ultimo.comprobante'], generacionPadronController.fechaEmisionComprobanteUltima)}"
                 showMessageFor="fechaFactura">
</o:validateOrder>

Upvotes: 2

Related Questions