struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Prasetya <>
Subject validation error struts2
Date Thu, 18 Oct 2007 03:05:27 GMT

I have this select.jsp

<%@ taglib prefix="s" uri="/struts-tags"%>
<p>Employee Data</p>
<s:form action="*save*" validate="*true*" namespace="/person">
    <s:hidden id="id" name="" />
    <s:textfield id="firstName" label="First Name"
        name="employee.firstName" />
    <s:textfield id="lastName" label="Last Name" name="employee.lastName" />
    <s:textfield id="phoneNumber" label="Phone Number"
        name="employee.phoneNumber" />
    <s:submit theme="ajax" targets="employees" notifyTopics="/save" />

this is called index.jsp via ajax via struts mapping alias "select"

<%@ taglib prefix="s" uri="/struts-tags"%>
        <s:head theme="ajax" debug="true"/>
        <script type="text/javascript">
            dojo.event.topic.subscribe("/save", function(data, type, 
request) {
                if(type == "load") {
                    dojo.byId("id").value = "";
                    dojo.byId("firstName").value = "";
                    dojo.byId("lastName").value = "";
                    dojo.byId("phoneNumber").value = "";
        <s:url action="list" id="descrsUrl"/>

        <div style="width: 300px;border-style: solid">
            <div style="text-align: right;">
                <s:a theme="ajax" notifyTopics="/refresh">Refresh</s:a>
            <s:div id="employees" theme="ajax" href="%{descrsUrl}" 
loadingText="Loading..." listenTopics="/refresh"/>


/        <s:url action="select" id="selectUrl"/>
        <div style="width: 300px;border-style: solid">
            <s:div id="empedit" theme="ajax" href="%{selectUrl}" 
loadingText="Loading Data..." listenTopics="/refedit"/>
/    </body>


<?xml version="1.0" encoding="UTF-8" ?>
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.devMode" value="true" />

    <package name="person" extends="struts-default">

        <action name="list" method="execute" class="employeeAction">
            <result name="input">pages/list.jsp</result>

        <action name="remove" class="employeeAction" method="remove">
            <result name="input">pages/list.jsp</result>
        <action name="edit" class="employeeAction" method="edit">
            <result name="input">pages/list.jsp</result>

        <action name="*save*" class="*employeeAction*" method="*save*">
            <result name="input">pages/list.jsp</result>
/        <action name="*select*" class="*employeeAction*" method="edit">
            <result name="input">pages/select.jsp</result>
/    </package>


when I run this and submit (which calls the "save" action), I get an 
error *ReferenceError: validateForm_save is not defined*

I already defined EmployeeAction-save-validation.xml

<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0//EN"
    <field name="employee.firstName">
        <field-validator type="requiredstring">
            <message>First name is required!</message>
    <field name="employee.lastName">
        <field-validator type="requiredstring">
            <message>Last name is required!</message>

Where have I did wrong ? when its still embedded inside the index.jsp, 
the validation is running normally but when i click edit which will fill 
the backing bean Employee it wont show up immediately which i have to do 
it the ajax way and seperate it into select.jsp. Please help.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message