سؤال

BACKGROUND

I am learning Struts 1.x and currently on the validation framework.

PROBLEM

I have it in a semi-working condition. Currently it is showing the validation errors, but in a javascript alert.. and then the validation summary (the thing generated by <html:error>) is blank.. well, it has 3 bullet points where the validation errors are supposed to be, but no text.

  1. I would not have expected it to use a javascript alert. I only want the validation summary. How can I turn this off, if possible?
  2. Why is the validation summary missing text?

EDIT

Here is some of the code, if it helps.

struts-config.xml

<form-beans>
        <form-bean name="ProductActionForm" type="actionForms.ProductActionForm"/>
    </form-beans>

validation.xml

<form name="ProductActionForm">
            <field property="name" depends="required">
                <arg key="ProductActionForm.name"/>
            </field>
            <field property="price" depends="required,float">
                <arg key="ProductActionForm.price"/>
            </field>
            <field property="quantityInStock" depends="integer,intRange">
                <arg0 key="ProductActionForm.quantityInStock"/>
                <arg1 name="intRange" key="${var:min}" resource="false"/>
                <arg2 name="intRange" key="${var:max}" resource="false"/>
                <var>
                    <var-name>min</var-name>
                    <var-value>0</var-value>
                </var>
                <var>
                    <var-name>max</var-name>
                    <var-value>9999</var-value>
                </var>
            </field>
        </form>

JSP HTML:

<html:javascript formName="ProductActionForm" />
        <html:errors></html:errors>
        <html:form action="/AddProductAction" method="post" onsubmit="validateProductActionForm(this);">
            <table class="table table-striped">
                <tbody>
                    <tr>
                        <td>Name: </td>
                        <td><html:text property="name" /></td>
                    </tr>
                    <tr>
                        <td>Price: </td>
                        <td><html:text property="price" /></td>
                    </tr>
                    <tr>
                        <td># In Stock </td>
                        <td><html:text property="quantityInStock" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="submit" class="btn btn-primary" value="Submit" /></td>
                    </tr>
                </tbody>
            </table>
        </html:form>

EDIT 2

Here are some screenshots:

Showing javascript alert: Showing javascript alert

Showing blank validation summary: Showing blank validation summary

هل كانت مفيدة؟

المحلول

Hi Matt Here we go There are 2 types of Struts1 Validations

1. Validate using ActionErrors validate in Bean itself(show summary)

2. Validate using xml and configure everything here itself.(javascript alert)

for your case you used second type that is correct,But to get summary alone check this link thats all, if you get problem in link or its example , Please ping me.

This is the example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top