This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Validation, problem with using action path instead of form name

 
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.
 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!