Trying to work with multiple submit buttons within a single form in struts2 application but not able to work. here is the jsp code i am using
<tr>
<td class="button"><input type="submit" value="Import"
name="destinationImport" class="button"></td>
<td class="button"><input type="submit" value="Export"
name="destinationExport" class="button"></td>
</tr>
here is the java part
private boolean destinationImport;
private boolean destinationExport;
//and the respective setters and getters
but i am sure is that Struts2 type convertor is having problem converting the String value to boolean do any one have idea how to achieve this
Thanks i开发者_开发问答n advance
Methods : getDestinationExport / setDestinationExport should deal with String, since your values: "Export" and "Import" aren't convertible directly to boolean type. If you need convert it by internal rule, place corresponding code inside setDestinationExport. Something like that:
public void setDestinationExport(String arg){
destinationExport = "Export".equals(arg);
destinationImport = "Import".equals(arg);
}
This way should works
private boolean destinationImport = false;
private boolean destinationExport = false;
public void setDestinationImport(boolean destinationImport) {
this.destinationImport = true;
}
public void setDestinationExport(boolean destinationExport) {
this.destinationExport = true;
}
Reference: http://serpensalbus.com/blog/tricking-struts2-multiple-submit-buttons/
精彩评论