Boa tarde pessoal.
Estou usando o Struts2 e tenho um formulario que possui 4 botoes submit em um form:
<s:form id="formRecrutar" onsubmit="return validaDadosForm()" cssClass="formularioCurriculo" acceptcharset="utf-8" theme="simple">
<s:submit value="Enviar"/>
<s:submit value="Atualizar" onclick="sendTo('updateRecrutamento!update.action')"/>
<s:submit value="Apagar" onclick="sendTo('deleteRecrutamento!delete.action')"/>
</s:form>
Struts.xml
<package name="recrutar" extends="struts-portlet-default" namespace="/recrutar">
<action name="updateRecrutamento" class="br.com.pine.plugins.curriculo.view.RecrutarAction">
<result name="success">/WEB-INF/view/recrutar/IndexRecrutamento.jsp</result>
</action>
<action name="deleteRecrutamento" class="br.com.pine.plugins.curriculo.view.RecrutarAction">
<result name="success">/WEB-INF/view/recrutar/IndexRecrutamento.jsp</result>
</action>
</package>
Action Class
public class RecrutarAction extends DefaultActionSupport {
private static final long serialVersionUID = 1L;
private static final Log LOG = LogFactory.getLog(RecrutarAction.class);
private Recrutamento recrutamento;
private List<Recrutamento> listRecrutamento;
private List<Vaga> vagas;
private String msg;
private String json;
private List<String> nomes;
private List<Long> cpf = new ArrayList<Long>();
private String recrutamentoDump;
private int listagem;
private int id;
private int offset;
private int pageSize;
public RecrutarAction() {
LOG.debug("Inicializando a Action de Recrutamento");
vagas = new ArrayList<Vaga>();
recrutamento = new Recrutamento();
}
public String delete() {
LOG.debug("Excluindo um recrutamento");
try {
DbClient.delete("deleteRecrutamento", recrutamento);
} catch (SQLException e) {
LOG.debug("Houve um erro: " + e.getMessage());
addActionError("<p>Houve um erro interno: </p></br>" + "<p>"+ e.getMessage()+"</p></br>" + "<p>Favor avise ao analista.</p>");
return ERROR;
}
addActionMessage("<p>Registro excluído com sucesso!</p>");
return SUCCESS;
}
public String update() {
LOG.debug("Atualizando um recrutamento");
try {
DbClient.update("updateRecrutamento", recrutamento);
} catch (SQLException e) {
LOG.debug("Houve um erro: " + e.getMessage());
addActionError("<p>Houve um erro interno: </p></br>" + "<p>"+ e.getMessage()+"</p></br>" + "<p>Favor avise ao analista.</p>");
return ERROR;
}
addActionMessage("<p>Registro atualizado com sucesso!</p>");
return SUCCESS;
}
}
JAVASCRIPT
function sendTo(url) {
document.getElementById('formRecrutar').action = url;
document.getElementById('formRecrutar').submit();
}
So que ele nao entra no metodo da action…
Como eu uso mais que um submit em um form, sem ser por AJAX?
Obrigado…