Re: Manipulate components inside a @For with DirectLink.

2006-08-07 Thread Karthik N

The solution looks quite nice.   After our experimentations with For, we
realized that the state of each minimize of each TabGroup should be a part
of a List and not in the component.  And that's where the TabGroupView fits
in.

Quite an eye-opener!! I always had the impression that a For loop would
render 'n' different components and not just one.

On 8/7/06, Reto Hotz <[EMAIL PROTECTED]> wrote:


Hi,

Thanks for your reply.

Yes, I found a solution:
I created a new "wrapper"-component who does the for-loop stuff. I
called it TabGroupView. Within this component I can save the
maximize/minimize status of all my TabGroups.
This means I moved my @For loop from the Home.html into this
component. My DirectLink-Listener is now also in the TabGroupView
component so I have full control over all groups.

Some example code:

Home.html:


TabGroupView.html:

  


TabGroupView.java:
public void linkActionToggleGroup(IRequestCycle cycle) {
Object[] params = cycle.getListenerParameters();
int index = (Integer) params[0];
Map minMap = (Map) params[1];
Boolean oldValue = (Boolean) minMap.get(index);
minMap.put(index, !oldValue);
setMinimizedMap(minMap);
}

public boolean isMinimized() {
if (getMinimizedMap().containsKey(getIndex())) {
return getMinimizedMap().get(getIndex());
} else {
getMinimizedMap().put(getIndex(), false);
return false;
}
}

TabGroup.html:

  


TabGroup.java:
@Parameter(name="parameters", required=false)
public abstract Object getParameters();

@Parameter(name="listener", required=false)
public abstract IActionListener getListener();



Not sure if this is the preferred way, but it works. :)

Greetings
Reto


On 8/7/06, Karthik N <[EMAIL PROTECTED]> wrote:
> any luck with this issue?
>
> After some discussions and experimentation with a colleague of mine, it
> appears that there is only one component.  that's the nature of the For
> loop.   We did this in the listener on the page:
>
> Map comps = this.getComponents();
> Set keyMap = comps.keySet();
> for (Iterator iter = keyMap.iterator(); iter.hasNext();) {
> System.out.println( comps.get(iter.next()));
>
> }
>
> Hence, if a For loop iterates over 'n' elements and writes out a
> @Util:TabGroup, there is just one component @Util:TabGroup.
>
> I suppose what it means is that for you to iterate over your list and
> control the maximize/minimize stuff, you'll have to have this as an
> attribute in the For loop's List, and accordingly use some client side
> scripting to handle maximize/minimize.
>
> Unless there is an attribute of the For loop that forces generation of
one
> @Util:TabGroup for every iteration.  If there is some such parameter, I
am
> not aware of it 
>
> Good luck.
>
>
> On 8/4/06, Reto Hotz <[EMAIL PROTECTED]> wrote:
> >
> > The TabGroup has a @DirectLink to change the state:
minimized/maximized.
> >
> > Home.html :
> > 
> >   
> > 
> >
> >
> > TabGroup.html:
> > 
> >> listener="ognl:listeners.lnkActionToggleGroup ">
> > 
> >   
> > 
> >
> > TabGroup.jwc:
> >  > allow-informal-parameters="no">
> >   
> > 
> >
> > TabGroup.java:
> > public abstract class TabGroup extends BaseComponent implements
> > PageAttachListener, IFormComponent {
> >
> > public abstract String getTitle();
> >
> > @Persist("client")
> > public abstract boolean getMinimized();
> >
> > public void lnkActionToggleGroup(boolean minimized) {
> > setMinimized(!minimized);
> > }
> > ...
> > }
> >
> >
> > For example if I create 2 TabGroups *without* the @For loop they are
> > rendered like this:
> > $TabGroup
> > $TabGroup_0
> >
> > But if I create them *with* the @For loop, I get the component twice:
> > $TabGroup
> > $TabGroup
> >
> > --> both are the same component and thus if I click on the DirectLink
> > of the first component, the second gets minimized too.
> >
> > Greetings
> > Reto
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Thanks, Karthik
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Thanks, Karthik


