Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF Struts Integration Action lost on submit

james salt
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I've been tearing my hair out with this one for half a day. I am producing a web app using struts and jsf in conjunction. I have succesfully used the integration library on several pages, so I know the framework is in place. However for the following page I can produce valuechange events and process them on a javascript submit, and perform a quick return render, but when I press the submit button, the action is not forwarded through to struts action.

The jsp page :
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="f" uri="" %>
<%@ taglib prefix="h" uri="" %>
<%@ taglib prefix="s" uri="" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<s:form action="/redirectSelectSite">
<table border="0">
<td>Site Code</td>
<td><h:selectOneMenu id="siteSelect" value="#{SelectPlotForm.sitecode}" valueChangeListener="#{SelectPlotForm.processSiteChange}" onchange="this.form.submit();">
<f:selectItems id="siteSelectItem" value="#{SelectPlotForm.sites}" />
<td>Plot Number</td>
<td><h:selectOneMenu id="plotSelect" value="#{SelectPlotForm.plotno}" >
<f:selectItems id="plotSelectItem" value="#{SelectPlotForm.plots}" />
<td colspan="2" align="center"><h:commandButton id="submit" type="SUBMIT" value="Continue"/></td>

Backing Bean:

public class SelectPlotForm extends ActionForm {

// Omitted unwanted detail.

* @param event
* @throws AbortProcessingException
public void processSiteChange(ValueChangeEvent event)
throws AbortProcessingException {
if (null != event.getNewValue()) {
sitecode = ((String)event.getNewValue());

// Get the list of plots for the new sitecode.

// Do a quick render response

struts-config.xml extract

<action attribute="SelectPlotForm" name="SelectPlotForm" path="/redirectSelectSite" scope="session"
validate="false" input="/selectPlot.faces" >
<forward name="success" path="/printchoices.faces" />

and finally the struts action file :

package com.millwood.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.config.ForwardConfig;

import com.millwood.Choices.Web.SelectPlotForm;

* Redirects the user of the selectPlot page to the appropriate action.
* @author James Salt
* @since 0.1
public class RedirectSelectPlot extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {

SelectPlotForm scf = (SelectPlotForm) form;

// Construct the foward entity on the fly.
ForwardConfig fc = new ForwardConfig();
fc.setPath(scf.getActionurl()+ ".do?plotno=" + scf.getPlotno() + "&sitecode="+ scf.getSitecode());

return (mapping.findForward("result"));


Sorry about the massive posting but I thought it better to provide all the information relevant as currently I am at a bit of a loss.

I have placed debug points at all the accessible parts of code, but non are triggered, so it must be being bounced in the ActionListener either in Struts or Faces before it tries to get the action.

Any help would be really, really appreciated.

Yours thankfully,

james salt
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic