I am doing a Struts 1 to Struts 2 migration. We have Struts 1 code that has extended and customised the org.apache.struts.taglib.html.FormTag. Did some search and found that the org.apache.struts2.views.jsp.ui.FormTag is the equivalent in Struts2.
My current Struts 1 code modifies the onsubmit variable of the FormTag by calling the setOnsubmit(), but it does that by first doing a getOnsubmit() like below.
if (this.getOnsubmit() == null) {
this.setOnsubmit(subCmd + subCmdEnd);
}
else {
this.setOnsubmit(subCmd + this.getOnsubmit() + subCmdEnd);
}
The Struts 2 class has the setOnsubmit(), but not the getOnsubmit(). Do we have any other option available to read the onsubmit value?
The
<s:form>tag belongs to Struts 2 core tag library. So, if you need to use your own tag that extends this one then you should extendorg.apache.struts2.views.jsp.ui.FormTagclass and provide your own implementation by overridingpublicmethods, and adding additional methods. Theonsubmitfield has aprotectedmodifyer.But before doing any changes to the Struts 2 framework ask an advice from qualifyed experts: why do you need to do it? For carrying the old code to the new one? The code that is written for S1 is incompatible with S2.
onsubmitis a HTML attribute of the HTML<form>tag, and it could be set in the any other ways on the server, i.e. using OGNL, or on the client using JavaScript.Also when migrating from Struts1 to Struts 2 you should read Struts 1 to Struts 2 migration strategy.