You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stephan Coboos <cr...@gmx.net> on 2005/06/28 09:34:27 UTC

[Cforms] How to reproduce the selection state?

Hello,

I need to bind a bean to a form using Cforms. My bean looks like this:

public class MyBean {

	String name;
	String description;
	List cars;

	// ... Setter and Getter here

	// Returns the selected car
	String getSelectedCar()...
}

I know how to bind this values to the form using the binding xml. But I
don't know how to repoduce the selection state of the cars list coming form
a presistence layer like the database. Let's say the bean contains the
following values right after loading it from the database:

name = Foo
description = Bar
cars = {BMW, Audi, Peugeot}
getSelectedCar = Audi

How can I reproduce the form in order to select "Audi" in the dropdown box
for cars automatically?

Thank you a lot!

Regards
Stephan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Cforms] How to reproduce the selection state?

Posted by Jorg Heymans <jh...@domek.be>.

Stephan Coboos wrote:
> 
> How can I reproduce the form in order to select "Audi" in the dropdown box
> for cars automatically?

http://cocoon.apache.org/2.1/userdocs/forms/datatypes.html#Selection+lists+%28default+implementation%29

"To set a default selection, just set the value of the widget containing
the selection list."

So this would translate into something like (untested)

  <fb:javascript id="cars" path="cars" direction="load">
    <fb:load-form>
      var selectedCar = getSelectedCar(); // this calls into flowscript
      widget.setValue(selectedCar);
    </fb:load-form>
  </fb:javascript>


HTH,
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: AW: AW: [Cforms] How to reproduce the selection state?

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-06-28 08:14:29 -0700, "Stephan Coboos" <cr...@gmx.net> said:

> Ahh, that's it!
> 	<fb:value="selected-car" path="selectedCar"/>
>> 
> This was the line I've missed. Thx! :)
> 
:-)

But what can I do, if more than one car can be selected?
> 
No difference.  Your bean will then be of type Set, right?
—ml—



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: AW: [Cforms] How to reproduce the selection state?

Posted by Stephan Coboos <cr...@gmx.net>.
Ahh, that's it! 

> 	<fb:value="selected-car" path="selectedCar"/>

This was the line I've missed. Thx! :)

But what can I do, if more than one car can be selected?

Thank you, Mark!

Regards
Stephan

> -----Ursprüngliche Nachricht-----
> Von: news [mailto:news@sea.gmane.org] Im Auftrag von Mark Lundquist
> Gesendet: Dienstag, 28. Juni 2005 16:52
> An: users@cocoon.apache.org
> Betreff: Re: AW: [Cforms] How to reproduce the selection state?
> 
> On 2005-06-28 04:00:46 -0700, "Stephan Coboos" 
> <cr...@gmx.net> said:
> 
> > Hi Mark,
> > 
> > Thanks for your answer.
> > 
> >>> name = Foo
> >>> description = Bar
> >>> cars = {BMW, Audi, Peugeot}
> >>> getSelectedCar = Audi
> >>> 
> >> I don't see the problem.  If cars and selectedCar are both bean 
> >> properties, why should it make a difference what the values are or 
> >> that they came from a database?
> >> 
> >> 
> >>> How can I reproduce the form in order to select "Audi" in the 
> >>> dropdown box for cars automatically?
> >>> 
> >> It should "just work" (;-)... have you tried it?
> > 
> > No, because I don't know how to say to Cforms that it have 
> to select 
> > Audi at form load.
> 
> So... how is that not just
> 
> 	form.load (bean);
> 
> ???  I must just not be understanding your question :-/
> 
> You have
> 
> 	<fb:value="selected-car" path="selectedCar"/>
> 
> or something along those lines, right?
> 
> —ml—
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: AW: [Cforms] How to reproduce the selection state?

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-06-28 04:00:46 -0700, "Stephan Coboos" <cr...@gmx.net> said:

> Hi Mark,
> 
> Thanks for your answer.
> 
>>> name = Foo
>>> description = Bar
>>> cars = {BMW, Audi, Peugeot}
>>> getSelectedCar = Audi
>>> 
>> I don't see the problem.  If cars and selectedCar are both bean 
>> properties, why should it make a difference what the values are or that 
>> they came from a database?
>> 
>> 
>>> How can I reproduce the form in order to select "Audi" in the dropdown 
>>> box for cars automatically?
>>> 
>> It should "just work" (;-)... have you tried it?
> 
> No, because I don't know how to say to Cforms that it have to select Audi at
> form load.

So... how is that not just

	form.load (bean);

???  I must just not be understanding your question :-/

You have

	<fb:value="selected-car" path="selectedCar"/>

or something along those lines, right?

—ml—



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: [Cforms] How to reproduce the selection state?

Posted by Stephan Coboos <cr...@gmx.net>.
Hi Mark,

Thanks for your answer.

> > name = Foo
> > description = Bar
> > cars = {BMW, Audi, Peugeot}
> > getSelectedCar = Audi
> > 
> I don't see the problem.  If cars and selectedCar are both 
> bean properties, why should it make a difference what the 
> values are or that they came from a database?
> 
> 
> > How can I reproduce the form in order to select "Audi" in 
> the dropdown 
> > box for cars automatically?
> > 
> It should "just work" (;-)... have you tried it?

No, because I don't know how to say to Cforms that it have to select Audi at
form load. How can I do this? In flowscript or is there an attribute like
selectedItemGetter="getSelectedCar". And what about multiselections?

Thank you thery much for your help.

Regards
Stephan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Cforms] How to reproduce the selection state?

Posted by Mark Lundquist <ml...@comcast.net>.
Hi Stephan,

> Hello,
> 
> I need to bind a bean to a form using Cforms. My bean looks like this:
> 
> public class MyBean {
> 
> 	String name;
> 	String description;
> 	List cars;
> 
> 	// ... Setter and Getter here
> 
> 	// Returns the selected car
> 	String getSelectedCar()...
> }
> 
> I know how to bind this values to the form using the binding xml.
> 
OK...

But I
> don't know how to repoduce the selection state of the cars list coming form
> a presistence layer like the database. Let's say the bean contains the
> following values right after loading it from the database:
> 
> name = Foo
> description = Bar
> cars = {BMW, Audi, Peugeot}
> getSelectedCar = Audi
> 
I don't see the problem.  If cars and selectedCar are both bean 
properties, why should it make a difference what the values are or that 
they came from a database?


> How can I reproduce the form in order to select "Audi" in the dropdown box
> for cars automatically?
> 
It should "just work" (;-)... have you tried it?

—ml—



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org