Re: Manipulate components inside a @For with DirectLink.

2006-08-07 Thread Reto Hotz

Hi,

Thanks for your reply.

Yes, I found a solution:
I created a new "wrapper"-component who does the for-loop stuff. I
called it TabGroupView. Within this component I can save the
maximize/minimize status of all my TabGroups.
This means I moved my @For loop from the Home.html into this
component. My DirectLink-Listener is now also in the TabGroupView
component so I have full control over all groups.

Some example code:

Home.html:


TabGroupView.html:

 


TabGroupView.java:
   public void linkActionToggleGroup(IRequestCycle cycle) {
   Object[] params = cycle.getListenerParameters();
   int index = (Integer) params[0];
   Map minMap = (Map) params[1];
   Boolean oldValue = (Boolean) minMap.get(index);
   minMap.put(index, !oldValue);
   setMinimizedMap(minMap);
   }

   public boolean isMinimized() {
   if (getMinimizedMap().containsKey(getIndex())) {
   return getMinimizedMap().get(getIndex());
   } else {
   getMinimizedMap().put(getIndex(), false);
   return false;
   }
   }

TabGroup.html:

 


TabGroup.java:
@Parameter(name="parameters", required=false)
public abstract Object getParameters();

@Parameter(name="listener", required=false)
public abstract IActionListener getListener();



Not sure if this is the preferred way, but it works. :)

Greetings
Reto


On 8/7/06, Karthik N <[EMAIL PROTECTED]> wrote:

any luck with this issue?

After some discussions and experimentation with a colleague of mine, it
appears that there is only one component.  that's the nature of the For
loop.   We did this in the listener on the page:

Map comps = this.getComponents();
Set keyMap = comps.keySet();
for (Iterator iter = keyMap.iterator(); iter.hasNext();) {
System.out.println( comps.get(iter.next()));

}

Hence, if a For loop iterates over 'n' elements and writes out a
@Util:TabGroup, there is just one component @Util:TabGroup.

I suppose what it means is that for you to iterate over your list and
control the maximize/minimize stuff, you'll have to have this as an
attribute in the For loop's List, and accordingly use some client side
scripting to handle maximize/minimize.

Unless there is an attribute of the For loop that forces generation of one
@Util:TabGroup for every iteration.  If there is some such parameter, I am
not aware of it 

Good luck.


On 8/4/06, Reto Hotz <[EMAIL PROTECTED]> wrote:
>
> The TabGroup has a @DirectLink to change the state: minimized/maximized.
>
> Home.html :
> 
>   
> 
>
>
> TabGroup.html:
> 
>listener="ognl:listeners.lnkActionToggleGroup ">
> 
>   
> 
>
> TabGroup.jwc:
>  allow-informal-parameters="no">
>   
> 
>
> TabGroup.java:
> public abstract class TabGroup extends BaseComponent implements
> PageAttachListener, IFormComponent {
>
> public abstract String getTitle();
>
> @Persist("client")
> public abstract boolean getMinimized();
>
> public void lnkActionToggleGroup(boolean minimized) {
> setMinimized(!minimized);
> }
> ...
> }
>
>
> For example if I create 2 TabGroups *without* the @For loop they are
> rendered like this:
> $TabGroup
> $TabGroup_0
>
> But if I create them *with* the @For loop, I get the component twice:
> $TabGroup
> $TabGroup
>
> --> both are the same component and thus if I click on the DirectLink
> of the first component, the second gets minimized too.
>
> Greetings
> Reto
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
Thanks, Karthik




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Manipulate components inside a @For with DirectLink.

2006-08-07 Thread Karthik N

any luck with this issue?

After some discussions and experimentation with a colleague of mine, it
appears that there is only one component.  that's the nature of the For
loop.   We did this in the listener on the page:

   Map comps = this.getComponents();
   Set keyMap = comps.keySet();
   for (Iterator iter = keyMap.iterator(); iter.hasNext();) {
   System.out.println( comps.get(iter.next()));

   }

