How to delete protlet from the code?

Hi All,
I want to delete the portlet at runtime (means from code) so does anyone has any idea how to do it?
Scenario - I have home page, there I have 5-8 portlets so I want to provide functionality to end user so they can delete and add the same portlet. So, for that I have created one more portlet which is on another page, from that portlet I am deleting one specific portlet by passing it's portlet instance ID.
I have written following code to delete it but it doesn't work out. I am not getting any exception while executing below code but it doesn't delete the portlet , so when I go back to home page I can see that portlet. FYI, It prints all SOPs.
I have written following code in backing file which is at page level (not on Home page).
String LOOKUP_NAME = com.bea.p13n.management.ApplicationHelper.getApplicationName() +"."+
     com.bea.netuix.application.manager.persistence.PortalCustomizationManagerHome.LOOKUP_NAME;
     Object obj = JndiHelper.lookup(LOOKUP_NAME, com.bea.netuix.application.manager.persistence.PortalCustomizationManager.class);
     System.out.println("=========="+obj.getClass().getName());
     com.bea.netuix.application.manager.persistence.PortalCustomizationManagerHome home = (com.bea.netuix.application.manager.persistence.PortalCustomizationManagerHome)obj;
     System.out.println("[HomePageBacking][Home]"+home);
     com.bea.netuix.application.manager.persistence.PortalCustomizationManager portalCustomizationManager = home.create();
     System.out.println("[HomePageBacking][portalCustomizationManager]"+portalCustomizationManager);
     com.bea.netuix.application.manager.CustomizationContext customizationContext = new com.bea.netuix.application.manager.CustomizationContext(request);
     System.out.println("[HomePageBacking][customizationContext]"+customizationContext);
     customizationContext.setVisitorMode(true);
     System.out.println("-------getParameter--------"+request.getParameter("instanceID"));
     String instanceID = request.getParameter("instanceID");
     if(instanceID != null)
          com.bea.netuix.application.identifier.PortletInstanceId portletInstanceId = com.bea.netuix.application.identifier.PortletInstanceId.createPortletInstanceId(Integer.parseInt(instanceID));
          //portletInstanceId.setId(Integer.parseInt(instanceID));
          System.out.println("[HomePageBacking][customizationContext.isVisitorMode()]"+customizationContext.isVisitorMode());
          System.out.println("[HomePageBacking][portletInstanceId.getId()]"+portletInstanceId.getId());
portalCustomizationManager.deletePortletInstance(customizationContext, portletInstanceId);
with the last line of above code it should delete that portlet for that user but it doesn't work.
So, any one has any idea on this?? I appreciate your help.
Thanks,
HJ

Following is the code to delete the portlet at runtime of from your code.
String webApp = ApplicationHelper.getWebAppName(request);
ResourceContext resourceContext = ResourceContext.createResourceContext(request, true);
String deletePortletId = "XXXXXX"; // This you can get it from request or from session
List<ControlAction> actions = new ArrayList<ControlAction>();
com.bea.netuix.application.identifier.Id id = new PortletInstanceId(Integer.valueOf(deletePortletId).intValue());
actions.add(PageInstanceAction.removePlaceableFromPageInstance(pageControl, (PlaceableInstanceId) id, webApp,
                         new PortalPath(portalPath), new DesktopPath(desktopPath)));
portalControl.executeActions(actions, resourceContext);
I hope this will help someone who wants to delete portlet at runtime fron code.
Thanks,
HJ

