Hi there

I have a problem disabling JSF validation for some components. In the attached 
JSP code, the input elements orderUnits, orderAmount, validFrom and validUntil 
block the execution of server-side action "#{orderEntryBean.gotoOrderReview}" 
of the command button navNextButton every time they are left blank (loaded 
value = null), even though I tagged them with required="false" and did not 
specify a validator. Can Javascript event handling somehow affect JSF 
validation?

If the action is set to immediate="true", the servers-side action will be 
executed, but the values won't be applied to the model.

Additionally to MyFaces, I use the component library quipukit, which has its 
own validation engine. I disabled it explicitly in web.xml:


<context-param>

<param-name>teamdev.jsf.validation.clientValidation</param-name>

<param-value>off</param-value>

</context-param>



<context-param>

<param-name>teamdev.jsf.validation.useDefaultClientPresentation</param-name>

<param-value>false</param-value>

</context-param>



<context-param>

<param-name>teamdev.jsf.validation.useDefaultServerPresentation</param-name>

<param-value>false</param-value>

</context-param>





Thanks for your help!



Regards,

-Lorin
<%@ page session="false" contentType="text/html; charset=ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
<%@ taglib uri="http://java.sun.com/portlet"; prefix="portlet"%>
<%@ taglib uri="http://teamdev.com/quipukit"; prefix="q"%>

<portlet:defineObjects />
<link rel="stylesheet" type="text/css" href="<%= 
renderResponse.encodeURL(renderRequest.getContextPath() + "/css/basic.css") %>" 
/>
<link rel="stylesheet" type="text/css" href="<%= 
renderResponse.encodeURL(renderRequest.getContextPath() + 
"/css/orderentry.css") %>" />
<link rel="stylesheet" type="text/css" href="<%= renderRequest.getContextPath() 
+ "/qk_internalResource/teamdev/jsf/renderkit/default.css"%>" />
<script type="text/javascript">
function calculateAmount(itemPrice) {
        var units = 
parseFloat(getElementById("oeSXOptionsForm:orderUnits").value);
        var amount = null;
        if(!isNaN(units)) amount = Math.round(units * itemPrice * 100) / 100;
        getElementById("oeSXOptionsForm:orderAmount").value = amount;
}

function calculateUnits(itemPrice) {
        var amount = 
parseFloat(getElementById("oeSXOptionsForm:orderAmount").value);
        var units = null;
        if(!isNaN(amount)) units = Math.round((amount / itemPrice) * 1000) / 
1000;
        getElementById("oeSXOptionsForm:orderUnits").value = units;
}


function changeLimitType(itemPrice) {
        var limitTypeComboBox = getElementById("oeSXOptionsForm:limitType");
        var v = 
limitTypeComboBox.options[limitTypeComboBox.selectedIndex].value;
        var triggerValue = getElementById("oeSXOptionsForm:triggerValue");
        var limitValue = getElementById("oeSXOptionsForm:limitValue");
        
        if(v == "Limited at" || v == "On Stop Limited at" || v == "Stop Loss 
Limited at") {     
                limitValue.value = itemPrice;
                limitValue.disabled = false;
                triggerValue.value = null;
                triggerValue.disabled = true;
        }
        else if(v == "On Stop at Best" || v == "Stop Loss at Best") {
                triggerValue.value = itemPrice;
                triggerValue.disabled = false;
                limitValue.value = null;
                limitValue.disabled = true;
        }
        else {
                limitValue.value = null;
                limitValue.disabled = true;
                triggerValue.value = null;
                triggerValue.disabled = true;
        }
}

function getElementById(id) {
        var element = document.getElementById(id);
        if(element == null) element = document.getElementById("view:"+id);
        return element; 
}
</script>

<f:view>
        <h:form id="oeSXOptionsForm" >
                <h:panelGrid columns="1" cellspacing="5">
                        <h:panelGrid columns="5" style="background-image: 
