You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Stevens, Jeffrey L (Dev Resource Central)" <je...@hp.com> on 2005/08/30 22:26:50 UTC

Setting RadioGroup selected attribute

I have a Java object called Test which defines a HashMap private member
called  Questions. This HashMap has question names for keys and
responses to the question for values.  These Questions can be different
from one instance of the object to the next and are populated from
persistent storage.

For example, one instance of TestRequest might have attributes such as:

TestRequest.Attributes {
	"Test1Question1", "Yes",
	"Test1Question2", "No",
	"Test1Question3", "Yes"}

While another instance of TestRequest may have attributes such as:

TestRequest.Attributes (
	"Test2Question1" "N/A",
	"Test2Question2", "No"}

The object Test is not a formal Java Bean in that it does not define
specific getters/setters for each possible Question.  Rather I have a
getQuestion(QuestionName) method and a setQuestion(QuestionName,
QuestionResponse) method.  This is so that I don't have to define a
specific getter/setter for every possible Question, which can be
dynamically defined.

My problem is that I would like to bing the selected attribute of a
RadioGroup to specific values from this Test.Questions HashMap, but
since it doesn't have the typical getter/setter methods how would I bind
the value of the RadioGroup's selected attribute?






---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Setting RadioGroup selected attribute

Posted by Kent Tong <ke...@cpttm.org.mo>.
Stevens, Jeffrey L (Dev Resource Central <jeff.stevens <at> hp.com> writes:

> My problem is that I would like to bing the selected attribute of a
> RadioGroup to specific values from this Test.Questions HashMap, but
> since it doesn't have the typical getter/setter methods how would I bind
> the value of the RadioGroup's selected attribute?

try:

  <binding name="selected" expression="question['question1']">

This will call getQuestion("question1") to get the value and
setQuestion("question1", <selected-value>) to set the value.

--
Author of e-book for learning Tapestry (www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org