You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by LS <al...@yahoo.com> on 2001/10/31 07:30:11 UTC

Looking for a good way to handle this in Velocity

Sorry, I couldn't come up with a better subject line.

I have come across something that I'm not sure how to implement in Velocity in a
clean way. I create a multiple select widget and populate it with categories like
this:

 <select multiple size=6 name=included[]>
            #foreach ($category in $model.Categories)
            <option value='$category' >$category
            #end
 </select>

That works fine. What I really want to do is figure out, for each category in the
category list, if the $category is an element in the $model.Included array, so I
could add the "selected" modifier to the <option> tag. 

Is there a MVC-friendly way to do this?

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Looking for a good way to handle this in Velocity

Posted by "Trever M. Shick" <ts...@objectwave.com>.
I think I would do this in the following way:

MySourceClass {
    String[] categories = // whatever;
    String selectedCategory = whatever;

    Vector getCategories() {
        Vector ret = new Vector();
        for (int i=0;i < categories.length; i++) {
            SelectionItem si = new SelectionItem();
            si.value = categories[i];
            si.description = categories[i];
            if (categories[i].equals(selectedCategory)) si.selected = true;
        }        
        return ret;
    }

    public static class SelectionItem {
        boolean selected;
        String value;
        String description;
        // getter methods...
     }
}


 
 <select multiple size=6 name=included[]> 
            #foreach ($item in $model.categories) 
           <option value='${item.value}' >${item.description} #if (${item.selected}) selected #end
            #end 
 </select> 

  ----- Original Message ----- 
  From: Emmanuel Cuevas 
  To: Velocity Users List 
  Sent: Wednesday, October 31, 2001 8:57 AM
  Subject: Re: Looking for a good way to handle this in Velocity


  LS escribió: 
    Sorry, I couldn't come up with a better subject line. 
    I have come across something that I'm not sure how to implement in Velocity in a 
    clean way. I create a multiple select widget and populate it with categories like 
    this: 

     <select multiple size=6 name=included[]> 
                #foreach ($category in $model.Categories) 
                <option value='$category' >$category 
                #end 
     </select> 

    That works fine. What I really want to do is figure out, for each category in the 
    category list, if the $category is an element in the $model.Included array, so I 
    could add the "selected" modifier to the <option> tag. 

    Is there a MVC-friendly way to do this? 

    __________________________________________________ 
    Do You Yahoo!? 
    Make a great connection at Yahoo! Personals. 
    http://personals.yahoo.com 

    -- 
    To unsubscribe, e-mail:   <ma...@jakarta.apache.org> 
    For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker
    


------------------------------------------------------------------------------


  --
  To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  For additional commands, e-mail: <ma...@jakarta.apache.org>

Re: Problems with navigation on templates

Posted by Dan Bachelder <ch...@chowda.net>.
this is a turbine question.. the whole $screen_placeholder and $navigation
this is turbine specific... the placeholder is your "screen" in turbine...
so if you want 2 dynamic things in there just make your "screen" parse two
other VM files...  the syntax is velocity but the semantics are turbine...

----- Original Message -----
From: Emmanuel Cuevas
To: Velocity Users List
Sent: Friday, November 02, 2001 11:18 AM
Subject: Re: Problems with navigation on templates


Well, I don't tjink it's for thr turbine list, 'case I'm usin' Velocimacros,
and I feel this question belongs here....   =)
What I'm traing to do, is tho have a page with two dynamic elements without
using frames....
Cheers !!
Dan Bachelder escribió:
this is a turbine question right? you might try the turbine list... I use
turbine, but i have not had the need to do what you are doing... sorry..
----- Original Message -----
From: Emmanuel Cuevas
To: Velocity Users List
Sent: Thursday, November 01, 2001 10:25 AM
Subject: Re: Problems with navigation on templates
Hello !!
Right now im thinking in changin the structure, buet I'd like to know if I
can have 2 screen_placeholders... here is my code, but I want to add an
additional
screen_placeholder but I cannot find if this is posible, in the
documentation says nothing about this issue...
here is my current code:
<table width="100%">
  <tr>
    <td colspan="2">
      $navigation.setTemplate("/DefaultTop.vm")
    </td>
  </tr>
  <tr>
    <td align="left" valign="top">
      $screen_placeholder
    </td>
    <td width="20" align="right" valign="top">
      $navigation.setTemplate("/Menu.vm")
    </td>
  </tr>
  <tr>
    <td colspan="2">
      $navigation.setTemplate("/DefaultBottom.vm")
    </td>
  </tr>