url(#{utilBean.requestContextPath}/images/orderentry_workflow.gif)" 
styleClass="oeWorkflowTable" columnClasses="oeWorkflowColumn, oeWorkflowColumn, 
oeWorkflowActiveColumn, oeWorkflowColumn, oeWorkflowColumn" >
                                <h:outputText 
value="Select#{utilBean.br}Portfolio" escape="false"/>
                                <h:outputText 
value="Select#{utilBean.br}Instrument" escape="false"/>
                                <h:outputText 
value="Order#{utilBean.br}Details" escape="false"/>
                                <h:outputText value="Review#{utilBean.br}Order" 
escape="false"/>
                                <h:outputText 
value="Processing#{utilBean.br}Status" escape="false"/>
                        </h:panelGrid>
                
                        <h:panelGrid columns="2" styleClass="oePanelGrid" 
headerClass="oePanelGridHeader" columnClasses="oeColumnDescription, 
oeColumnValue">
                                <f:facet name="header">
                                        <h:outputText value="Instrument" />
                                </f:facet>
                                <h:outputText value="Instrument"/>
                                <h:outputText id="instrumentName" 
value="#{orderEntryBean.selectedInstrument}" />
                                
                                <h:outputText value="Item Price"/>
                                <h:outputText id="itemPrice" 
value="#{orderEntryBean.selectedInstrument.itemPrice}" >
                                                <f:convertNumber 
pattern="#,##0.00 ¤" 
currencyCode="#{orderEntryBean.selectedInstrument.tradingCurrency}"/>
                                </h:outputText>
                        </h:panelGrid>
                        
                        <h:panelGrid columns="2" styleClass="oePanelGrid" 
headerClass="oePanelGridHeader" columnClasses="oeColumnDescription, 
oeColumnValue">
                                <f:facet name="header">
                                        <h:outputText value="General" />
                                </f:facet>
                                <h:outputLabel for="orderAction" value="Choose 
Action" />
                                <h:selectOneRadio id="orderAction" 
layout="lineDirection" value="#{orderEntryBean.orderAction}" >
                                                <f:selectItem itemLabel="BUY" 
itemValue="BUY"/>
                                                <f:selectItem itemLabel="SELL" 
itemValue="SELL"/>
                                </h:selectOneRadio>
                
                                <h:outputLabel for="orderUnits" value="Specify 
Units" />
                                <h:inputText id="orderUnits" 
value="#{orderEntryBean.orderUnits}" required="false" 
onkeyup="calculateAmount('#{orderEntryBean.selectedInstrument.itemPrice}')" 
onchange="calculateAmount('#{orderEntryBean.selectedInstrument.itemPrice}')" />
                
                                <h:outputLabel for="orderAmount" value="or 
Amount (#{orderEntryBean.selectedInstrument.tradingCurrency})" />
                                <h:inputText id="orderAmount" 
value="#{orderEntryBean.orderAmount}" required="false" 
onkeyup="calculateUnits('#{orderEntryBean.selectedInstrument.itemPrice}')" 
onchange="calculateAmount('#{orderEntryBean.selectedInstrument.itemPrice}')" />
                                
                                <h:outputLabel for="placedBy" value="Placed By" 
/>
                                <h:selectOneMenu id="placedBy" 
value="#{orderEntryBean.placedBy}" >
                                                <f:selectItems 
value="#{orderEntryBean.placedByItems}" />
                                </h:selectOneMenu>
                        </h:panelGrid>
                
                        <h:panelGrid columns="2" styleClass="oePanelGrid" 
headerClass="oePanelGridHeader" columnClasses="oeColumnDescription, 
oeColumnValue">
                                <f:facet name="header">
                                        <h:outputText value="Validity" />
                                </f:facet>
                                <h:outputLabel for="validFrom" value="Valid 
From" />
                                <q:dateChooser id="validFrom" 
value="#{orderEntryBean.validFrom}" required="false" pattern="dd.MM.yyyy" 
buttonImageUrl="/images/calendar_icon.gif" />
                
                                <h:outputLabel for="validUntil" value="Valid 
Until" />
                                <q:dateChooser id="validUntil" 
value="#{orderEntryBean.validUntil}" required="false" pattern="dd.MM.yyyy" 
buttonImageUrl="/images/calendar_icon.gif" />
                        </h:panelGrid>
                        
                        <h:panelGrid columns="2" cellspacing="5" 
styleClass="oePanelGrid" headerClass="oePanelGridHeader" 
columnClasses="oeColumnDescription, oeColumnValue">
                                <f:facet name="header">
                                        <h:outputText value="Limit" />
                                </f:facet>
                                <h:outputLabel for="limitType" value="Limit 
Type" />
                                <h:selectOneMenu id="limitType" 
value="#{orderEntryBean.selectedLimitTypeItem}" 
onchange="changeLimitType('#{orderEntryBean.selectedInstrument.itemPrice}')">
                                        <f:selectItems 
value="#{orderEntryBean.limitTypeItems}"/>
                                </h:selectOneMenu>
                
                                <h:outputLabel for="limitValue" value="Limit" />
                                <h:inputText id="limitValue" 
value="#{orderEntryBean.limitValue}" >
                                </h:inputText>
                                
                                <h:outputLabel for="triggerValue" 
value="Trigger" />
                                <h:inputText id="triggerValue" 
value="#{orderEntryBean.triggerValue}" >
                                </h:inputText>
                        </h:panelGrid>
        
                        <h:panelGrid columns="3" styleClass="oePanelGrid" 
headerClass="oePanelGridHeader" columnClasses="oeNavigationLeft, 
oeNavigationRight, oeNavigationRight">
                                <h:commandButton id="navCancelButton" 
value="Cancel" action="#{orderEntryBean.reset}" immediate="true" 
styleClass="oeButton"/>
                                <h:commandButton id="navBackButton" value="« 
Back" action="goto_SelectInstrument" immediate="true" styleClass="oeButton"/>
                                <h:commandButton id="navNextButton" value="Next 
»" action="#{orderEntryBean.gotoOrderReview}" styleClass="oeButton" />
                        </h:panelGrid>
                        
                </h:panelGrid>
        </h:form>
</f:view>

Reply via email to