Guys,

 

I don't know what I am doing wrong. I am missing the actual validation
JavaScript code in the generated html when accessing
add_comment.do?blogid=23. I have included the snippet below.

 

 

addcomment.jsp

 

<s:form action="save_comment" method="POST"  validate="true">

<s:actionerror />

<s:actionmessage />

<input type="hidden" id="blogid" name="comment.blogid" value="<s:property
value="blog.id">"

<s:textfield  required="true" id="name" name="comment.name" label="Name"/>

<s:textarea  required="true" id="comment" name="comment.comment"
label="Comment"/>

<s:submit/>

 

struts.xml 

 

<action name="add_comment" class="CommentAction" method="add"> 

<result>/blog/addcomment.jsp</result>

</action>

 

<action name="save_comment" class="CommentAction" method="save"> 

<result name="input">/blog/addcomment.jsp</result>

<result>/blog/addcomment.jsp</result>

</action>

 

 

CommentAction-save-validation.xml

 

<validators>

            <field name="comment.name">

                        <field-validator type="requiredstring">

                                    <param name="trim">true</param>

                                    <message>Name is required</message>

                        </field-validator>

            </field>

            <field name="comment.comment">

                        <field-validator type="requiredstring">

                                    <param name="trim">true</param>

                                    <message>Comment is required</message>

                        </field-validator>

            </field>

</validators>

 

 

Generated html by browser when accessing add_comment.do?blogid=23

 

<form namespace="/blog"  

id="save_comment"  name="save_comment"  onsubmit="return
validateForm_save_comment();"  

action="/blog/save_comment.action"  method="POST">

.......

.......

.......

function validateForm_save_comment() 

{

 

            form = document.getElementById("save_comment");

 

            clearErrorMessages(form);

 

            clearErrorLabels(form);

 

            var errors = false;

 

            // Missing actual validation here..............

 

            return !errors;

}

 

I would really appreciate is anyone has idea what am I doing wrong.

 

Thanks 

Rabin 

Reply via email to