cancel
Showing results for 
Search instead for 
Did you mean: 

Maintain history for collapsed and expanded trays in iView

Former Member
0 Kudos

Hello Experts,

My requirement is as follows-

I have an iView with multiple trays. Each tray has its own UI elements.

At runtime user is allowed to collapse/expand trays by default. However, once the user logs out of the portal and logs in back all the trays are expanded again.

Is there any way in which I can maintain the collapsed trays even after the user has logged out and logged in again?

There is a personalization property for hidden tray but none for collapse/expand.

Please help me out with this issue.

Regards,

Nisha.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Angelo/Ilan,

Apologies for the delay.

Context -

Value Node - UserDet

cardinality - 1..1

collectionType - list

initializeLeadSelection - true

name - UserDet

selection - 0..1

singleton - true

typedAccessRequired - true

Value Atrribute - myUser

calculated - false

name - myUser

readOnly - false

type - com.sap.security.api.IUser

Value Attribute - UserMaint

calculated - false

name - UserMaint

readOnly - false

type - com.sap.security.api.IUserMaint

On button_1 click to load user -

public void onActionloadUser(

com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent) {

//@@begin onActionloadUser(ServerEvent)

try {

wdContext.currentUserDetElement().setMyUser(

WDClientUser.getCurrentUser().getSAPUser());

String user =

wdContext.currentUserDetElement().getMyUser().getUniqueID();

IUserMaint userMaint =

UMFactory.getUserFactory().getMutableUser(user);

wdContext.currentUserDetElement().setUserMaint(userMaint);

} catch (WDUMException ex) {

wdComponentAPI.getMessageManager().raiseException(

ex.getLocalizedMessage(),

true);

} catch (UMException ume) {

wdComponentAPI.getMessageManager().raiseException(

ume.getLocalizedMessage(),

true);

}

//@@end

}

On click of tray to save property -

String attribs[] = new String[1];

attribs[0] = "true";

String propertiesName = "Expandable";

wdContext.currentUserDetElement().getUserMaint().setAttribute("com.sap.security.core.usermanagement", propertiesName, attribs);

On button_2 click to load property -

public void onActionloadCode(

com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent) {

//@@begin onActionloadCode(ServerEvent)

String attribute[] =

wdContext.currentUserDetElement().getUserMaint().getAttribute(

"com.sap.security.core.usermanagement",

"Expandable");

if(attribute != null)

wdComponentAPI.getMessageManager().reportSuccess(

"Attribute in load code:" + attribute[0]);

//@@end

}

I am unable to retrieve the attribute for a user after the user moves to another role or logs off the portal and logs in again.

Please help.

Thank you for all the help so far.

Nisha.

former_member192152
Active Participant
0 Kudos

Nisha, I just sent an example of code ... you must perform the methods save () and commit (). A good navigated in the methods of that class would be very helpful.

In any case:


  public boolean UMSavePropertiesByNode( )
  {
    //@@begin UMSavePropertiesByNode()

		String properties[] = this.getPropertiesByNode();
		String propertiesName = this.getUMPropertyName() + ".TableColumns";

		wdThis.wdGetMMComponentController().messManagerShowMessage("propertiesName = " + propertiesName, PBMessagesTypes.TP_Debug, null, myLogger);
		wdThis.wdGetMMComponentController().messManagerShowMessage("properties[].length = " + properties.length, PBMessagesTypes.TP_Debug, null, myLogger);

		try {
			boolean retorno = wdContext.currentVnAppPropertiesElement().getVaIUserMaint().setAttribute("com.sap.security.core.usermanagement", propertiesName, properties);
			if (retorno) {
				wdContext.currentVnAppPropertiesElement().getVaIUserMaint().save();
				wdContext.currentVnAppPropertiesElement().getVaIUserMaint().commit();
				msg.reportMessage(IMessageMMComponent.UMPROPERTY__SAVE__FIELDS__SUCCESS, null, false);
			}
		} catch (UMException ex) {
			wdContext.currentVnAppPropertiesElement().getVaIUserMaint().rollback();
			msg.reportMessage(IMessageMMComponent.UMPROPERTY__SAVE__FIELDS__ERROR, null, false);
			return false;
		} catch (Exception e) {
			//wdContext.currentVnAppPropertiesElement().getVaIUserMaint().rollback();
			messages.addPBMessagesItem(e.getLocalizedMessage(), e, true, PBMessagesTypes.TP_DebugStackTrace.ordinal(), "CstCtrlTableUtils.UMSavePropertiesByNode");
			return false;
		}
		return true;
    //@@end
  }

