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:
<span jwcid="@Util:TabGroupView" source="ognl:items"/>

TabGroupView.html:
<span jwcid="@For" source="ognl:source" index="ognl:index" value="ognl:group">
 <span jwcid="@TabGroup" title="ognl:group.title"
minimized="ognl:minimized" parameters="ognl:new
java.lang.Object[]{index, minimizedMap}"
listener="ognl:listeners.linkActionToggleGroup"/>
</span>

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:
<a jwcid="@DirectLink" parameters="ognl:parameters" listener="ognl:listener">
 <span jwcid="@Insert" value="ognl:title"/>
</a>

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 :
> <span jwcid="@For" source="ognl:items" value="ognl:item">
>   <span jwcid="@Util:TabGroup" title="ognl:item.name"/>
> </span>
>
>
> TabGroup.html:
> <span jwcid="@If" condition="ognl:!minimized">
>   <a jwcid="@DirectLink" parameters="ognl:minimized"
> listener="ognl:listeners.lnkActionToggleGroup ">
>     <span jwcid="@Insert" value="ognl:title"/>
>   </a>
> </span>
>
> TabGroup.jwc:
> <component-specification class="TabGroup" allow-body="yes"
> allow-informal-parameters="no">
>   <parameter name="title" required="yes" cache="false"/>
> </component-specification>
>
> 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]

Reply via email to