</table>
It belongs to my Default.vm file, and here is where I want to add the other
screen_placeholder.
Any thoughts ???
Thanks in advance !!!
Dan Bachelder escribió:
Are you using #include()? you should use #parse() if you want velocity to
parse the file.... otherwise its just like doing a SSI..
----- Original Message -----
From: Emmanuel Cuevas
To: Velocity Users List
Sent: Wednesday, October 31, 2001 11:47 AM
Subject: Problems with navigation on templates
Hi everyone !!
I it seems that no long ago I replied an email by accident, sorry  =)
Well, here is my problem:
I want to use more than one template for formating a web page,
but when I try to load a navigation template from a screen template
I just a web page showing the variable names but without format nor data.
I'd like to know how can I achieve such loading process !!
Any suggestion ??
Thanks in advance
--
Emmanuel Cuevas
Senior Developer
ecuevasr@iac.com.mx
"If you gotta go, go with a smile"
                        The Joker
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
Emmanuel Cuevas
Senior Developer
ecuevasr@iac.com.mx
"If you gotta go, go with a smile"
                        The Joker
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problems with navigation on templates

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Please stop the HTML emails.

Where are the Velocimacros?

Also, what is a screen_placeholder?  That isn't a Velocity concept.

Geir


On 11/2/01 11:18 AM, "Emmanuel Cuevas" <ec...@iac.com.mx> wrote:

> Well, I don't tjink it's for thr turbine list, 'case I'm usin' Velocimacros,
> and I feel this question belongs here....   =)
> 
> What I'm traing to do, is tho have a page with two dynamic elements without
> using frames.... 
> 
> Cheers !! 
> 
> Dan Bachelder escribió:
>> this is a turbine question right? you might try the turbine list... I use
>> turbine, but i have not had the need to do what you are doing... sorry..
>> 
>> ----- Original Message -----
>> From: Emmanuel Cuevas
>> To: Velocity Users List
>> Sent: Thursday, November 01, 2001 10:25 AM
>> Subject: Re: Problems with navigation on templates
>> 
>> Hello !! 
>> Right now im thinking in changin the structure, buet I'd like to know if I
>> can have 2 screen_placeholders... here is my code, but I want to add an
>> additional 
>> screen_placeholder but I cannot find if this is posible, in the
>> documentation says nothing about this issue...
>> here is my current code:
>> <table width="100%">
>> <tr> 
>>   <td colspan="2">
>>     $navigation.setTemplate("/DefaultTop.vm")
>>   </td> 
>> </tr> 
>> <tr> 
>>   <td align="left" valign="top">
>>     $screen_placeholder
>>   </td> 
>>   <td width="20" align="right" valign="top">
>>     $navigation.setTemplate("/Menu.vm")
>>   </td> 
>> </tr> 
>> <tr> 
>>   <td colspan="2">
>>     $navigation.setTemplate("/DefaultBottom.vm")
>>   </td> 
>> </tr> 
>> </table> 
>> It belongs to my Default.vm file, and here is where I want to add the other
>> screen_placeholder.
>> Any thoughts ???
>> Thanks in advance !!!
>> 
>> Dan Bachelder escribió:
>> Are you using #include()? you should use #parse() if you want velocity to
>> parse the file.... otherwise its just like doing a SSI..
>> ----- Original Message -----
>> From: Emmanuel Cuevas
>> To: Velocity Users List
>> Sent: Wednesday, October 31, 2001 11:47 AM
>> Subject: Problems with navigation on templates
>> Hi everyone !! 
>> I it seems that no long ago I replied an email by accident, sorry =)
>> Well, here is my problem:
>> I want to use more than one template for formating a web page,
>> but when I try to load a navigation template from a screen template
>> I just a web page showing the variable names but without format nor data.
>> I'd like to know how can I achieve such loading process !!
>> Any suggestion ??
>> Thanks in advance


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problems with navigation on templates

Posted by Emmanuel Cuevas <ec...@iac.com.mx>.
Well, I don't tjink it's for thr turbine list, 'case I'm usin' Velocimacros, and I
feel this question belongs here....   =)

What I'm traing to do, is tho have a page with two dynamic elements without using
frames....

Cheers !!

Dan Bachelder escribió:

