vendredi 1 septembre 2017

How to make a list of objects which are checked in GWT?

I am developing an GWT app where I am using check-boxes. I have list of GwtRoles which are in checkboxes, but I don't know how to get those GwtRoles that are checked. This is my code:

@Override
    public void createBody() {

    for (GwtRole gwtRole : roleList) {
                checkBox = new CheckBox();
                checkBox.setBoxLabel(gwtRole.getName());
                for (GwtAccessRole gwtAccessRole : lista) {
                    if (gwtRole.getId().equals(gwtAccessRole.getRoleId())) {
                        checkBox.setValue(true);
                    }

RoleList is list of GwtRoles that are in checkboxes. This lista is a list of items that should be pre-checked when user opens form. I am not really familiar with check-boxes in GWT. I have used CheckBox list and there I had method getChecked() which returns list of all checked GwtRoles, but here with this check-boxes I don't have that option. In this method I should make a list of GwtRoles which are checked:

 @Override
    public void submit() {

        List<GwtAccessRoleCreator> listCreator = new ArrayList<GwtAccessRoleCreator>();

        for (GwtRole role : list) {
            GwtAccessRoleCreator gwtAccessRoleCreator = new GwtAccessRoleCreator();

            gwtAccessRoleCreator.setScopeId(currentSession.getSelectedAccount().getId());

            gwtAccessRoleCreator.setAccessInfoId(accessInfoId);

            gwtAccessRoleCreator.setRoleId(role.getId());
            listCreator.add(gwtAccessRoleCreator);
        }
        GWT_ACCESS_ROLE_SERVICE.createCheck(xsrfToken, currentSession.getSelectedAccount().getId(), userId, listCreator, new AsyncCallback<GwtAccessRole>() {

            @Override
            public void onSuccess(GwtAccessRole arg0) {
                exitStatus = true;
                exitMessage = MSGS.dialogAddConfirmation();
                hide();
            }

Could someone helps me how to set a list of GwtRoles which are checked?




Aucun commentaire:

Enregistrer un commentaire