Monday, June 15, 2009

Struts2: form not submitting

When using Struts2, here are some hints about what may be happening if after submit the data of your form isn't available within the corresponding action:


  • Check if on click you're effectively performing a submit and not just merely following a link; only the <s:submit> tag should be used or a link which calls a javascript:form.submit()!


  • Be sure that you have a public setter (and getter) within your action for all the variables you're submitting, otherwise the (private) member variables within your action will never receive a value!

Thursday, June 11, 2009

Changes needed when switching from Struts2 v.2.0.11.2 to v.2.1.6

When using an old and working application, based upon Struts2 v.2.0.11.2, as the base for a new application using Struts2 v.2.1.6, I encountered I had to make the following modifications in struts.xml:

  • change all type="redirect-action" into type="redirectAction"

  • Because the org.apache.struts2.views.tiles.TilesResult isn't included anymore in the struts jar, I had to comment

    <result-types>
    <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
    </result-types>


    Update: on hindsight, the second error was caused by a missing tiles jar!