jeff
jeff

Reputation: 3732

Omnifaces validateOrder BigDecimal cannot be cast to String when using p:ajax on two panel groups

EDIT How do I use o:validateOrder and p:ajax with two inputs not in the same panelGroup?

ORIGINAL

I'm getting java.math.BigDecimal cannot be cast to java.lang.String using Omnifaces o:validateOrder, but only for the case where I have my inputs over two panel groups and p:ajax processes two inputs. I am using two separate panel groups only for GUI layout. Debugging during o:validateOrder, the comparableValues array has one value as BigDecimal and the other as a string.

But when I have ajax process a single panelGroup that wraps both inputs(say p:ajax process="bothLengthsPanelGroup") things work and the comparableValues array has both values as BigDecimals. But the GUI is doesn't have the layout I want. How can I keep my formatting but have p:ajax pass in BigDecimals?

<h:panelGrid columns="2">    
 <h:panelGroup id="nlength">
    <p:outputLabel value="Bolt Length" />
    <h:panelGrid columns="3">
        <h:outputLabel value="nominal:" />
        <p:inputText size="1" id="bolt_length" value="#{cc.attrs.bolt.nominal_fastener_length}">
            <p:ajax process="tlength nlength" update="nlength tlength boltFeedback" />
        </p:inputText>
  </h:panelGrid>
     <o:validateOrder type="gt" components="bolt_length thread_length" message="Nominal Thread Length must not exceed Nominal Bolt Length" disabled="#{empty cc.attrs.bolt.nominal_fastener_length and empty cc.attrs.bolt.nominal_thread_length}" />
 </h:panelGroup>

 <h:panelGroup id="tlength">
   <p:outputLabel value="Thread Length" />
    <h:panelGrid columns="3">
        <h:outputLabel value="nominal:" />
        <p:inputText size="1" id="thread_length" value="#{cc.attrs.bolt.nominal_thread_length}">
            <p:ajax process="tlength nlength" update="tlength nlength boltFeedback" />
        </p:inputText>
    </h:panelGrid>
    <o:validateOrder type="gt" components="bolt_length thread_length" message="Nominal Thread Length must not exceed Nominal Bolt Length" disabled="#{empty cc.attrs.bolt.nominal_fastener_length and empty cc.attrs.bolt.nominal_thread_length}" />
  </h:panelGroup>
</h:panelGrid>

enter image description here enter image description here

Upvotes: 1

Views: 102

Answers (1)

Melloware
Melloware

Reputation: 12029

try this...I just use one o:validate order and change the process="pnlLengths" to process the whole DIV without affecting your panel grid layouts.

    <h:panelGrid columns="2" id="pnlLengths">
        <h:panelGroup id="nlength">
            <p:outputLabel value="Bolt Length" />
            <h:panelGrid columns="3">
                <h:outputLabel value="nominal:" />
                <p:inputText size="1" id="bolt_length" value="#{cc.attrs.bolt.nominal_fastener_length}">
                    <p:ajax process="pnlLengths" update="nlength tlength boltFeedback" />
                </p:inputText>
            </h:panelGrid>
        </h:panelGroup>
        <h:panelGroup id="tlength">
            <p:outputLabel value="Thread Length" />
            <h:panelGrid columns="3">
                <h:outputLabel value="nominal:" />
                <p:inputText size="1" id="thread_length" value="#{cc.attrs.bolt.nominal_thread_length}">
                    <p:ajax process="pnlLengths" update="tlength nlength boltFeedback" />
                </p:inputText>
            </h:panelGrid>
        </h:panelGroup>
        <o:validateOrder type="gt" components="bolt_length thread_length" message="Nominal Thread Length must not exceed Nominal Bolt Length" disabled="#{empty cc.attrs.bolt.nominal_fastener_length and empty cc.attrs.bolt.nominal_thread_length}" />
    </h:panelGrid>

Upvotes: 1

Related Questions