> this is a turbine question right? you might try the turbine list... I use
> turbine, but i have not had the need to do what you are doing... sorry..
>
> ----- Original Message -----
> From: Emmanuel Cuevas
> To: Velocity Users List
> Sent: Thursday, November 01, 2001 10:25 AM
> Subject: Re: Problems with navigation on templates
>
> Hello !!
> Right now im thinking in changin the structure, buet I'd like to know if I
> can have 2 screen_placeholders... here is my code, but I want to add an
> additional
> screen_placeholder but I cannot find if this is posible, in the
> documentation says nothing about this issue...
> here is my current code:
> <table width="100%">
>   <tr>
>     <td colspan="2">
>       $navigation.setTemplate("/DefaultTop.vm")
>     </td>
>   </tr>
>   <tr>
>     <td align="left" valign="top">
>       $screen_placeholder
>     </td>
>     <td width="20" align="right" valign="top">
>       $navigation.setTemplate("/Menu.vm")
>     </td>
>   </tr>
>   <tr>
>     <td colspan="2">
>       $navigation.setTemplate("/DefaultBottom.vm")
>     </td>
>   </tr>
> </table>
> It belongs to my Default.vm file, and here is where I want to add the other
> screen_placeholder.
> Any thoughts ???
> Thanks in advance !!!
>
> Dan Bachelder escribió:
> Are you using #include()? you should use #parse() if you want velocity to
> parse the file.... otherwise its just like doing a SSI..
> ----- Original Message -----
> From: Emmanuel Cuevas
> To: Velocity Users List
> Sent: Wednesday, October 31, 2001 11:47 AM
> Subject: Problems with navigation on templates
> Hi everyone !!
> I it seems that no long ago I replied an email by accident, sorry  =)
> Well, here is my problem:
> I want to use more than one template for formating a web page,
> but when I try to load a navigation template from a screen template
> I just a web page showing the variable names but without format nor data.
> I'd like to know how can I achieve such loading process !!
> Any suggestion ??
> Thanks in advance
> --
> Emmanuel Cuevas
> Senior Developer
> ecuevasr@iac.com.mx
> "If you gotta go, go with a smile"
>                         The Joker
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> --
> Emmanuel Cuevas
> Senior Developer
>
> ecuevasr@iac.com.mx
>
> "If you gotta go, go with a smile"
>                         The Joker
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker



Re: Problems with navigation on templates

Posted by Dan Bachelder <ch...@chowda.net>.
this is a turbine question right? you might try the turbine list... I use
turbine, but i have not had the need to do what you are doing... sorry..

----- Original Message -----
From: Emmanuel Cuevas
To: Velocity Users List
Sent: Thursday, November 01, 2001 10:25 AM
Subject: Re: Problems with navigation on templates


Hello !!
Right now im thinking in changin the structure, buet I'd like to know if I
can have 2 screen_placeholders... here is my code, but I want to add an
additional
screen_placeholder but I cannot find if this is posible, in the
documentation says nothing about this issue...
here is my current code:
<table width="100%">
  <tr>
    <td colspan="2">
      $navigation.setTemplate("/DefaultTop.vm")
    </td>
  </tr>
  <tr>
    <td align="left" valign="top">
      $screen_placeholder
    </td>
    <td width="20" align="right" valign="top">
      $navigation.setTemplate("/Menu.vm")
    </td>
  </tr>
  <tr>
    <td colspan="2">
      $navigation.setTemplate("/DefaultBottom.vm")
    </td>
  </tr>
</table>
It belongs to my Default.vm file, and here is where I want to add the other
screen_placeholder.
Any thoughts ???
Thanks in advance !!!

Dan Bachelder escribió:
Are you using #include()? you should use #parse() if you want velocity to
parse the file.... otherwise its just like doing a SSI..
----- Original Message -----
From: Emmanuel Cuevas
To: Velocity Users List
Sent: Wednesday, October 31, 2001 11:47 AM
Subject: Problems with navigation on templates
Hi everyone !!
I it seems that no long ago I replied an email by accident, sorry  =)
Well, here is my problem:
I want to use more than one template for formating a web page,
but when I try to load a navigation template from a screen template
I just a web page showing the variable names but without format nor data.
I'd like to know how can I achieve such loading process !!
Any suggestion ??
Thanks in advance
--
Emmanuel Cuevas
Senior Developer
ecuevasr@iac.com.mx
"If you gotta go, go with a smile"
                        The Joker
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problems with navigation on templates

Posted by Emmanuel Cuevas <ec...@iac.com.mx>.
Hello !!

Right now im thinking in changin the structure, buet I'd like to know if I can
have 2 screen_placeholders... here is my code, but I want to add an additional
screen_placeholder but I cannot find if this is posible, in the documentation says
nothing about this issue...

here is my current code:

<table width="100%">
  <tr>
    <td colspan="2">
      $navigation.setTemplate("/DefaultTop.vm")
    </td>
  </tr>
  <tr>
    <td align="left" valign="top">
      $screen_placeholder
    </td>
    <td width="20" align="right" valign="top">
      $navigation.setTemplate("/Menu.vm")
    </td>
  </tr>
  <tr>
    <td colspan="2">
      $navigation.setTemplate("/DefaultBottom.vm")
    </td>
  </tr>
</table>

It belongs to my Default.vm file, and here is where I want to add the other
screen_placeholder.

Any thoughts ???

Thanks in advance !!!


Dan Bachelder escribió:

