Tim,

I haven't got time to take a look at this, but I'll forward it to the maintainers of the dojo package. They are both offline for the day.

Martijn


On 2/2/06, Tim Squires (sent by Nabble.com) <[EMAIL PROTECTED]> wrote:
Hi,

I have a tree of objects ( train operators and trains ) and would like a wiper menu.  To create  the menu, I followed the instructions in the tutorial

http://wicket-stuff.sourceforge.net/wicket-contrib-dojo/WiperMenuTutorial.html

and added the details using a ListView for both the top level menu items and the submenus with separate component classess for each.  Tips from a previous post in this forum:

http://www.nabble.com/DOJO-FXOnClickWiper-t988596.html#a2572416

See below for full code.

The problem is when creating a listview of WebMarkupContainers, the id does not change for each iteration of the ListView and therefore the dojo wiper _javascript_ only picks up the first top level menu.  An AttributeModifier was added to change the id but it has no effect:

final WebMarkupContainer trainMenu = new WebMarkupContainer("trainMenu");
trainMenu.add(new AttributeModifier("id", true, new Model("trainMenu_"  
                +operator.getId())));
add(trainMenu);


gives me

<div wicket:id="trainMenu" style="display:none" id="trainMenu_operator:trainMenu">

what I expected to see was

<div wicket:id="trainMenu" style="display:none" id="trainMenu_1234">

Anyone any ideas for doing this a better way or changing the web containers html id?

Thanks, Tim

Menu component code:
public class RTPSTrainOperatorChooser extends Panel {

        public static final int duration = 250;

        public RTPSTrainOperatorChooser(String id, TrainOperator operator) {
                super(id);
                addTrains(operator);
        }

        protected void addTrains(final TrainOperator operator) {

                final Label operatorMenuLabel = new Label("operator", new Model(
                                operator.getName()));
                add(operatorMenuLabel);
                final WebMarkupContainer trainMenu = new WebMarkupContainer("trainMenu");
                trainMenu.add(new AttributeModifier("id", true, new Model("trainMenu_"
                                + operator.getId())));
                trainMenu.add(new FXOnClickWiper(duration, operatorMenuLabel));
                add(trainMenu);

                trainMenu.add(new ListView("trains", new ArrayList<Train>(operator
                                .getTrains())) {
                        // This method is called for each 'entry' in the list.
                        @Override
                        protected void populateItem(ListItem item) {
                                // add the top level of the menu, the operators
                                // this list will always be shown
                                Train train = (Train) item.getModelObject();
                                Label label = new Label("trainLabel", new Model(train
                                                .getDescription()));
                                trainMenu.add(label);
                                item.add(label);
                        }
                });

        }
}


Menu component html:
<html>
  <body>
    <wicket:panel>    
                <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td bgcolor="#FF6600">
                    <div wicket:id="operator" align="center">Operator</div>
            </td>
          </tr>
          <tr>
            <td bgcolor="#FF9966">
                    <div wicket:id="trainMenu">
                       <span wicket:id="trains">
                            <div wicket:id="trainLabel" align="center">Train</div>
                   </span>
                    </div>
            </td>
          </tr>
                </table>
    </wicket:panel>    
  </body>
</html>


View this message in context: Changing the id of a WebMarkupContainer
Sent from the wicket-stuff-user forum at Nabble.com.



--
Living a wicket life...

Martijn Dashorst - http://www.jroller.com/page/dashorst

Wicket 1.1.1 is out: http://wicket.sourceforge.net/wicket-1.1

Reply via email to