You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "James S. Carlson" <js...@speakeasy.net> on 2001/05/06 20:31:14 UTC

Popup Lists

Is there functionality within Turbine somewhere to build popup lists on the
fly and set their value (from the peer) automatically?  I checked through
the apidocs, and found only the nice date selector builder.

What I did (waaaay back in the day, using GSP) is create a PopupLoader class
that would, given a table and query expression, return a, well, what they
called a FormLabel which contained a String[] of keys and a Hashtable of
key-value maps.  This could then be passed to one of the form methods like
.getList() which would return HTML for the element, automatically selecting
the 'currently selected' value based on the request's parameters.  I'd then
stick all the FormLabels I built this way into the Application Context
because they didn't change very often, and that was as close as I could come
to the Cache service back then. :-)

So now, I'd generate something analogous to a FormLabel using
Peers/Criteria, and put it into the cache, I think.  Then setting the
'currently selected' value based on the current request's parameters, or on
the value of the actual Peer object being edited--what is the appropriate
place to hook that into the framework?

Or am I barking up a pre-barked tree?

Thanks,
James Carlson


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


Re: Popup Lists

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/6/01 11:31 AM, "James S. Carlson" <js...@speakeasy.net> wrote:

> Or am I barking up a pre-barked tree?
> 
> Thanks,
> James Carlson

If you are using Velocity, then just create a little Velcimacro that does
the job.

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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


RE: Popup Lists - found SelectorBox, jon. :)

Posted by "James S. Carlson" <js...@speakeasy.net>.
Thanks, Jon.

It looks like if I pull down Scarab, I can see how just about everything is
used in a production-esque environment.  I want to get past the
Scarab-specific vocabulary to understand where things like the intake
service get initialized and so on... but this is all beginning to make sense
now.

James

-----Original Message-----
From: Jon Stevens [mailto:jon@latchkey.com]
Sent: Sunday, May 06, 2001 4:46 PM
To: Turbine-user
Subject: Re: Popup Lists - found SelectorBox, jon. :)


on 5/6/01 2:33 PM, "James S. Carlson" <js...@speakeasy.net> wrote:

> Yes, now that I've gone through the trouble of using a SelectorBox in this
> way, I'm thinking I need a better solution.  To use a Velocimacro for
this,
> I'd need something like
>
> #macro (listBox $name $values $selected $multiple $size $onchange)
> <select name="$name" #if($onchange) $onchange #end #if($multiple) multiple
> #end size=#if($size) "$size" #else "1" #end>
>   #foreach ($value in $values)
>   <option value="$value.key">$value.label</option>
>   #end
> </select>
> #end

Close:

<http://scarab.tigris.org/source/browse/scarab/src/templates/GlobalMacros.vm
?rev=1.9&content-type=text/x-cvsweb-markup>

> And that would mean that I'd need to make a special object for this, so
that
> $value.key would always correspond to the key, and $value.label would
always
> correspond to the label.

Well, that is why we created Intake. :-) Intake's job is to map form data to
the BO's.

The stack looks something like this:

------------------
   HTML Form
------------------
    Intake
------------------
 Business Objects
------------------
     Peers
------------------
     RDBMS
------------------

One way to do that without using Intake would be to make it so that any
object which would need to be represented by a listBox would implement an
interface which would have a getKey/getLabel methods in it.

> Furthermore, I'd need something like another foreach loop inside this one
to
> determine if the current $value is in $selected.  Unless there's some way
to
> do that in Velocity already, like #if($value in $selected)?  I don't think
> so.  Hm.

@see Scarab Example

-jon

--
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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



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


Re: Popup Lists - found SelectorBox, jon. :)

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/6/01 2:33 PM, "James S. Carlson" <js...@speakeasy.net> wrote:

> Yes, now that I've gone through the trouble of using a SelectorBox in this
> way, I'm thinking I need a better solution.  To use a Velocimacro for this,
> I'd need something like
> 
> #macro (listBox $name $values $selected $multiple $size $onchange)
> <select name="$name" #if($onchange) $onchange #end #if($multiple) multiple
> #end size=#if($size) "$size" #else "1" #end>
>   #foreach ($value in $values)
>   <option value="$value.key">$value.label</option>
>   #end
> </select>
> #end

Close:

<http://scarab.tigris.org/source/browse/scarab/src/templates/GlobalMacros.vm
?rev=1.9&content-type=text/x-cvsweb-markup>

> And that would mean that I'd need to make a special object for this, so that
> $value.key would always correspond to the key, and $value.label would always
> correspond to the label.

Well, that is why we created Intake. :-) Intake's job is to map form data to
the BO's.

The stack looks something like this:

------------------
   HTML Form
------------------
    Intake
------------------
 Business Objects
------------------
     Peers
------------------
     RDBMS
------------------

One way to do that without using Intake would be to make it so that any
object which would need to be represented by a listBox would implement an
interface which would have a getKey/getLabel methods in it.

