This is part of the "optimistic" binding algorithm which is the default binding algorithm. To specify explicit bindings, use the <binder> view-state child element. See the ref docs of 2.0.3 for details.
Keith
This is part of the "optimistic" binding algorithm which is the default binding algorithm. To specify explicit bindings, use the <binder> view-state child element. See the ref docs of 2.0.3 for details.
Keith
Keith Donald
Core Spring Development Team
Hi,
I had this question of whether or not to use domain objects for getting form data. Since you have mentioned that you are keeping seperate set of classes for form data. I'd like to know where you keep them? under domain or web ? Also if any other have better idea please be kind enough to share
Under web, in dto. E.g., the package name myapp.web.dto. The controllers are in myapp.web.controller, two Decorator classes for DisplayTag which are in myapp.web.displaytag, and a Spring HandlerInterceptorAdapter is in myapp.web.interceptor.
It's almost as bad as Spring's sentence long class names.![]()
Enum binding will be available starting with tonight's 2.0.4 nightly build. Please give it a try and let us know if you run into any issues.
-Scott
Scott Andrews
Software Engineer, Web Products Team
SpringSource
Most excellent; thanks!
Hi all,
I've added following conversation service but its never used, its using toString function of Country model.
If I remove the conversation service, it throws exception.
Also If I remove the toString function it displays object's hash. (similar to com.eon.persistence.Countty@dahd123213)
Here's my webflow config file:
Here's my conversation service implementation. I've printed BLA BLA1 BLA2 but only BLA printed to console.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.springframework.org/schema/webflow-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd"> <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController"> <property name="flowExecutor" ref="flowExecutor"/> </bean> <flow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/> <flow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> <flow:flow-location path="/WEB-INF/webflows/public/register.xml" id="register"/> <flow:flow-location path="/WEB-INF/webflows/public/login.xml" id="login"/> <flow:flow-location path="/WEB-INF/webflows/public/index.xml" id="index"/> </flow:flow-registry> <bean id="conversionService" class="com.eon.ibuy.forms.IBuyTypeConversionService"/> <flow:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator" conversion-service="conversionService"/> <bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> <!--<property name="viewResolvers"> <list> <ref bean="viewResolver"/> </list> </property>--> <property name="viewResolvers" ref="tilesViewResolver"/> </bean> <bean id="publicLoginForm" class="com.eon.ibuy.forms.PublicLoginForm" scope="session"> </bean> <bean id="publicRegisterForm" class="com.eon.ibuy.persistence.Systemuser" scope="session"> </bean> </beans>
Here's my flow config:Code:package com.eon.ibuy.forms; import org.springframework.binding.convert.service.DefaultConversionService; import com.eon.ibuy.persistence.Country; public class IBuyTypeConversionService extends DefaultConversionService { @Override protected void addDefaultConverters() { super.addDefaultConverters(); addConverter(new CountryToString(Country.class)); } } package com.eon.ibuy.forms; import org.springframework.binding.convert.converters.StringToObject; import com.eon.ibuy.persistence.Country; public class CountryToString extends StringToObject { public CountryToString(Class country) { super(country); System.out.println("BLA"); } @Override protected Object toObject(String country_name, Class country) throws Exception { System.out.println("BLA1"); return null; } @Override protected String toString(Object country) throws Exception { System.out.println("BLA2"); return ((Country)country).getCountryName(); } }
Here's the register.jsp page part:Code:<?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> <view-state id="agreement" view="public/account/terms" redirect="false" popup="false"> <transition on="agree" to="prepare"/> </view-state> <action-state id="prepare"> <evaluate expression="CountryDAO.findAll()" result="flowScope.countries"> </evaluate> <transition on="success" to="show"/> </action-state> <view-state id="show" model="publicRegisterForm" view="public/account/register" redirect="false" popup="false"> </view-state> </flow>
Here's the Country.java file:Code:<form:select id="country" path="country" items="${countries}"> </form:select>
By the way I'm using model and dao classess which has been generated by hibernate reverse engineriing in myeclipse 7.Code:package com.eon.ibuy.persistence; import java.util.HashSet; import java.util.Set; /** * Country entity. @author MyEclipse Persistence Tools */ public class Country implements java.io.Serializable { // Fields private String countryId; private String countryIso3; private String countryName; private Set zones = new HashSet(0); private Set shops = new HashSet(0); private Set companies = new HashSet(0); private Set systemusers = new HashSet(0); private Set currencies = new HashSet(0); // Constructors /** default constructor */ public Country() { } /** minimal constructor */ public Country(String countryId, String countryIso3, String countryName) { this.countryId = countryId; this.countryIso3 = countryIso3; this.countryName = countryName; } /** full constructor */ public Country(String countryId, String countryIso3, String countryName, Set zones, Set shops, Set companies, Set systemusers, Set currencies) { this.countryId = countryId; this.countryIso3 = countryIso3; this.countryName = countryName; this.zones = zones; this.shops = shops; this.companies = companies; this.systemusers = systemusers; this.currencies = currencies; } // Property accessors public String getCountryId() { return this.countryId; } public void setCountryId(String countryId) { this.countryId = countryId; } public String getCountryIso3() { return this.countryIso3; } public void setCountryIso3(String countryIso3) { this.countryIso3 = countryIso3; } public String getCountryName() { return this.countryName; } public void setCountryName(String countryName) { this.countryName = countryName; } public Set getZones() { return this.zones; } public void setZones(Set zones) { this.zones = zones; } public Set getShops() { return this.shops; } public void setShops(Set shops) { this.shops = shops; } public Set getCompanies() { return this.companies; } public void setCompanies(Set companies) { this.companies = companies; } public Set getSystemusers() { return this.systemusers; } public void setSystemusers(Set systemusers) { this.systemusers = systemusers; } public Set getCurrencies() { return this.currencies; } public void setCurrencies(Set currencies) { this.currencies = currencies; } public String toString() { return countryName; } }
Last edited by digz6666; Apr 14th, 2009 at 12:55 AM.
Let's care our nature!
Make sure you're running 2.0.6 or >
Keith Donald
Core Spring Development Team
The problem fixed in version 2.0.6 so I've removed the toString function from my model class.
But I have another problem. I'm using render fragment but it hides all the dojo decorated text inputs.
I'm creating registration form, when user selects country, zones in selected country must have fetched from database and bind to select. It successfully fetched from database but not bind and hides text inputs.
Here's the register.xml flow definition:
Here's the register.jsp file part. (I'm using tiles 2):Code:<?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> <view-state id="agreement" view="public/account/terms" redirect="false" popup="false"> <transition on="agree" to="setup"/> </view-state> <action-state id="setup"> <evaluate expression="publicRegisterFormAction.setupForm(flowRequestContext)"> </evaluate> <evaluate expression="publicRegisterFormAction.initForm(flowRequestContext)"> <attribute name="name" value="init"/> <attribute name="operation" value="0"/> </evaluate> <transition on="success" to="fetchCountries"/> </action-state> <action-state id="fetchCountries"> <evaluate expression="CountryDAO.findAll()" result="flowScope.countries"/> <transition on="success" to="show"/> </action-state> <view-state id="show" model="publicRegisterForm" view="public/account/register" redirect="false" popup="false"> <transition on="checkRegister" to="checkRegister" validate="false"/> <transition on="fetchZones" validate="false"> <evaluate expression="ZoneDAO.findAll()" result="flowScope.zones"/> <render fragments="body"/> </transition> </view-state> <action-state id="checkRegister"> <evaluate expression="publicRegisterFormAction.bindAndValidate(flowRequestContext)"/> <transition on="success" to="processRegister"/> </action-state> <action-state id="processRegister"> <evaluate expression="SystemUserDAO.save(publicRegisterForm)"/> </action-state> </flow>
Here's the typical debug result (taken from console):Code:<table style="width: 400px;"> <tr> <td>Country</td> <td> <form:select id="country" path="country"> <c:forEach var="cur_country" items="${countries}"> <form:option id="${cur_country.countryId}" value="${cur_country.countryName}"></form:option> </c:forEach> </form:select> <script type="text/javascript"> Spring.addDecoration(new Spring.AjaxEventDecoration({ elementId: "country", formId: "publicRegisterForm", event: "onchange", params: { _eventId: "fetchZones", country_id: dojo.byId('country').value } })); </script> </td> </tr> <tr> <td>Zone</td> <td> <div id="zoneDiv"> <form:select id="zone" path="zone"> <c:forEach var="cur_zone" items="${zones}"> <form:option id="${cur_zone.zoneId}" value="${cur_zone.zoneName}"></form:option> </c:forEach> </form:select> </div> </td> </tr> <tr> <td>City</td> <td> </td> </tr> <tr> <td>District</td> <td></td> </tr> <tr> <td>Street</td> <td></td> </tr> <tr> <td>Address</td> <td></td> </tr> </table>
If you need the war file (included java source files) I've uploaded here:Code:DEBUG: org.springframework.webflow.mvc.view.AbstractMvcView - Rendering MVC [org.springframework.webflow.mvc.view.FlowAjaxTilesView: name 'public/account/register'; URL [public/account/register]] with model map [{webflowViewActionStateHolder=[ViewActionStateHolder@5b84b eventId = 'checkRegister', mappingResults = Mapping Results = [[TargetAccessError@618565 mapping = parameter:'password' -> password, code = 'typeMismatch', error = true, errorCause = org.springframework.binding.expression.ValueCoercionException: Value could not be converted to target class; is a suitable type converter registered?, originalValue = array<String>['12', '12'], mappedValue = [null]], [Success@1664f1a mapping = parameter:'country' -> country, code = 'success', error = false, originalValue = 'Mongolia', mappedValue = 'Mongolia'], [Success@1d33eef mapping = parameter:'userId' -> userId, code = 'success', error = false, originalValue = '12', mappedValue = '12'], [TargetAccessError@1c8f644 mapping = parameter:'email' -> email, code = 'typeMismatch', error = true, errorCause = org.springframework.binding.expression.ValueCoercionException: Value could not be converted to target class; is a suitable type converter registered?, originalValue = array<String>['', ''], mappedValue = [null]], [Success@9ff588 mapping = parameter:'middleName' -> middleName, code = 'success', error = false, originalValue = '', mappedValue = ''], [TargetAccessError@1b0d2d0 mapping = null -> eventId, code = 'propertyNotFound', error = true, errorCause = org.springframework.binding.expression.PropertyNotFoundException: Property not found, originalValue = [null], mappedValue = [null]], [Success@1e06b12 mapping = parameter:'firstName' -> firstName, code = 'success', error = false, originalValue = '', mappedValue = ''], [TargetAccessError@9576fd mapping = parameter:'execution' -> execution, code = 'propertyNotFound', error = true, errorCause = org.springframework.binding.expression.PropertyNotFoundException: Property not found, originalValue = 'e4s2', mappedValue = [null]], [Success@b6e385 mapping = parameter:'lastName' -> lastName, code = 'success', error = false, originalValue = '', mappedValue = '']]], viewScope=map[[empty]], org.springframework.validation.BindingResult.publicRegisterForm=org.springframework.webflow.mvc.view.BindingModel: 2 errors Field error in object 'publicRegisterForm' on field 'password': rejected value [null]; codes []; arguments []; default message [typeMismatch on password] Field error in object 'publicRegisterForm' on field 'email': rejected value [null]; codes []; arguments []; default message [typeMismatch on email], currentFormObject=com.eon.ibuy.persistence.Systemuser@1baa8d8, flashScope=map['webflowViewActionStateHolder' -> [ViewActionStateHolder@5b84b eventId = 'checkRegister', mappingResults = Mapping Results = [[TargetAccessError@618565 mapping = parameter:'password' -> password, code = 'typeMismatch', error = true, errorCause = org.springframework.binding.expression.ValueCoercionException: Value could not be converted to target class; is a suitable type converter registered?, originalValue = array<String>['12', '12'], mappedValue = [null]], [Success@1664f1a mapping = parameter:'country' -> country, code = 'success', error = false, originalValue = 'Mongolia', mappedValue = 'Mongolia'], [Success@1d33eef mapping = parameter:'userId' -> userId, code = 'success', error = false, originalValue = '12', mappedValue = '12'], [TargetAccessError@1c8f644 mapping = parameter:'email' -> email, code = 'typeMismatch', error = true, errorCause = org.springframework.binding.expression.ValueCoercionException: Value could not be converted to target class; is a suitable type converter registered?, originalValue = array<String>['', ''], mappedValue = [null]], [Success@9ff588 mapping = parameter:'middleName' -> middleName, code = 'success', error = false, originalValue = '', mappedValue = ''], [TargetAccessError@1b0d2d0 mapping = null -> eventId, code = 'propertyNotFound', error = true, errorCause = org.springframework.binding.expression.PropertyNotFoundException: Property not found, originalValue = [null], mappedValue = [null]], [Success@1e06b12 mapping = parameter:'firstName' -> firstName, code = 'success', error = false, originalValue = '', mappedValue = ''], [TargetAccessError@9576fd mapping = parameter:'execution' -> execution, code = 'propertyNotFound', error = true, errorCause = org.springframework.binding.expression.PropertyNotFoundException: Property not found, originalValue = 'e4s2', mappedValue = [null]], [Success@b6e385 mapping = parameter:'lastName' -> lastName, code = 'success', error = false, originalValue = '', mappedValue = '']]]], flowExecutionUrl=/ibuy/register.ibuy?execution=e4s2, flowRequestContext=[RequestControlContextImpl@1a30706 externalContext = org.springframework.webflow.mvc.servlet.MvcExternalContext@749ebc, currentEvent = [null], requestScope = map[[empty]], attributes = map[[empty]], messageContext = [DefaultMessageContext@18662b6 sourceMessages = map[[null] -> list[[empty]], 'password' -> list[[Message@1aabc29 source = 'password', severity = Error, text = 'typeMismatch on password']], 'email' -> list[[Message@1bd5f28 source = 'email', severity = Error, text = 'typeMismatch on email']]]], flowExecution = [FlowExecutionImpl@223d9b flow = 'register', flowSessions = list[[FlowSessionImpl@1fa8d3b flow = 'register', state = 'show', scope = map['viewScope' -> map[[empty]], 'currentFormObject' -> com.eon.ibuy.persistence.Systemuser@1baa8d8, 'systemuser' -> com.eon.ibuy.persistence.Systemuser@1baa8d8, 'countries' -> list[com.eon.ibuy.persistence.Country@4e4fc4, com.eon.ibuy.persistence.Country@156f920]]]]]], flowExecutionKey=e4s2, systemuser=com.eon.ibuy.persistence.Systemuser@1baa8d8, countries=[com.eon.ibuy.persistence.Country@4e4fc4, com.eon.ibuy.persistence.Country@156f920], currentUser=null}]
Could you please explain me why the dojo decorated text inputs hidden and zones not displaying?Code:http://www.mediafire.com/?izj5czjyojt
Please help me.
Last edited by digz6666; Apr 14th, 2009 at 12:42 PM.
Let's care our nature!
I would suggest breaking your second question out into a separate forum thread, since it's a different topic all together. Also, make sure you outline what you're trying to accomplish functionally before you dive into the technical approach. Might get more eyes on it that way.
Keith
Keith Donald
Core Spring Development Team
My english is bad. So that's why I asking noob questions.
Here's the screenshots of my webapp:
1. It's in show state:
2. I changed the country combobox and ajax event fired. 1st textfield disappeared.
3. After sevelal changes all the textfields disappeared except undecorated textfield.
Please help me to solve it.
When I solved my issue I write small tutorial in this forum.
Let's care our nature!