Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Know the user credential client side + disable UI component base on security

    I would like to know the user credential on the client side, this way I can show who is logged and I can disable UI base on role (in addition to the server side).

    We use SmartGWT Pro 2.3. We are just starting the project, so this is new for me.

    We use J2EE security. We have 3 roles: read, write and administrator.

    In all our DS, fetch need read, and add, remove and update are write. With some special case that need admin.

    I know something is already supported in the component:
    https://www.isomorphic.com/product/#declarativeSecurity
    Declarative Security: Attach role-based security declaratively to DataSource operations. UI components are security-aware and automatically disable UI for disallowed functions. Zero code integration with J2EE Security, Spring Security, or JAAS. Documentation can be found here and here. Also available as a preview for Enterprise Edition is a pre-built login process and user administration interface; purchase Enterprise Edition for early access.

    But I didn't see it yet. What will be automatically disabled?

    We are on our first screen. We have a form with 20 disable fields and 1 enable combo box that is auto-submit on change.

    What I need right now:
    A - Put the name of the user and is permission in a label.
    B - Disable the combo box is the user don’t have right permission.

    For that, I have created a user DS that use DMI to send me back the user logged and is permission. I tried to call it manually.


    For that, I have followed the bean example from the showcase:
    http://www.smartclient.com/smartgwte...ase/#javabeans

    I also linked the user DS to a grid to confirmed the DS output.

    When I execute it, I got 2 problems:

    1 - The user gets sent to the ListGrid UI with the correct name, but all permissions are always true.

    The object have the right permission server side in the DMI (I log it), but when it go through the DSResponse, it got change.

    2 - I tried without success to get the user with my client side custom code:

    I tried this two way:

    1st: (got index out of bound on userDS.getCacheData()[0])
    DataSource userDS = DataSource.get("user");

    userDS.fetchData();
    Record r = userDS.getCacheData()[0];

    User user = new User();
    user.setName(r.getAttributeAsString("Name"));
    user.setRead(r.getAttributeAsBoolean("Read"));
    user.setWrite(r.getAttributeAsBoolean("Write"));
    user.setAdmin(r.getAttributeAsBoolean("Admin"));


    2nd: (got null value)
    DataSource userDS = DataSource.get("user");

    ListGrid grid = new ListGrid();
    grid.setDataSource(userDS);
    grid.fetchData();
    ListGridRecord r = grid.getRecord(0);

    User user = new User();
    user.setName(r.getAttributeAsString("Name"));
    user.setRead(r.getAttributeAsBoolean("Read"));
    user.setWrite(r.getAttributeAsBoolean("Write"));
    user.setAdmin(r.getAttributeAsBoolean("Admin"));

    SO have pointer to help me resolve this?

    Thank in advance for your help!
    Attached Files

    #2
    There was an issue in the 2.3 release where a boolean column could appear checked even if the underlying value is actually false. You may be hitting this bug - since 2.4 is about to be released, the best approach would be to download a nightly build of 2.4 (which has many documentation and other enhancements you may as well take advantage of) from smartclient.com/builds.

    Comment


      #3
      Hi,

      Did you get a response for your issue?
      I am facing the same situation and I cannot find a feasible solution.

      Thank you,
      Driftdone

      Comment

      Working...
      X