struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabian Richter <frich...@mtg.de>
Subject Not calling setters when callchaining into fields and using complex type, bug or feature?
Date Thu, 03 Apr 2014 09:19:24 GMT
Hey,

not sure this is a Bug or a Feature, but I ran into the following 
troubles, someone might be able to explain:

class ComplexType {
	private DifferentComplexType test;

	public void setTest(DifferentComplexType test){
		this.test = test;
	}
	public DifferentComplexType getTest(){
		return this.test;
	}
}

In an action class I have

	private ComplexType field;

	public ComplexType getField(){
		return this.field;
	}

	public void setField(ComplexType field){
		this.field = field;
	}

Now in this Action, I am setting "test" with a <s:select list="..." 
key="field.test" headerKey="" headerValue="Undefined" />

But when I want to null it, by selecting the header entry "Undefined", 
Struts is not calling getField().setTest() its not changing "test" in 
"field" at all.

When I add to my action

	public DifferentComplexType getTest(){
		return this.field.getTest();
	}

	public void setTest(DifferentComplexType test){
		this.field.setTest(test);
	}

and change the <s:select> to use key="test" it works like a charm.

Is that how its supposed to be? If so, why?

Thank you for explaining!

Best
Fabian


Mime
View raw message