> Are you using #include()? you should use #parse() if you want velocity to
> parse the file.... otherwise its just like doing a SSI..
>
> ----- Original Message -----
> From: Emmanuel Cuevas
> To: Velocity Users List
> Sent: Wednesday, October 31, 2001 11:47 AM
> Subject: Problems with navigation on templates
>
> Hi everyone !!
> I it seems that no long ago I replied an email by accident, sorry  =)
> Well, here is my problem:
> I want to use more than one template for formating a web page,
>
> but when I try to load a navigation template from a screen template
>
> I just a web page showing the variable names but without format nor data.
> I'd like to know how can I achieve such loading process !!
> Any suggestion ??
> Thanks in advance
> --
> Emmanuel Cuevas
> Senior Developer
>
> ecuevasr@iac.com.mx
>
> "If you gotta go, go with a smile"
>                         The Joker
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker



Re: Problems with navigation on templates

Posted by Dan Bachelder <ch...@chowda.net>.
Are you using #include()? you should use #parse() if you want velocity to
parse the file.... otherwise its just like doing a SSI..

----- Original Message -----
From: Emmanuel Cuevas
To: Velocity Users List
Sent: Wednesday, October 31, 2001 11:47 AM
Subject: Problems with navigation on templates


Hi everyone !!
I it seems that no long ago I replied an email by accident, sorry  =)
Well, here is my problem:
I want to use more than one template for formating a web page,

but when I try to load a navigation template from a screen template

I just a web page showing the variable names but without format nor data.
I'd like to know how can I achieve such loading process !!
Any suggestion ??
Thanks in advance
--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Problems with navigation on templates

Posted by Emmanuel Cuevas <ec...@iac.com.mx>.
Hi everyone !!

I it seems that no long ago I replied an email by accident, sorry  =)

Well, here is my problem:

I want to use more than one template for formating a web page,

but when I try to load a navigation template from a screen template

I just a web page showing the variable names but without format nor data.

I'd like to know how can I achieve such loading process !!

Any suggestion ??

Thanks in advance

--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker



Re: Looking for a good way to handle this in Velocity

Posted by Emmanuel Cuevas <ec...@iac.com.mx>.
LS escribió:

> Sorry, I couldn't come up with a better subject line.
>
> I have come across something that I'm not sure how to implement in Velocity in a
> clean way. I create a multiple select widget and populate it with categories like
> this:
>
>  <select multiple size=6 name=included[]>
>             #foreach ($category in $model.Categories)
>             <option value='$category' >$category
>             #end
>  </select>
>
> That works fine. What I really want to do is figure out, for each category in the
> category list, if the $category is an element in the $model.Included array, so I
> could add the "selected" modifier to the <option> tag.
>
> Is there a MVC-friendly way to do this?
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Emmanuel Cuevas
Senior Developer

ecuevasr@iac.com.mx

"If you gotta go, go with a smile"
                        The Joker



Re: Looking for a good way to handle this in Velocity

Posted by LS <al...@yahoo.com>.
Hey, your 3AM answer is better than my 5PM answer. And Trevor's answer is along
similar lines, but handles the more generic case where option value != option
description. 

Thanks both of you for the help.

--- Bojan Smojver <bo...@binarix.com> wrote:
> 
> You could make Categories contain two things, value and flag. The flag
> would indicate to the view that it has to render it as selected.
> Something like:
> 
> <select multiple size=6 name=included[]>
>            #foreach ($category in $model.Categories)
>            <option #if($category.flag)selected#end
> value='$category.value' >$category.value
>            #end
> </select>
> 
> Bojan
> 
> PS. Take into account that I've been up till 3 a.m. this morning ;-)


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Looking for a good way to handle this in Velocity

Posted by Bojan Smojver <bo...@binarix.com>.
LS wrote:
> 
> Sorry, I couldn't come up with a better subject line.
> 
> I have come across something that I'm not sure how to implement in Velocity in a
> clean way. I create a multiple select widget and populate it with categories like
> this:
> 
>  <select multiple size=6 name=included[]>
>             #foreach ($category in $model.Categories)
>             <option value='$category' >$category
>             #end
>  </select>
> 
> That works fine. What I really want to do is figure out, for each category in the
> category list, if the $category is an element in the $model.Included array, so I
> could add the "selected" modifier to the <option> tag.
> 
> Is there a MVC-friendly way to do this?

You could make Categories contain two things, value and flag. The flag
would indicate to the view that it has to render it as selected.
Something like:

<select multiple size=6 name=included[]>
           #foreach ($category in $model.Categories)
           <option #if($category.flag)selected#end
value='$category.value' >$category.value
           #end
</select>

Bojan

PS. Take into account that I've been up till 3 a.m. this morning ;-)

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>