Similar Messages

  • I joined this community in error and don't know how to delete myself from the group. Can someone please advise me on this ?

    I joined this community in error and don't know how to delete myself from the group. Can someone please tell me how to do that ?
    Thanks,
    Skeebo

  • How to delete items from the list of "auto-open" tabs that load whenever FF4 opens?

    When I recently downloaded FF4, I was asked if I'd like to have FF automatically open the same tabs as were set in my IE. Great! Worked perfectly until I set those tabs as App Tabs. Now both the App Tabs and the original IE set of tabs open whenever I open FF -- essentially each tab loads twice -- as app tab and large tab. How can I delete tabs from the list of "auto-open" tabs? In addition, for some reason, every time I try to set my home page, it's not working -- I keep getting the same home page regardless of how many times I have tried to set a new one.

    You can close a tab with a middle-click or with a left click on the close X on the tab or via the right-click context menu of that tab.<br />
    Do those tabs come back if you close then and lose Firefox?

  • Please someone tell me how to delete songs from the newest/latest verison of Itunes! You can't just right click anymore... :(

    So I have the latest version of Itunes and I can't figure out how to delete songs from Itunes when my IPad mini is connected; it's not like it was before when all you had to do was right click and select the delete option...
    Thank you all so much

    I have exactly the same problem with videos and my right click does not work either.  There is no delete function that I can see.

  • God morning can some  one tell me how to delete app from the iphone4?

    cAN SOME ONE TELL ME HOW TO DELETE APP FORM THE IPHONE4??

    If it is an App you have Downloaded and there is no X when it Wiggles...
    Perhaps this Assistant can Help you:
    http://www.apple.com/support/iphone/assistant/application/

  • How to delete addresses from the pop-down list in the "To" line ?

    Several times I have entered someones's address incorrectly in my address book. When I correct it at some later time, the incorrect one still appears in the pop-down list when I start typing the name in the To: line. Sometimes I don't look closely and the old, incorrect address gets entered (and then I never hear back from the person!). So how do I delete the incorrect ones? I've tried everything I can think of.
    Thanks.
    John

    Those are probably coming from your previous recipients list.
    Open Mail, Click on Window, Previous Recipents, and delete any that you don't want.
    - Wayne
    PowerMac G5   Mac OS X (10.4.8)  

  • In a PrC, how to delete data from the PSA that have been loaded in Prcs Chn

    Hello,
    In a process chain, how can I delete the data from the PSA that have been loaded within that process chain. I don't want to delete data that belongs to other business units that use the same datasource.
    Thanks,
    Andre

    I dont think so you can achieve that, PSA is actually datasource dependent.
    One you load from a datasource to PSA.That is accesible by multiple DTPs if you have created so.
    As you said "I don't want to delete data that belongs to other business units that use the same datasource."
    If you delete the PSA, you may have to repull the data from source system again and if thats delta it wont work out.
    As said by above ppl you can include the "Delete PSA" in process chain but choose some 15 days buffer.
    Hope this helps.

  • TS3274 I only have a 16gig ipad. I have bought some music that I want to get rid of so that I can sync with my laptop but don't know how to delete stuff from the ipad. My library on the ipad is 4 gigs bigger than the ipad anyway.

    I have a 16gig ipad. I want to get rid of quite a bit of stuff that I have purchased to create space because I can't sync with my itunes library on my laptop. I dont know how to delete from the ipad. Can anyone help please? Terry

    Typically you can delete content on the iPad one of two ways - swipe across an item in list view to bring up a red delete button or tap and hold down on an icon to bring up an X to delete option.
    Why dont you connect your iPad to your laptop and transfer the purchases and then select exactly what you want to sync to the iPad. You don't have to delete anything this way.
    Transfer purchases.
    http://support.apple.com/kb/HT1848

  • How to delete message from the fodler of  AOL account using Java mail

    Hello All,
    I am using Java MAil API in my application, i want to delete message from AOL account's folder,
    when i set the folder as "Recently Deleted" or "Trash" , i get an exception as "folder does not exist".
    when i tested , some times mail is moving into Recently Deleted folder, but not every time.
    this is happening in both the interface as AOl Interface or my application.
    when i use folder.close(true) after setting the flag of message as DELETED. it completely remove the message from the acount.
    but i want to let the message be remained in the Recently Deleted folder. what should i do.
    i dont want to remove the message completely from the account.I am using IMAP also.

    You'll need to figure out what the real name of the "Recently Deleted" folder is on the AOL IMAP server
    (assuming it's a real folder and not some sort of "virtual" folder), then copy the message into that folder.
    See the folderlist.java demo program as a way to explore the names of all the folders on the server.

  • How to delete data from the table PA0007

    Hi Friends,
    Thank you for your kindly help.
    When I upload data to infotype 0007(planed working time),
    there is something wrong with the infotype 2011. So I want
    to delete the data of  infotype 0007. While using the program RPUREOPN to delete the data, the system will say:0007 cannot be deleted because of time constraint 1/A.
    Now how can I delete the data from table PA0007?
    Pls help me urgently.
    Best wishes
    Anne

    Hi Sikindar,
       Thank you for your help.
      There is another question. There are five clients (Client 300,310,320,330,350) in my HR DEV system. I just want to delete the data of infotype 0007 in client 350. When I change the the time constraint and delete the data in client 350, the data of infotype 0007 in other clients will be safe or not?
    Thank you again for your help!
    Best wishes
    Anne

  • How to delete  File from the Application Server,ABAP

    Hi Gurus,
    I'm using  DELETE  DATASET  Statement ,
    Based on Date  how can i delete files with in the period in the Application server
    Any BAPI/FM  for this Delete file based  on some Date Period
    Thanks in Advance.

    DATA: BEGIN OF file,
            dirname(75) TYPE c, " name of directory. (possibly truncated.)
            name(75)    TYPE c, " name of entry. (possibly truncated.)
            type(10)    TYPE c,            " type of entry.
            len(8)      TYPE p,            " length in bytes.
            owner(8)    TYPE c,            " owner of the entry.
            mtime(6)    TYPE p, " last modification date, seconds since 1970
            mode(9)     TYPE c, " like "rwx-r-x--x": protection mode.
            useable(1)  TYPE c,
            subrc(4)    TYPE c,
            errno(3)    TYPE c,
            errmsg(40)  TYPE c,
            mod_date    TYPE d,
            mod_time(8) TYPE c,            " hh:mm:ss
            seen(1)     TYPE c,
            changed(1)  TYPE c,
          END OF file.
    DATA: BEGIN OF file_list OCCURS 100,
            dirname(75) TYPE c, " name of directory. (possibly truncated.)
            name(75)    TYPE c, " name of entry. (possibly truncated.)
            type(10)    TYPE c,            " type of entry.
            len(8)      TYPE p,            " length in bytes.
            owner(8)    TYPE c,            " owner of the entry.
            mtime(6)    TYPE p, " last modification date, seconds since 1970
            mode(9)     TYPE c, " like "rwx-r-x--x": protection mode.
            useable(1)  TYPE c,
            subrc(4)    TYPE c,
            errno(3)    TYPE c,
            errmsg(40)  TYPE c,
            mod_date    TYPE d,
            mod_time(8) TYPE c,            " hh:mm:ss
            seen(1)     TYPE c,
            changed(1)  TYPE c,
          END OF file_list.
      DO.
        CLEAR file.                           
        CALL 'C_DIR_READ_NEXT'
          ID 'TYPE'   FIELD file-type
          ID 'NAME'   FIELD file-name
          ID 'LEN'    FIELD file-len
          ID 'OWNER'  FIELD file-owner
          ID 'MTIME'  FIELD file-mtime
          ID 'MODE'   FIELD file-mode
          ID 'ERRNO'  FIELD file-errno
          ID 'ERRMSG' FIELD file-errmsg.
       if sy-subrc eq 0.
          MOVE-CORRESPONDING file TO file_list.
          APPEND file_list.
       else.
          exit.
       endif.
    enddo.
    sort file_list based on date and time ie, MOD_DATE and MOD_TIME fields
    and delete the entries

  • How to delete words from the spellcheck dictionary?

    i accidentally added a word to the spellcheck dictionary when i try to click the recommended work, instead, i clicked "add to dictionary".
    how can i reset or delete that word?
    am i able to do so?

    I have OS X 10.5.3
    I still cannot make FireFox unlearn the word "detnal" which is screwupese for "dental". BTW as I write this, the word "detnal" is not underlined while FireFox and screwupese are underlined.
    I went into TextEdit and saw that it allowed "detnal". There was NO right click option called "Unlearn Spelling". What I did was click on "dental". and it then underlined "detnal" to my surprise.
    I then quit firefox and restarted firefox and it still likes "detnal". It doesn't underline it.
    I went to /Users/nicole/library/Application Support/firefox/profiles and could not find the file persdict.dat
    Is there a way to search all files on the computer that contain the string "detnal" in it? There has to be a file somewhere containing "detnal".
    <Apple-F> on Finder is useless. It says there is no persdict.dat file anywhere and there are not files anywhere on the computer containing "detnal".
    I'm stumped at this point.
    Message was edited by: NicoleNM

  • Hey guys I need to delete photos from the very first  IPad sold on the market, how I do it, when I bring the photos to be view I don't get the little garbage can to trash them. Help please!

    Hey guys! How you delete photos from the very first IPad when you don't get the little garbage can on the screen.

    The links below have instructions for deleting photos.
    iOS and iPod: Syncing photos using iTunes
    http://support.apple.com/kb/HT4236
    iPad Tip: How to Delete Photos from Your iPad in the Photos App
    http://ipadacademy.com/2011/08/ipad-tip-how-to-delete-photos-from-your-ipad-in-t he-photos-app
    Another Way to Quickly Delete Photos from Your iPad (Mac Only)
    http://ipadacademy.com/2011/09/another-way-to-quickly-delete-photos-from-your-ip ad-mac-only
    How to Delete Photos from iPad
    http://www.wondershare.com/apple-idevice/how-to-delete-photos-from-ipad.html
    iPhoto for iOS (iPad): Delete photos from iPhoto
    http://support.apple.com/kb/ph3137
    How to: Batch Delete Photos on the iPad
    http://www.lifeisaprayer.com/blog/2010/how-batch-delete-photos-ipad
    How to Delete Photos from iCloud’s Photo Stream
    http://www.cultofmac.com/124235/how-to-delete-photos-from-iclouds-photo-stream/
    The Fastest Way to Remove All the Photos from the iPad Camera Roll
    http://ipadinsight.com/ipad-tips-tricks/the-fastest-way-to-remove-all-the-photos -from-the-ipad-camera-roll/
    Delete Pictures from Your iPad
    http://www.dummies.com/how-to/content/delete-pictures-from-your-ipad.html
     Cheers, Tom

  • How do I delete music from the cloud, How do I delete music from the cloud

    I'm trying to figure out how to delete music from the cloud. There is currently music on my I-phone that I listened to when I was in high school and no longer wish to have on my phone. I can delete the song from my iTunes library  on my computer but not from my actual device. Any advice would be greatly appreciated! Thanks

    Hi Jennal89,
    You can learn how to remove music from iCloud in this article -
    iTunes Store: How to delete songs from iCloud
    http://support.apple.com/kb/HT4915
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • How do you delete files from the iPod?

    i have a 30GB iPod, but i was wondering how you delete music from the iPod? and also is it possible to play the music from the iPod?
    30GB iPod.   Windows XP   30GB iPod.

    There are several methods of deleting songs from the iPod and/or iTunes, and the method you choose depends on the settings you have selected for your iPod.
    If you have the iPod set to automatically transfer songs, and you no longer want a copy of those songs on either the iPod or in iTunes, simply delete the songs in iTunes. Highlight the songs you no longer want then right click and select "clear", or from the edit menu select "clear". Next time you connect the iPod, the songs will be deleted from there also.
    Only do this if you no longer want the songs on both the iPod and your computer.
    You can also use the "only update checked songs" method in the iPod options (right click on the iPod in the source list in iTunes and select options, then select "only update checked songs"). With this preference checked, you can remove the check mark from the songs in iTunes that you no longer want on the iPod. The next time you connect the iPod, those unchecked songs will be removed from the iPod whilst still being retained in iTunes. You can check and uncheck songs as you change your mind about what songs you want to put on the iPod. Songs that have no check mark against them will be skipped over when played back in iTunes.
    If you have the iPod set to manually manage your songs, and you want to delete the song from the iPod only, then select the iPod in the source list of iTunes, or click on the "music" option underneath it to show all your songs. Highlight the song(s) you no longer want on the iPod, right click and select "clear", or use the edit menu as previously mentioned.
    This method only deletes the songs from the iPod, so if you no longer want the song in iTunes also, you'll need to delete it from there separately using the method above.
    If you are using iTunes version 7 or later, all these settings can be found in the summary screen.
    If you want to delete everything from the iPod and completely erase the hard drive and start from scratch, then you can restore the iPod to factory settings.
    Only do this if you have the songs in your iTunes library, or a back up somewhere other than the iPod itself.
    To play music from an iPod through iTunes, you need to set your iPod to manage the iPod content manually.
    This will make the songs on the iPod accessible and playable.

Maybe you are looking for