Loading ...
Sorry, an error occurred while loading the content.
 

Role based YUI Menu

Expand Messages
  • kpdummy
    Hi all, I am using YUI Menu s in my application. Based on login user role, some menu items should not visible. How can we do that using YUI Menu. Help me in
    Message 1 of 4 , Sep 18, 2008
      Hi all,

      I am using YUI Menu's in my application. Based on login user role,
      some menu items should not visible.

      How can we do that using YUI Menu.

      Help me in this regard.
      Thanks in advance.
    • Frank Dietrich
      ... I would build the menu dynamically with information coming from the server (in JSON or XML). I would not have all options on the client side and build from
      Message 2 of 4 , Sep 18, 2008
        >I am using YUI Menu's in my application. Based on login user role,
        >some menu items should not visible.
        >
        >How can we do that using YUI Menu.

        I would build the menu dynamically with information coming from the server (in JSON or XML). I would not have all options on the client side and build from that.
      • adolfo foronda
        Is there any example code for this scenario? I would like to do something similar but rather simply highlight the area that the user is in. ... server (in JSON
        Message 3 of 4 , Dec 15, 2008
          Is there any example code for this scenario? I would like to do
          something similar but rather simply highlight the area that the user
          is in.

          --- In ydn-javascript@yahoogroups.com, "Frank Dietrich"
          <fdietrich@...> wrote:
          >
          >
          > >I am using YUI Menu's in my application. Based on login user role,
          > >some menu items should not visible.
          > >
          > >How can we do that using YUI Menu.
          >
          > I would build the menu dynamically with information coming from the
          server (in JSON or XML). I would not have all options on the client
          side and build from that.
          >
        • lou_tribal
          You have 3 ways of doing that depending on what technologies you are using... 1. If you are using a server side page generation like php, jsp etc you can do
          Message 4 of 4 , Dec 15, 2008
            You have 3 ways of doing that depending on what technologies you are
            using...

            1. If you are using a server side page generation like php, jsp etc
            you can do that directly in your page, by building the menu content
            based on the user role.

            Example in jsp using jstl:

            var myMenu = new YAHOO.widget.Menu ( ... );
            <c:if test="${myUserRole == 'ONE_ROLE'}" >
            myMenu.addItem({ text: "My Menu entry for ONE_ROLE", onclick:... });
            </c:if>
            ... add other menu entries ...
            mymenu.render(document.body);

            2. If you are using plain old html page, you can perform a query that
            will retrieve the menu items data from the server in json, something like:

            var myMenu = new YAHOO.widget.Menu ( ... );
            var callback = {
            success: function(o){
            var myItems = YAHOO.lang.JSON.parse(o.responseText);
            var menu = o.argument[0];
            menu.addItems(myItems);
            menu.render(document.body);
            },
            failure: function(o){
            // do whatever you need in case of connection failure to gracely
            fail
            },
            argument: [myMenu]
            };
            YAHOO.util.Connect.asyncRequest('GET',
            "myUrlWhereToeGetMyMenuItems.do", callback);


            3. and last if you are using plain old html you can do something
            similar to the previous, but retrieve the user role and build the menu
            items in the javascript based on the user role, something like;

            var myMenu = new YAHOO.widget.Menu ( ... );
            var callback = {
            success: function(o){
            var myRole = YAHOO.lang.JSON.parse(o.responseText);
            var menu = o.argument[0];
            if(myRole==="blabla")
            // add one item for that role
            menu.render(document.body);
            },
            failure: function(o){
            // do whatever you need in case of connection failure to gracely
            fail
            },
            argument: [myMenu]
            };
            YAHOO.util.Connect.asyncRequest('GET',
            "myUrlWhereToeGetMyUserRole.do", callback);

            This last one is less desirable as you are exposing the user roles in
            the javascript which is not something you wanna do.

            Hope this will help.

            <


            --- In ydn-javascript@yahoogroups.com, "adolfo foronda" <aforonda@...>
            wrote:
            >
            > Is there any example code for this scenario? I would like to do
            > something similar but rather simply highlight the area that the user
            > is in.
            >
            > --- In ydn-javascript@yahoogroups.com, "Frank Dietrich"
            > <fdietrich@> wrote:
            > >
            > >
            > > >I am using YUI Menu's in my application. Based on login user role,
            > > >some menu items should not visible.
            > > >
            > > >How can we do that using YUI Menu.
            > >
            > > I would build the menu dynamically with information coming from the
            > server (in JSON or XML). I would not have all options on the client
            > side and build from that.
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.