Doubt in Getting and Adding ManagedBean from FacesContext???

Hi all,
I would like to know the proper way to get a managedBean instance from FacesContext.
let us consider the ways i follow normally
Way 1.
Mbean mBean=  (Mbean )FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(managedBean);
          if(mBean== null){
                    mBean = new Mbean();
                    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(managedBean,mBean );
     Way 2.
Mbean  mBean = (Mbean)((ValueBinding) getValueBinding(getElExpr(beanName))).getValue(getFacesContext());Those two ways mentioned above are used to get the managed bean Mbean from context level,my query is which one out of
these two ways is the best?
what exactly getValueBinding(getElExpr(beanName))).getValue(getFacesContext()); line does?
Thanks in advance,
sundar.

Way 1 will break if you change the scope of the bean in the faces-config.xml. Way 2 won't.
Here are more ways: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html#AccessingAnotherManagedBean].
If you're using JSF 1.1, I would use the createValueBinding approach. If you're using JSF 1.2, I would use the evaluateExpressionGet approach. But I more prefer the approach of injecting the one bean as a managed property of the other bean: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html#InjectingManagedBeansInEachOther].

Similar Messages

  • Hot to Make HTTPS GET and POST calls from ExtendScript

    We are currently porting our ActionScript code to ExtendScript (JavaScript).
    We performed HTTPS GET and POST calls from ActionScript with no problem. I can find no way to make HTTPS calls from ExtendScript. We tried jQuery, but after hours of work we can't get the ExtendScript engine to work with it - even a very, very old version of jQuery.
    What do I do?
    TIA,
    mlavie

    Adobe needs a "Want Answers" button like Quora has because I would press that button on this post.

  • How to get latest added file from a folder using apple script

    Hi..
    I am trying to get a latest added file from a folder..and for this i have below script
    tell application "Finder"
        set latestFile to item 1 of (sort (get files of (path to downloads folder)) by creation date) as alias
        set fileName to latestFile's name
    end tell
    By using this i am not able to get latest file because for some files the creation date is some older date so is there any way to get latest file based on "Date Added" column of a folder.

    If you don't mind using GUI Scripting (you must enable access for assistive devices in the Accessibility System Preference pane), the following script should give you a reference to the last item added to any folder. Admittedly not the most elegant solution, but it works, at least under OS X 10.8.2.
    set theFolder to choose folder
    tell application "Finder"
        activate
        set theFolderWindow to container window of theFolder
        set alreadyOpen to exists theFolderWindow
        tell theFolderWindow
            open
            set theInitialView to current view
            set current view to icon view
        end tell
    end tell
    tell application "System Events" to tell process "Finder"
        -- Arrange by None:
        set theInitialArrangement to name of menu item 1 of menu 1 of menu item "Arrange By" of menu 1 of menu bar item "View" of menu bar 1 whose value of attribute "AXMenuItemMarkChar" is "✓"
        keystroke "0" using {control down, command down}
        -- Sort by Date Added:
        set theInitialSortingOrder to name of menu item 1 of menu 1 of menu item "Sort By" of menu 1 of menu bar item "View" of menu bar 1 whose value of attribute "AXMenuItemMarkChar" is "✓"
        keystroke "4" using {control down, option down, command down}
        -- Get the name of the last item:
        set theItemName to name of image 1 of UI element 1 of last scroll area of splitter group 1 of (window 1 whose subrole is "AXStandardWindow")
        -- Restore the initial settings:
        click menu item theInitialSortingOrder of menu 1 of menu item "Sort By" of menu 1 of menu bar item "View" of menu bar 1
        click menu item theInitialArrangement of menu 1 of menu item "Arrange By" of menu 1 of menu bar item "View" of menu bar 1
    end tell
    tell application "Finder"
        set current view of theFolderWindow to theInitialView -- restore the initial view
        if not alreadyOpen then close theFolderWindow
        set theLastItem to item theItemName of theFolder
    end tell
    theLastItem
    Message was edited by: Pierre L.

  • Best way to get and pass filename from a DB Table to SQL Loader?

    What is the best way to get the data filename from an Oracle Table to pass it to SQL Loader?

    I am looking for a sompler way.
    I only want to instruct SQL Loader/Control file to get the filename from a table. Do we need external tables for this? Can I pass a funciton/SQL as parameter to filename?
    Thanks

  • Get and save image from camera

    Hi I need to grab an image from a camera and save it in a known format (such as TIF).  What is the best way to do this in LabView.  We are using an EDT camera via a PCI DV C-Link http://www.edt.com/pcidv_cl.html.  Appreciate any help/ guidance.

    EDT says:
    Do you have Labview drivers? Matlab? IDL? Others?
    Not
    directly. Our API is designed to allow programmers to build
    functionality into their applications, and all hooks are available to
    make EDT API subroutine calls from drivers for third party packages,
    but we do not provide the drivers ourselves. Some drivers are available
    from other providers; see our Partners page.
    So you will need to use the Call Library Function Node to integrate their Drivers DLL into your LV. How to save the images then in a standart format depends on the data format you get from their driver.
    Using an NI Framegrabber would be easier
    Christian 

  • Problem in getting a session object  from FacesContext into a Servlet

    Hi,
    I am new to JSF. I had a session bean and I want to get the instance of the session bean in a servlet. I wrote the below code to get the bean object, but some times it is failing and giving NullPointer Exception.
    Can anyone send the code which works perfectly to retrieve the Faces Context session bean object into a Servlet.

    Which code are you talking about? I don't see any code :)
    Well, this snippet here might be useful: http://balusc.xs4all.nl/srv/dev-jep-com.html#AccessingTheFacesContextInsideHttpServletOrFilter

  • Exporting and adding swatches from library

    Good Afternoon,
    I followed the tutorial at the below URL on creating your own customized swatches within your saved library and then adding them to your new site.  After adding them to the new site, they should automatically appear in the swatch window, however they are not showing up, can you please assist?
    http://helpx.adobe.com/muse/using/organizing-reusing-design-elements-using-library-panel.h tml#Creating custom swatches

    Upon investigating this further at my end, we found the issue was that I had created the rectangles in the source Muse file with custom colors - but DID NOT have those colors in the swatches panel. That caused the swatches to be not exported with the MULIB.
    Once I created swatches for my custom colors in the source Muse file and then exported rectangles with those color fills via Library, I was able to see the swatches added to my target Muse installation upon importing the MULIB.
    Let me know if your issue is similar. Also share the exact steps that you are following if your case is different.
    Cheers,
    Vikas

  • Itunes says it can't connect to my ipad because it gets and invalid response from the ipad

    Hi
    I am having trouble getting itunes on my windows pc to recognize my ipad.

    After a visit to the apple store, they were able to get through my pass code but unfortunately I found out that is was a problem with the logic board. Since Apple only wants to sell and not fix, I was able to locate an iphone repair near me that deals with logic boards and they are currently working on it right now. i should be getting it back soon. Im not sure if the problem you are experiencing is the same as i went through but it does sound like it may be also a hardware issue and would suggest searching online for an iphone repair place that can diagnose what exactly is wrong. Hope this helps.

  • How to get and use connection from Web AS 7.0 pool?

    Hello!
    I've set up a datasource and connection pool in my Web AS according http://help.sap.com/saphelp_nw70/helpdata/en/c0/3ad4d5cdc66447a188b582aad537d3/frameset.htm
    And I have some questions about using connection pool:
    1) here is my code which get connection form pool:
    InitialContext ctx = new InitialContext();
    DataSource datasource = (DataSource) ctx.lookup("jdbc/IndexesDataSource");
    Connection con = datasource.getConnection();
    return con;
    Does it properly?
    2) Which method I should call when I need to pass connection back to the pool? Will it be enough to call con.close()?
    regards, Lev

    Hi Lev,
    Write code like this
    try{
    InitialContext ctx=new InitialContext();
    DataSource ds=(DataSource)ctx.lookup("jdbc/indexsDataSource");
    Connection con=ds.getConnection();
    Statement stmt=con.createStatement();
    con.close();
    catch(Exception e)
    wdComponentAPI.getMessageManager().reportException("Exception "+e,true);
    also have a look at below links[Link|http://help.sap.com/saphelp_nw04/helpdata/en/61/fdbc3d16f39e33e10000000a11405a/frameset.htm][Link1|http://help.sap.com/saphelp_nw04/helpdata/en/46/ddc4705e911f43a611840d8decb5f6/frameset.htm][Tutorial|http://help.sap.com/saphelp_nw04/helpdata/en/91/9c2226df76f64fa7783dcaa4534395/frameset.htm]
    Regards,
    Krishna kattu

  • Satellite C850 - Where can I get and Win7 istallation .iso from?

    Hi guys,
    I've searched around and found lots of threads, but haven't actually found a solution.
    I bought C850 with Win7-64-home-premium preinstalled for my wife.
    First I wanted to decline Microsoft EULA and claim money back for Win7 licence, but I thought its only 50 or 60 quid, and I might want it once a year so I left it as is.
    First impression - its Terrible slow !!!
    I have an old NB100, with Atom and 2GB RAM running Linux witch I use from time to time when I work on the move and this old tiny netbook is A LOT faster then my new C850 with i3 and 8GB of RAM. I mean A LOOOOOT faster.
    Then I run Mint Live-CD and then I saw how fast C850 can be if only given real operating system instead of Microsofts crapware.
    Then I installed WIn7-64-professional and there was a BIG difference. It wasn't nowhere near as fast as on Linux Mint, but it was whole lot better then original install.
    That was only to check how it goes on clean install. I do not have licence for Win7-pro for C850 and I have not even a slightest intention of paying for something as useless as Win7. People should be paid for all the suffering caused by Win7.
    On the other hand I would gladly pay for Linux Mint and in fact I have made a nice donation to the project not long time ago :)
    Conclusion - slowdown was casued by Toshiba bloatware (which is completely not needed for proper operation of laptop!) and all the other stuff like McAfee or Nero.
    I've tried to do reinstall but the reinstalled Win7 comes with all this bloatware and I need clean Win7 install.
    To cut short answers like "install and delete waths not needed" - that doesn't solve the problem for two reasons:
    1) if install and delete, a lot of stuff stays on the system, registry entries, lots of files etc
    2) I need and .iso of Win7, so I can slipstream few things and get rid of WHOLE LOT of useless things
    Where can I get and istallation .iso from ?
    I mean clean Win7 without all that Toshiba bloatware, McAfee, Nero and other rubbish.
    Mind you, I purchased a laptop with Win7 licence so I do have LEGAL RIGHT to use Win7 on its own.
    Any hint VERY MUCH appreciated.
    Thank you.

    On this forum you can find a lot of similar threads where people write about the same experience. We can discuss about this theme for days but the conclusion is always the same: new notebooks are delivered with recovery image that contains OS, all necessary drivers, Toshiba specific tools and utilities, additional software and some stuff that nobody needs.
    Nobody force notebook owners to use recovery image like this. What you must do is OS optimizing. Remove all software you dont need, disable auto start for all not important stuff and check Windows settings. I do the same all the time and there is big difference how notebook runs, especially start-up time will be much shorter. On this forum you can find very interesting threads about that.
    So my advice for you is to install recovery image again and optimize it. The performance will be OK and your wife will have nice piece of hardware for everyday work.
    > 1) if install and delete, a lot of stuff stays on the system, registry entries, lots of files etc
    Everything can be removed but if you dont do this it is definitely not so critical for notebook performance.
    > 2) I need and .iso of Win7, so I can slipstream few things and get rid of WHOLE LOT of useless things
    At first, you will not find iso file anywhere and slipstreaming will not work at all. You cannot unbundle recovery image and use parts that you need. It doesnt work on this way.
    I just hope you have created recovery disc before you have started your testing phase.

  • When i first got my iphone i plugged it into my friend's computer and songs on from itunes. Now it will not show up in the side bar when i plug it into my computer. I have already tried 'authorizing this computer'. What can i do?

    When I first got my iphone i plugged it into my friends computer and added songs from their itunes. Now when i plug it into my computer it will not connect or show up in the sidebar in itunes. I have already tried factory resetting the phone and 'authorizing this computer' in itunes. Can anyone help?

    Is your iTunes up to date, it is now 10.7, click the iTunes button at the top of this page if you need the new version.

  • Get and SetValue in CoreInputText

    Can You tell me how can I get and set value from CoreInputText ??
    Some example ?
    thanks

    Create a value binding through "Value" property of your af:inputText component
    In that way when the page is been rendered the component will read its value from the managed bean and when the form is submitted its value will be set into the managed bean
    In most cases the variable created in your managed bean is of type String, if you don´t need ADF to convert it

  • How do you get Itunes to only sync newly added photos from my phone to the computer and not every photo on my phone each time I try to sync?

    How do you get Itunes to only sync newly added photos from my phone to the computer and not every photo on my phone each time I try to sync?

    Hello Angelcasper,
    Welcome to Apple Support Communities.
    The following article provides some suggestions on importing photos from your iOS device to your computer.
    iOS: Import personal photos and videos from iOS devices to your computer
    http://support.apple.com/kb/HT4083
    Regards,
    Jeff D.

  • Help!  I thought I was pretty good setting up slide shows and adding music.  I'm trying to make a new slide show from a great trip to New York.  I can get theme music but no music at all from iTunes.  Checking my older slide shows, which did play music!

    Help!  I thought I was pretty good setting up slide shows and adding music.  I'm trying to make a new slide show from a great trip to New York.  I can get theme music but no music at all from iTunes.  Checking my older slide shows, which did play music, it's all gone!
    Problem seems to have started after updating to Mavericks.
    Is there a box I need to check/uncheck?
    Any help very welcome!

    Hopefully you've seen the post from Terence Devlin?  I've pasted it below.
    In iTunes go File -> Library -> Organise Library -> Reorganise Library.
    Then quit and restart iPhoto.
    Pity Apple didn't either warn us or set up a bug fix!

  • HT1277 I can't seem to get gmail from my apple mail account. I have removed the account and added it, but it says I have the wrong password. I close gmail and get in just fine. What's up?

    I can't seem to get gmail from my apple mail account. I have removed the account and added it, but it says I have the wrong password. I close gmail and get in just fine. What's up?

    I meant that I sign out, sign back in ok. Ergo, I know my password. Someone here on the support page  (you?) told me the culprit is the 2 step verification process which I had on. That makes a lot of sense as Apple mail won't get a code thereby jamming up the process. I could not even start a new account until I took that 2 step process off. Everything fine now thank you.