regards,

Angelo

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Angelo,

Saving and commit resolved my issue.

Hurray!!

Thanks a ton.

Nisha.

Former Member
0 Kudos

Hi Angelo,

Thank you very much for this piece of code.

I can succesfully set the attribute using your code.

However, I am not able to read the user property on a reload, because when i try to load the code after logging out and logging in again I cannot read any value from the property.

Any suggestion?

I have a context attribute of type IUserMaint to which I am trying to sett the attribute.

Please advise.

Regards,

Nisha

Former Member
0 Kudos

Please post your code for the 3 phases of setup, saving and the loading - as described by Angelo.

former_member192152
Active Participant
0 Kudos

Your code may be falling in some catch ... note that just showed how to proceed, but not made available a code 100% functional. It's up to you as a developer to make the necessary adjustments.

We can try to help you ... post your code!

best regards,

Angelo

Former Member
0 Kudos

Hi Ilan,

I just wanted to ensure there is no personalization or iview property that maintains the history for portal users.

If there is no such way, I will have to use a database.

Thanks for your input

Regards,

Nisha

former_member192152
Active Participant
0 Kudos

Hi,

You will need to save user settings in the properties customizable user at UM.

LOAD USER


  public void loadCurrentUser( )
  {
    //@@begin loadCurrentUser()
    try {
        wdContext.currentVnAppPropertiesElement().setVaIUser(WDClientUser.getCurrentUser().getSAPUser());

        String user = wdContext.currentVnAppPropertiesElement().getVaIUser().getUniqueID();
        IUserMaint userMaint = UMFactory.getUserFactory().getMutableUser(user);

        wdContext.currentVnAppPropertiesElement().setVaIUserMaint(userMaint);

    } catch (WDUMException ex) {
        wdComponentAPI.getMessageManager().raiseException(ex.getLocalizedMessage(), true);
    }
    //@@end
  }

SAVE CODE


 public boolean UMSave(String val1 )
  {
    //@@begin UMSaveQtdPageItems()
    String attribs[] = new String[1];
    attribs[0] = val1;
    String propertiesName = "PropertyName";

    try {
        boolean retorno = wdContext.currentVnAppPropertiesElement().getVaIUserMaint().setAttribute("com.sap.security.core.usermanagement", propertiesName, attribs);
    } catch (UMException ex) {
        wdContext.currentVnAppPropertiesElement().getVaIUserMaint().rollback();
        return false;
    }
    return true;
    //@@end
  }

LOAD CODE


  public String UMLoad( )
  {
    //@@begin UMLoadQtdPageItems()
    try {
        String attribute[] = wdContext.currentVnAppPropertiesElement().getVaIUserMaint().getAttribute("com.sap.security.core.usermanagement", "PropertyName");
        }
    } catch (Exception ex) {
    }
   //@@end
  }

best regards,

Angelo

Former Member
0 Kudos

Thanks, Angelo!

This is very useful for when you want to store data for a user that is small and doesn't require using a custom table.

former_member192152
Active Participant
0 Kudos

Yes, I usually use this feature to simulate the customization options present in WD ABAP, eg allow the user to hide columns in a table or even change their order.

regards,

Angelo

Former Member
0 Kudos

You need to use some kind of data store.

Why not use a database?