Hi. Did u find any solution?
I have this environment:
- Spring 2.5.6
- Spring webflow 2.0.7
- JVM 1.5 and 1.6
- Tomcat 5.5 and 6.0
I have a classic Spring MVC application done by Controller, SimpleFormController and AbstractWizardFormController. I need to add some Aajax behaviours above all to my AbstractWizardFormController. I downloaded spring webflow 2.0.7 and i'ld love to use only Spring-Js framework.
Now i'ld like to realize this scenario (if possible but i think it's possible) in my AbstractWizardFomController:
- The user comples the required fields in first page of my page (the _target0 page)
- He/She clicks on a link or button or submit that goes on the _target1 page
- I wanna open a popup where the user can do some work (i.e checks some checkboxes)
- when on the _target1 page the user clicks on confirm button i wanna do a submit to the _target0 page and refresh only a partial part od my page showing to the user the choices
Now...in my myapp-servlet.xml file i added the TilesViewResolver that is:
Code:
<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
<property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
</bean>
Now i have a first problem: how can i do a submit with Spring Js framework?
In my jsp page i did this thing:
Code:
<a href="createCeItem.controller?_popu1&folderId=<%=request.getParameter("folderId") %>" id="scegliCategorie" name="scegliCategorie" title="<fmt:message key="chooseCateogries"/>" class="button"><fmt:message key="chooseCateogries"/></a>
<script type="text/javascript">
/*<![CDATA[*/
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "scegliCategorie",
event: "onclick",
popup: true,
params: {fragments: "scegliCategorie"}
}));
/*]]>*/
</script>
The fragments params is a tiles so defined:
Code:
<definition name="cePopUpHome" template="/WEB-INF/ceTilesLayout/cePopupLayout.jsp">
<put-attribute name="head" value="/WEB-INF/jsp/ce/generic/head.jsp" />
<put-attribute name="corpo" value="" />
</definition>
<definition name="elencoCategorie" extends="cePopUpHome">
<put-attribute name="corpo" value="/WEB-INF/jsp/ce/item/elencoCategorie.jsp" />
</definition>
I "deceived" my abstracwizardform controller by overriding the isSubmissionForm method and the getTargetPage method in order to do a "submit" when the user clicks on the href. I did this thing:
Code:
@SuppressWarnings("unchecked")
protected final int getButtonFromRequest(HttpServletRequest request, String value) {
Enumeration<String> paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String paramName = (String) paramNames.nextElement();
if (paramName.startsWith(value)) {
String val = paramName.substring(value.length(), paramName.length());
return Integer.parseInt(val);
}
}
return -1;
}
@Override
protected boolean isFormSubmission(HttpServletRequest request) {
if (getButtonFromRequest(request, "_popup") != -1) {
return true;
}
return super.isFormSubmission(request);
}
@Override
protected int getTargetPage(HttpServletRequest request, Object command, Errors errors, int currentPage) {
int popupButton = getButtonFromRequest(request, "_popup");
if (popupButton > -1) {
String requestUri = request.getServletPath();
String queryString = request.getQueryString();
requestUri = requestUri.endsWith("?") ? requestUri : requestUri+"?";
String completeUri = requestUri+queryString;
String msg = "E stata richiamata questa uri: "+completeUri+" sopprimo le validazioni ed apro la popup";
LoggerUtil.traceInfo(logger, msg);
setAllowDirtyForward(true);
return popupButton;
} else {
if( isAllowDirtyForward() ){
setAllowDirtyForward(false);
}
return super.getTargetPage(request, currentPage);
}
}
But, altough the abstractwizardformcontroller thinks it's a submit, this is not a real HTML submit so, correctly, spring will not bind the elements in command; anyway i'm able to open a popup (it seems strange but this popup doesn't have any stylesheet and i don't know why..it simply appears trasparent with the checkboxes i want); this problem is destroying me

.
Do u have any suggestion about how i could implement this scenario?