struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodrigo Lins <lins.olive...@gmail.com>
Subject Help with validation
Date Tue, 12 May 2009 20:22:13 GMT
Hi,
I'm in trouble, i use a ValidationForm and the validation plugin to validate
my formBean.
Every time i push the button to submit my action and don't validate i see
twice error messages.
Can you help me?


Thanks,
Rodrigo.

validation.xml
<form name="networkAdminForm">
<field depends="required,mask,minlength" property="nodeName" page="4">
                <arg
key="label.wdtlight.networkAdmin.hardwareChangeNotification.validation.nodeName"

                position="0" />
                <arg key="${var:minlength}" name="minlength" position="1"
resource="false" />
                <var>
                    <var-name>mask</var-name>
                    <var-value>${dslam}</var-value>
                </var>
                <var>
                    <var-name>minlength</var-name>
                    <var-value>5</var-value>
                </var>
            </field>

            <field depends="mask" property="portKey" page="4">
                <arg
key="label.wdtlight.networkAdmin.hardwareChangeNotification.validation.resourcePosition"

                position="0" />
                <var>
                    <var-name>mask</var-name>
                    <var-value>${port}</var-value>
                </var>
            </field>
</form>

Part of my Action

    public ActionForward searchHardwareChangeNotification(ActionMapping
mapping, ActionForm form, HttpServletRequest request, HttpServletResponse
response)
    {
        request.getSession().removeAttribute(IConstants.SESSION_LIST);

        initLists(request);

        NetworkAdminForm networkAdminForm = (NetworkAdminForm) form;

        //    Seta a página correta no formulário para validação.

networkAdminForm.setPage(NetworkAdminForm.HARDWARE_CHANGE_NOTIFICATION_PAGE);

        //    Valida os dados de entrada do formulário. (configurações de
validação no arquivo validation.xml)
        ActionMessages errors = networkAdminForm.validate(mapping, request);

        if (!errors.isEmpty()) {
            saveErrors(request, errors);
            return showHardwareChangeNotificationPage(mapping, form,
request, response);
        }
}


My JSP File

<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic-el.tld" prefix="logic-el" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/tlds/displaytag.tld" prefix="display" %>

<%@ page import="br.com.targets.wdt.ui.struts.action.NetworkAdminAction" %>
<%@ page import="br.com.targets.wdt.ui.struts.action.IConstants" %>
<%@ page import="br.com.targets.wdt.business.valueobjects.ResourceObject" %>

<link type="text/css" rel="stylesheet"
href="<%=request.getContextPath()%>/include/css/wdtlight-tableReport.css">


<script language="javascript">

    if (navigator.appName.indexOf('Microsoft') != -1){
         clientNavigator = "IE";
     }else{
         clientNavigator = "Other";
     }

    function blockChararacters(evnt){
        if (clientNavigator == "IE"){
             if (evnt.keyCode < 48 || evnt.keyCode > 57){
                 return false
             }
         }else{
             if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode
== 0){
                 return false
             }
         }
    }

    function formatPosition(input, evnt){

        if (input.value.length == 2 || input.value.length == 5 ||
input.value.length == 8){
            if(clientNavigator == "IE"){
                 input.value += "-";
             }else{
                 if(evnt.keyCode == 0){
                     input.value += "-";
                 }
             }
        }
        return blockChararacters(evnt);
    }

    // Função usada para submeter o form com uma acao especifica
    function doNetworkAction(pForm,pAcao,pId){
        pForm.elements['method'].value=pAcao;
        pForm.elements['selectedNodeIp'].value=pId;
        pForm.submit();
    }

    function doNetworkActionStatus(pForm,pAcao,pId,pType){
        pForm.elements['method'].value=pAcao;
        pForm.elements['selectedId'].value=pId;
        pForm.elements['selectedResourceType'].value=pType;
        pForm.submit();
    }
</script>



<html:form action="/NetworkAdmin" >

<html:hidden name="networkAdminForm" property="method" />


<html:hidden name="networkAdminForm" property="selectedNodeName" />
<html:hidden name="networkAdminForm" property="selectedResourceType" />
<html:hidden name="networkAdminForm" property="selectedNodeIp" />
<html:hidden name="networkAdminForm" property="selectedId" />


<TABLE width="100%">
    <TBODY>
        <TR>
            <TD class="subsubtitle" colspan="3" >
                <IMG height=7 src="./include/images/body/barrow.jpg"
width=10 border=0 />
                <B><FONT color=#003366><bean:message
key="label.wdtlight.networkAdmin.hardwareChangeNotification.form.title"/></FONT></B>
            </TD>
        </TR>
        <TR>
            <TD colspan="3">
                <HR>
            </TD>
        </TR>
        <tr>
            <TD width="50">
            </TD>
            <td>
                <table width="100%"  border='0'>

                    <!-- Nome do nó -->
                    <tr>
                        <td width="150" align="left">
                            <bean:message
key="label.wdtlight.networkAdmin.changeStatus.nodeName"/>
                        </td>
                        <td>
                            <html:text name="networkAdminForm"
property="nodeName" maxlength="64" size="35" ></html:text>
                        </td>
                    </tr>


                    <!-- Posicao do Recurso -->
                    <tr>
                        <td width="150" align="left">
                            <bean:message
key="label.wdtlight.networkAdmin.hardwareChangeNotification.resourcePosition"/>
                        </td>
                        <td>
                            <html:text name="networkAdminForm"
property="portKey" maxlength="11" size="35" onkeypress="return
formatPosition(this, event);"></html:text>
                        </td>
                    </tr>
                    <tr>

                        <!-- Status do Recurso -->
                        <td width="150" align="left">
                            <bean:message
key="label.wdtlight.networkAdmin.hardwareChangeNotification.resourceStatus"/>
                        </td>
                        <td>
                            <html:select name="networkAdminForm"
property="selectedResourceStatus" style="width:231px;">
                                <html:option value=""><bean:message
key="label.wdtlight.combo.noSelection"/></html:option>
                                <logic-el:iterate id="item" name='<%=
NetworkAdminAction.RESOURCE_STATUS_LIST %>' indexId="index">
                                    <html-el:option
value="${item.key}"><bean-el:message key="${item.key}" /></html-el:option>
                                </logic-el:iterate>
                            </html:select>
                        </td>
                    </tr>
                    <tr>
                        <TD align="right" colspan="2">
                            <table width="100%">

                                <tr>
                                    <td class="formButton" align='right'>
                                        <div align='right'>
                                            <INPUT class='button'
type='button'
onclick="JavaScript:showWaitMessage();doNetworkAction(networkAdminForm,'<%=
NetworkAdminAction.ACTION_SEARCH_FROM_HARDWARE_CHANGE %>')"
value='<bean:message
key="label.wdtlight.networkAdmin.hardwareChangeNotification.search.button"/>'>

                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </TD>
                    </tr>


                </table>
            </td>
        </TR>
    </TBODY>
</table>
<logic:present name='<%= IConstants.SESSION_LIST %>'>

    <table width="100%" border='0'>
    <tr>
        <td colspan="3" height="10">
            <hr>
        </td>
    </tr>
    </table>

    <%-- Caso o retorno tenha sido em branco --%>
    <logic:empty name='<%= IConstants.SESSION_LIST %>'>
    <table width="100%" border='0'>
        <tr valign="top" >
            <td colspan="3"  align="center" style="padding-top: 15px;
padding-bottom: 20px;">
                <font style="color: red; "><bean:message
key="label.wdtlight.noResults"/></font>
            </td>
        </tr>
    </table>
    </logic:empty>

    <%-- Caso o retorno venha populado --%>
    <logic:notEmpty name='<%= IConstants.SESSION_LIST %>'>
        <table width="100%" border='0'>
                <tr align="center" valign="middle">
                    <td colspan="3">
                        <display:table class="report" id="resourceObject"
name='<%= IConstants.SESSION_LIST %>'
                        export="true" defaultsort="1"
defaultorder="descending" pagesize='<%= IConstants.DEFAULT_PAGE_SIZE %>'
                        requestURI='<%=
"/NetworkAdmin.do?method="+NetworkAdminAction.ACTION_SEARCH_FROM_HARDWARE_CHANGE
%>' excludedParams="method" >

                            <%-- Dslam Name Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.dslamName"
property="nodeName" sortable="true" headerClass="sortable"/>

                            <%-- Resource Position Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.resourcePosition"
property="key" sortable="true" headerClass="sortable"/>

                            <%-- Manufacturer Name Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.manufacturerName"
property="manufacturer" sortable="true" headerClass="sortable"/>

                            <%-- Node Resource Type Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.resourceType"
sortable="true" headerClass="sortable">
                                <bean-el:message
key="${resourceObject.resourceType.key}"/>
                            </display:column>

                            <%-- Node Status Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.nodeStatus"
sortable="true" headerClass="sortable">
                                <bean-el:message
key="${resourceObject.resourceStatus.key}"/>
                            </display:column>

                            <%-- Timestamp Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.timestamp"
property="timestamp" sortable="true" headerClass="sortable"
decorator="br.com.targets.wdt.ui.displaytag.decorators.LongDateWrapper" />

                            <%-- Node Select Column --%>
                            <display:column
titleKey="label.wdtlight.networkAdmin.hardwareChangeNotification.select">
                                <input class='button' type='button'
onclick="javascript:doNetworkActionStatus(networkAdminForm,'<%=NetworkAdminAction.ACTION_SHOW_CHANGE_OR_UPDATE_STATUS_PAGE%>','<%=((ResourceObject)resourceObject).getId()%>','<%=((ResourceObject)resourceObject).getResourceType().getKey()%>')"
value='<bean:message
key="label.wdtlight.networkAdmin.hardwareChangeNotification.update.button"/>'
/>
                            </display:column>

                            <display:setProperty name="export.pdf"
value="true" />

                        </display:table>
                    </td>
                </tr>
        </table>
    </logic:notEmpty>

</logic:present>

</html:form>

-- 
Rodrigo Lins de Oliveira
21 8610-8297

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message