Maybe you are looking for

  • Error: InfoObject does not contain alpha-conforming value 20030729

    Hi everyone, I got this problem, that i tried to fix yesterday, but all i did was that i got realy frustrated... I created an infoobject which is copy of 0DOC_NUMBER and has alpha coversion routine. Mapping field in DataSource is also type character

  • Acrobat Pro 9.0 to 9.3.1 update path needed

    I have called Tech Support.  I thought this was a brainless question to ask and figured the tech would ramble out the answer like he's probably done 100 times today. But no.  I guess I stumped him because the best he could do was point me to a CS4 Ma

  • X: drive HP Pavilion d7 HD crash

    0) PROBLEM: no Win 7 Home Premium OA boot/ goes into SMART check failing error HD1 (301). reboot gives X: boot 1) Boots to boot drive X: (whatever that is!) and includes mystery G: drive. Drive letters changed/incremented from pals’ *identical* machi

  • Finding no. of days in a month in formula variable

    Hi all I wanted to find out no. of days in a month in formula variable customer exit at bex. I did the following code, which returning X value. Can anybody helps here. WHEN 'ZFV_NO_DAYS_MONTH'.      IF I_STEP = 2.        CLEAR L_S_RANGE.        READ

  • HP Deskjet printer won't print after 7.6 FW installed.

    This used to work wth 7.5; after updating to 7.6 nothing gets printed; I have deleted/recreated the printer via Bonjour but no luck yet. Can anybody please shed some light? Thanks! Fernando