Bonjour,
j'utilise Iceface et notamment le Tag menubar, le but étant de créer un menu dynamiquement, j'aimerais pouvoir mettre dans le code de la page un paramètre servant à la construction du menu , je n'arrive pas à récupérer ce paramètre. Dois-je utiliser f:setPropertyActionListener ou f:param?? Merci d'avance. Désolé pour cette question bête mais je débute...

Ma page
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html" xmlns:ice="http://www.icesoft.com/icefaces/component">
    <head>
        <link href="css/rime.css" rel="stylesheet" type="text/css"/>
    </head>
 
    <body>
        <f:view>
            <ice:form>
                <ice:menuBar orientation="horizontal" >
                    <ice:menuItems value="#{menuBean.menuModel}">
                        <f:setPropertyActionListener target="#{menuBean.menuId}" value="1" />
                    </ice:menuItems>
                </ice:menuBar>
            </ice:form>
 
        </f:view>
 
    </body>
</html>
Mon Bean:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package org.devit;

import com.icesoft.faces.component.menubar.MenuItem;
import java.util.ArrayList;
import java.util.List;
import javax.el.MethodExpression;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import javax.faces.event.ActionEvent;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.devit.entity.MnuLine;
import org.devit.entity.controller.MnuLineJpaController;
import org.devit.util.FacesUtils;


/**
 *
 * @author fbourqui
 */
public class MenuBean {

    private List menuModel;
    //private MenusJpaController mnuController = null;
    private String actionFired;
    private String param;
    private List<MnuLine> mnuLines;
    private String menuId;


    public List getMenuModel() {
        return menuModel;
    }

    public MenuBean() {

        menuModel = new ArrayList();           
        mnuLines = new ArrayList<MnuLine>();
       
        /*
        Query q = FacesUtils.getEM().createQuery("select m from MnuLine m");
         
        mnuLines=q.getResultList();
        System.out.println(q.getResultList().size());
         


        System.out.println("TEST JPA");
        for(int i=0;i<=mnuLines.size()-1;i++){
            System.out.println(mnuLines.get(i).getLink());
        }
        */
        System.out.println(menuId);

        MenuItem topLevel1 = new MenuItem();
        topLevel1.setValue("Home");
        MenuItem topLevel2 = new MenuItem();
        topLevel2.setValue("Presentation");
        MenuItem topLevel3 = new MenuItem();
        topLevel3.setValue("Tips And Trick");

        FacesContext context = FacesContext.getCurrentInstance();
        MethodExpression methodEx = context.getApplication().getExpressionFactory().createMethodExpression(context.getELContext(),
        "#{navigationController.goTo}", String.class, new Class[] {});
        //topLevel3.setActionExpression(methodEx);

        topLevel3.setLink("contact.iface");
       // topLevel3.setActionListener(this.createMethodBinding("actionListener"));
        



        menuModel.add(topLevel1);
        menuModel.add(topLevel2);
        menuModel.add(topLevel3);

        MenuItem sub1_1 = new MenuItem();

        sub1_1.setValue("sub1_1");
        MenuItem sub1_2 = new MenuItem();

        sub1_2.setValue("sub1_2");
        MenuItem sub1_3 = new MenuItem();

        sub1_3.setValue("sub1_3");

        topLevel1.getChildren().add(sub1_1);
        topLevel1.getChildren().add(sub1_2);
        topLevel1.getChildren().add(sub1_3);

        MenuItem sub1_1_1 = new MenuItem();

        sub1_1_1.setValue("sub1_1_1");
        MenuItem sub1_1_2 = new MenuItem();

        sub1_1_2.setValue("sub1_1_2");
        MenuItem sub1_1_3 = new MenuItem();

        sub1_1_3.setValue("sub1_1_3");

        sub1_1.getChildren().add(sub1_1_1);
        sub1_1.getChildren().add(sub1_1_2);
        sub1_1.getChildren().add(sub1_1_3);
    }


    public String action(){

    return "contact";
    }

     public MethodBinding createMethodBinding(String method)
       {
           Class[] args = {ActionEvent.class};
           MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{navigationController." + method + "}", args);
           return mb;
       }

    /**
     * @return the menuId
     */
    public String getMenuId() {       
        return menuId;
    }

    /**
     * @param menuId the menuId to set
     */
    public void setMenuId(String menuId) {
        this.menuId = menuId;
    }
}