You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Manish Kumar <ma...@cisco.com> on 2004/02/21 01:58:25 UTC

Avoiding Foreach loop in jetspeed.vm

Hi All,
 
Please let me know how can substitute following loop with individual
elements:
 
#foreach ( $action in $actions )
     <a href="${action.Link}" title="${action.Name}" ><img
src="images/${action.Name}.gif" alt="${action.Alt}" border="0"></a>
#end

I am looking for something like this. But, my limited knowledge of
jetspeed and velocity is not helping. :-(
 
<a href="${actions[2].Link}" title="${actions[2].Name}" ><img
src="images/${actions[2].Name}.gif" alt="${actions[2].Alt}"
border="0"></a>

<a href="${actions[5].Link}" title="${actions[5]Name}" ><img
src="images/${actions[5].Name}.gif" alt="${actions[5].Alt}"
border="0"></a>
and so on ...
 
Objective is to configure the order of appearance of action buttons.
 
- M.
 
 


RE: Avoiding Foreach loop in jetspeed.vm

Posted by Manish Kumar <ma...@cisco.com>.
I am not very conversant with Java. So, I was looking towards only
configuration and customization. But, if I can achieve the change in
order by some tweaking in Java code. I won't mind doing it. Please let
me know where exactly I need to change. I have all standard (unaltered)
code from JetSpeed.

-----Original Message-----
From: Stijn de Witt [mailto:StijnDeWitt@chello.nl] 
Sent: Sunday, February 22, 2004 5:06 AM
To: Jetspeed Users List
Subject: Re: Avoiding Foreach loop in jetspeed.vm


Do you place the actions in the context yourself? If so, why not make
the order of the buttons configurable at the Java end instead of at the
Velocity end? Order is not a style/lay-out thing, so placing it's
configuration in the Model instead of the View makes sense to me... You
would then, in your Java, do something like this: (assuming your order
configuration is an array of indexes into your actions
list)

int[] orderArray;
...

Vector orderedActions = new Vector();
for (int i=0; i<actionOrder.size(); i++)
    orderedActions.addElement(actions[orderArray[i]]);
context.put ("orderedActions", orderedActions);

And in the .vm, you always make a simple loop, this keeps the .vm very
lightweight too.

-Stijn


----- Original Message -----
From: "Manish Kumar" <ma...@cisco.com>
To: <je...@jakarta.apache.org>
Sent: Saturday, February 21, 2004 1:58 AM
Subject: Avoiding Foreach loop in jetspeed.vm


> Hi All,
>
> Please let me know how can substitute following loop with individual
> elements:
>
> #foreach ( $action in $actions )
>      <a href="${action.Link}" title="${action.Name}" ><img 
> src="images/${action.Name}.gif" alt="${action.Alt}" border="0"></a> 
> #end
>
> I am looking for something like this. But, my limited knowledge of 
> jetspeed and velocity is not helping. :-(
>
> <a href="${actions[2].Link}" title="${actions[2].Name}" ><img 
> src="images/${actions[2].Name}.gif" alt="${actions[2].Alt}" 
> border="0"></a>
>
> <a href="${actions[5].Link}" title="${actions[5]Name}" ><img 
> src="images/${actions[5].Name}.gif" alt="${actions[5].Alt}" 
> border="0"></a> and so on ...
>
> Objective is to configure the order of appearance of action buttons.
>
> - M.



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



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


Re: Avoiding Foreach loop in jetspeed.vm

Posted by Stijn de Witt <St...@chello.nl>.
Do you place the actions in the context yourself? If so, why not make the
order of the buttons configurable at the Java end instead of at the Velocity
end? Order is not a style/lay-out thing, so placing it's configuration in
the Model instead of the View makes sense to me...
You would then, in your Java, do something like this:
(assuming your order configuration is an array of indexes into your actions
list)

int[] orderArray;
...

Vector orderedActions = new Vector();
for (int i=0; i<actionOrder.size(); i++)
    orderedActions.addElement(actions[orderArray[i]]);
context.put ("orderedActions", orderedActions);

And in the .vm, you always make a simple loop, this keeps the .vm very
lightweight too.

-Stijn


----- Original Message -----
From: "Manish Kumar" <ma...@cisco.com>
To: <je...@jakarta.apache.org>
Sent: Saturday, February 21, 2004 1:58 AM
Subject: Avoiding Foreach loop in jetspeed.vm


> Hi All,
>
> Please let me know how can substitute following loop with individual
> elements:
>
> #foreach ( $action in $actions )
>      <a href="${action.Link}" title="${action.Name}" ><img
> src="images/${action.Name}.gif" alt="${action.Alt}" border="0"></a>
> #end
>
> I am looking for something like this. But, my limited knowledge of
> jetspeed and velocity is not helping. :-(
>
> <a href="${actions[2].Link}" title="${actions[2].Name}" ><img
> src="images/${actions[2].Name}.gif" alt="${actions[2].Alt}"
> border="0"></a>
>
> <a href="${actions[5].Link}" title="${actions[5]Name}" ><img
> src="images/${actions[5].Name}.gif" alt="${actions[5].Alt}"
> border="0"></a>
> and so on ...
>
> Objective is to configure the order of appearance of action buttons.
>
> - M.



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