Hence, if a For loop iterates over 'n' elements and writes out a
@Util:TabGroup, there is just one component @Util:TabGroup.

I suppose what it means is that for you to iterate over your list and
control the maximize/minimize stuff, you'll have to have this as an
attribute in the For loop's List, and accordingly use some client side
scripting to handle maximize/minimize.

Unless there is an attribute of the For loop that forces generation of one
@Util:TabGroup for every iteration.  If there is some such parameter, I am
not aware of it 

Good luck.


On 8/4/06, Reto Hotz <[EMAIL PROTECTED]> wrote:


The TabGroup has a @DirectLink to change the state: minimized/maximized.

Home.html :

  



TabGroup.html:

  

  


TabGroup.jwc:

  


TabGroup.java:
public abstract class TabGroup extends BaseComponent implements
PageAttachListener, IFormComponent {

public abstract String getTitle();

@Persist("client")
public abstract boolean getMinimized();

public void lnkActionToggleGroup(boolean minimized) {
setMinimized(!minimized);
}
...
}


For example if I create 2 TabGroups *without* the @For loop they are
rendered like this:
$TabGroup
$TabGroup_0

But if I create them *with* the @For loop, I get the component twice:
$TabGroup
$TabGroup

--> both are the same component and thus if I click on the DirectLink
of the first component, the second gets minimized too.

Greetings
Reto

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Thanks, Karthik


Re: Manipulate components inside a @For with DirectLink.

2006-08-04 Thread Reto Hotz

The TabGroup has a @DirectLink to change the state: minimized/maximized.

Home.html:

 



TabGroup.html:

 
   
 


TabGroup.jwc:

 


TabGroup.java:
public abstract class TabGroup extends BaseComponent implements
PageAttachListener, IFormComponent {

   public abstract String getTitle();

   @Persist("client")
   public abstract boolean getMinimized();

   public void lnkActionToggleGroup(boolean minimized) {
   setMinimized(!minimized);
   }
   ...
}


For example if I create 2 TabGroups *without* the @For loop they are
rendered like this:
$TabGroup
$TabGroup_0

But if I create them *with* the @For loop, I get the component twice:
$TabGroup
$TabGroup

--> both are the same component and thus if I click on the DirectLink
of the first component, the second gets minimized too.

Greetings
Reto

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Manipulate components inside a @For with DirectLink.

2006-08-04 Thread Karthik N

I am assuming that to the @DirectLink you are passing the appropriate
parameter(s) that makes it render a unique URL for each iteration?   Any
code snippets would help.

On 8/4/06, Reto Hotz <[EMAIL PROTECTED]> wrote:


Hi Karthik,

On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote:
> I think you will have to look at the parameters that are passed to your
> TabGroup component.  ensure you have cache="false" on all of them in the
> .jwc file of TabGroup

Makes no difference, unfortunately.


Greetings
Reto

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Thanks, Karthik


Re: Manipulate components inside a @For with DirectLink.

2006-08-04 Thread Reto Hotz

Hi Karthik,

On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote:

I think you will have to look at the parameters that are passed to your
TabGroup component.  ensure you have cache="false" on all of them in the
.jwc file of TabGroup


Makes no difference, unfortunately.


Greetings
Reto

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Manipulate components inside a @For with DirectLink.

2006-08-04 Thread Karthik N

I think you will have to look at the parameters that are passed to your
TabGroup component.  ensure you have cache="false" on all of them in the
.jwc file of TabGroup

On 8/4/06, Reto Hotz <[EMAIL PROTECTED]> wrote:


Hello,

In T4, I have a custom component (TabGroup) in a @For loop. The
component has a @DirectLink to manipulate itself. Now I have the
problem, that the @For-loop creates only one instance of my component
and reuses it in every loop. And thus if I click on the components
DirectLink to manipulate one of tthem, all of them are manipulated
instead of just one.

If I use the TabGroup component outside of the @For loop, it just works
fine.

Is there a way to tell the @For component to create on every loop a
new instance of the TabGroup component?


Thanks for your help.

Greetings
Reto

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Thanks, Karthik