> Furthermore, I'd need something like another foreach loop inside this one to
> determine if the current $value is in $selected.  Unless there's some way to
> do that in Velocity already, like #if($value in $selected)?  I don't think
> so.  Hm.

@see Scarab Example

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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


RE: Popup Lists - found SelectorBox, jon. :)

Posted by "James S. Carlson" <js...@speakeasy.net>.
Yes, now that I've gone through the trouble of using a SelectorBox in this
way, I'm thinking I need a better solution.  To use a Velocimacro for this,
I'd need something like

#macro (listBox $name $values $selected $multiple $size $onchange)
  <select name="$name" #if($onchange) $onchange #end #if($multiple) multiple
#end size=#if($size) "$size" #else "1" #end>
    #foreach ($value in $values)
    <option value="$value.key">$value.label</option>
    #end
  </select>
#end

Yes?

And that would mean that I'd need to make a special object for this, so that
$value.key would always correspond to the key, and $value.label would always
correspond to the label.

Furthermore, I'd need something like another foreach loop inside this one to
determine if the current $value is in $selected.  Unless there's some way to
do that in Velocity already, like #if($value in $selected)?  I don't think
so.  Hm.

-----Original Message-----
From: Jon Stevens [mailto:jon@latchkey.com]
Sent: Sunday, May 06, 2001 2:43 PM
To: Turbine-user
Subject: Re: Popup Lists - found SelectorBox, jon. :)


on 5/6/01 12:13 PM, "James S. Carlson" <js...@speakeasy.net> wrote:

> Ok, anyone else who has asked before, look at
> org.apache.turbine.util.template.SelectorBox
>
> You rock, Jon.
>
> I think I'd still love to work on some cacheing version of this that I
can:
> 1. Pull out of the cache a pre-filled SelectorBox
> 2. Set the 'selected' items
> 3. Stick in template context

Yes, that works as well, but is a more deprecated solution in my eyes (much
like ECS is) because we are trying to keep as much of the View in the
template as possible. That code was written before Velocimacro's were
available so it was a good solution for the time because Select boxes are
about the only HTML you can embed in code without having to worry about
people being able to modify it...

Also, the caching should happen in the business objects, not in the
SelectorBox. If you look in Scarab at the Attribute.java class, you can see
how we are caching things using the TurbineGlobalCache service.

Thanks,

-jon

--
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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



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


Re: Popup Lists - found SelectorBox, jon. :)

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/6/01 12:13 PM, "James S. Carlson" <js...@speakeasy.net> wrote:

> Ok, anyone else who has asked before, look at
> org.apache.turbine.util.template.SelectorBox
> 
> You rock, Jon.
> 
> I think I'd still love to work on some cacheing version of this that I can:
> 1. Pull out of the cache a pre-filled SelectorBox
> 2. Set the 'selected' items
> 3. Stick in template context

Yes, that works as well, but is a more deprecated solution in my eyes (much
like ECS is) because we are trying to keep as much of the View in the
template as possible. That code was written before Velocimacro's were
available so it was a good solution for the time because Select boxes are
about the only HTML you can embed in code without having to worry about
people being able to modify it...

Also, the caching should happen in the business objects, not in the
SelectorBox. If you look in Scarab at the Attribute.java class, you can see
how we are caching things using the TurbineGlobalCache service.

Thanks,

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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


RE: Popup Lists - found SelectorBox, jon. :)

Posted by "James S. Carlson" <js...@speakeasy.net>.
Ok, anyone else who has asked before, look at
org.apache.turbine.util.template.SelectorBox

You rock, Jon.

I think I'd still love to work on some cacheing version of this that I can:
1. Pull out of the cache a pre-filled SelectorBox
2. Set the 'selected' items
3. Stick in template context

-----Original Message-----
From: James S. Carlson [mailto:jsc@speakeasy.net]
Sent: Sunday, May 06, 2001 1:31 PM
To: turbine-user@jakarta.apache.org
Subject: Popup Lists


Is there functionality within Turbine somewhere to build popup lists on the
fly and set their value (from the peer) automatically?  I checked through
the apidocs, and found only the nice date selector builder.

What I did (waaaay back in the day, using GSP) is create a PopupLoader class
that would, given a table and query expression, return a, well, what they
called a FormLabel which contained a String[] of keys and a Hashtable of
key-value maps.  This could then be passed to one of the form methods like
.getList() which would return HTML for the element, automatically selecting
the 'currently selected' value based on the request's parameters.  I'd then
stick all the FormLabels I built this way into the Application Context
because they didn't change very often, and that was as close as I could come
to the Cache service back then. :-)

So now, I'd generate something analogous to a FormLabel using
Peers/Criteria, and put it into the cache, I think.  Then setting the
'currently selected' value based on the current request's parameters, or on
the value of the actual Peer object being edited--what is the appropriate
place to hook that into the framework?

Or am I barking up a pre-barked tree?

Thanks,
James Carlson


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



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