Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation, problem with using action path instead of form name

 
Jasna Dosen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to configure validation.xml using
action path instead of form name (in form element) but I'm getting an error
ActionForm doesn't exist.Seems like not accepting
action path instead of form name.

struts-conf.xml
...........
<action name="templateForm" path="/AddNewTemplate" scope="session" type="com.infinica.admin.actions.SaveTemplateAction" input="/newTemplate.jsp" validate="true">
<forward name="showInserted" path="/jsp/showInsertTemplate.jsp" />
<forward name="error" path="/jsp/newTemplate.jsp">
</forward>
</action>
............


validation.xml
......
<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>

<formset>
<form name="/AddNewTemplate">
<field property="version" depends="required">
<arg0 key="label.template.version" />
</field>
</form>

</formset>
</form-validation>

What could be an possible reason for that? I tried all possible versions of dtd file.

Thank you in advance.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your TemplateForm extend ValidatorActionForm? If not, that's the problem.

You extend ValidatorForm if you're using the name of the form for validation, and you extend ValidatorActionForm if you're using the name of the action.
 
Jasna Dosen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, of course.Here is code of my form that extends ValidatorActionForm:

public class TemplateForm extends ValidatorActionForm {

public TemplateForm() {
super();
// TODO Auto-generated constructor stub
}
private static final long serialVersionUID = 1L;
private Integer id;
private String name = "";
private Integer version;
private byte[] itd;
private FormFile xslt;
private String creationTime;
private String modificationTime;
private Integer[] listSelected;

public String getCreationTime() {
return creationTime;
}
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public byte[] getItd() {
return itd;
}
public void setItd(byte[] itd) {
this.itd = itd;
}
public String getModificationTime() {
return modificationTime;
}
public void setModificationTime(String modificationTime) {
this.modificationTime = modificationTime;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public FormFile getXslt() {
return xslt;
}
public void setXslt(FormFile xslt) {
this.xslt = xslt;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return this.id;
}
public Integer[] getListSelected() {
return listSelected;
}
public void setListSelected(Integer[] listSelected) {
this.listSelected = listSelected;
}

public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {

return super.validate(mapping, request);

}


}

It looks like syntax check doesn't allowed that I put action path instead of form name.

As a addition part from struts-config.xml

<form-bean name="templateForm" type="com.infinica.admin.forms.TemplateForm">
</form-bean>
Thanks,
Jasna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic