PortletModelController for a portlet - Websphere

This is a discussion on PortletModelController for a portlet - Websphere ; Can someone please tell me how to get reference to PortletModelController of a portlet from a different Portlet? Is it possible to get the Modifiable Portlet Definition of a portlet from another portlet using it's unique name?...

+ Reply to Thread
Results 1 to 3 of 3

Thread: PortletModelController for a portlet

  1. PortletModelController for a portlet

    Can someone please tell me how to get reference to PortletModelController of a portlet from a different Portlet? Is it possible to get the Modifiable Portlet Definition of a portlet from another portlet using it's unique name?

  2. Re: PortletModelController for a portlet

    I was able to get the PortletModelController for a portlet. Is it possible to edit the global preference of one portlet from another one. I was able to edit the preference using ModifiablePortletPrefernce but the changes are not getting reflected. Can someone please advice me on this?

  3. Re: PortletModelController for a portlet

    Can someone please help me? I'm stuck at this place.
    I've attached the code below
    {code}
    psh = (PortletServiceHome) ctx.lookup("portletservice/com.ibm.portal.portlet.service.model.ContentModelP rovider");
    PortletModelControllerHome home = (PortletModelControllerHome) ctx.lookup(PortletModelControllerHome.PORTLET_MODE L_CONTROLLER_JNDI_NAME);
    ContentModelProvider contentModelProvider = (ContentModelProvider) psh.getPortletService(ContentModelProvider.class);
    ContentModel contentModel = contentModelProvider.getContentModel(renderRequest , renderResponse);
    Locator locator = contentModel.getLocator();
    ContentPage cPage = (ContentPage)locator.findByUniqueName("com.test.testpreferences");
    // System.out.println("got the locator from model");
    // System.out.println("got the modifable portlet definiton");
    LayoutModel lModel = contentModel.getLayoutModel(cPage);
    ControlLocator cLocator = (ControlLocator) lModel.getLocator();

    ListModel allPortlets = cLocator.findAllControls();

    PortletServiceHome psHomeModel = null;

    PortletModelProvider modelProvider = null;
    if (psHomeModel == null ){
    //Context ctx2= new InitialContext();
    psHomeModel = (PortletServiceHome) ctx.lookup("portletservice/com.ibm.portal.portlet.service.model.PortletModelP rovider");
    }
    modelProvider = (PortletModelProvider) psHomeModel.getPortletService(PortletModelProvider .class);
    Iterator controlIter = allPortlets.iterator();
    LayoutControl lControl = null;
    System.out.println("just befor while loop");
    while ( controlIter.hasNext()) {
    System.out.println("inside while loop");
    lControl = (LayoutControl ) controlIter.next();

    PortletModel pModel = modelProvider.getPortletModel(renderRequest, renderResponse);
    if (home != null) {
    result = home.getPortletModelControllerProvider().createPor tletModelController(pModel);
    }
    PortletWindow pWindow2 = pModel.getPortletWindow(lControl);

    PortletDefinition pDefinition = pModel.getPortletDefinition(pWindow2);
    Modifiable modifiable = result.getModifiableNode(pDefinition);

    ModifiablePortletPreferences preferences = ((ModifiablePortletDefinition)modifiable).getModif iablePortletPreferencesLayer();
    System.out.println("THI IS FROM MODIFIABLE REFERENCE"+preferences.getStringValue("view.page"));

    if(preferences.getStringValue("view.page")!=null)
    {
    System.out.println("VIEW.PAGE NOT NULL %%%%%%");
    System.out.println("THIS PREFERENCE CAN BE REMOVED??"+preferences.confirmRemoveName("view.page"));
    System.out.println("THIS VALUE CAN BE SET?? "+preferences.confirmSetStringValue("view.page","newvalue" ));
    preferences.setStringValue("view.page", "newvalue");
    //System.out.println("REMOVE"+preferences.removeNames());

    System.out.println("NEW VALUE AFTER SETTING"+preferences.getStringValue("view.page"));//getting the updated value


    }
    PortletPreferences preferenceLayer=(PortletPreferences) pDefinition.getPortletPreferencesLayer();
    //PortletPreferences preferenceLayer2=pDefinition.getPortletPreferences Layer();

    if(preferenceLayer!=null)
    {

    System.out.println("NOT NULL NORMAL" +preferenceLayer.getStringValue("view.page"));//I'm getting the previous value here

    }
    {code}

+ Reply to Thread