Problems accessing Objects created by JSF

I have a JSF page:
<h:form id="LoginForm">
          <tr><td><h:outputText value="#{msg.username}"/></td>
               <td><h:inputText id="username" value="#{userBean.username}" validator="#{loginValidator.validateUsername}" required="true"/></td></tr>
          <tr><td><h:outputText value="#{msg.password}"/></td>
               <td><h:inputSecret id="password" value="#{userBean.password}" validator="#{loginValidator.validatePassword}" required="true"/></td></tr>
          <tr><td><h:commandButton action="login" value="#{msg.signOn}"/></td>
               <td><a href="registerAccount.jsf" class="header"><h:outputText value="#{msg.createAccount}"/></a></td></tr>
</h:form>Which binds the entered data to my bean, but how do i access that very same bean in my validator? (i later want to update the data in the bean from a database call)
my validator:
public void validateUsername(FacesContext facesContext, UIComponent uIComponent, Object object) throws ValidatorException{
  System.out.println("Validate Username.");
  String username = (String)object;
  UserBean ub = (UserBean) uIComponent.getAttributes().get("userBean");
    if(ub == null)
     ub = (UserBean)FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("userBean");
        if(ub == null)
          ub = (UserBean)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("userBean");
  if(ub == null)
    System.out.println("userBean = null");Never seems to get the reference :(

Thanks for trying to help!
My JSF:
<h:form id="LoginForm">
     <tr><td><h:outputText value="#{msg.username}"/></td>
          <td><h:inputText id="username" value="#{userBean.username}" validator="#{loginValidator.validateUsername}" required="true"/></td></tr>
     <tr><td><h:outputText value="#{msg.password}"/></td>
          <td><h:inputSecret id="password" value="#{userBean.password}" validator="#{loginValidator.validatePassword}" required="true"/></td></tr>
     <tr><td><h:commandButton action="login" value="#{msg.signOn}"/></td>
          <td><a href="registerAccount.jsf" class="header"><h:outputText value="#{msg.createAccount}"/></a></td></tr>
</h:form>there I use it right? :S
Then in my validator i try to access the bean and get a NullPointer.
If you can plese help I have been struggeling with this for 10 hours now :(

Similar Messages

  • Can't access object created in the view from controller

    Hi
    In the view, I create a simple HTML control with a DIV tag.I need to access the DIV tag from the view.  The function this.getView().byId() returns nothing.
    view
    createContent : function(oController) {
                            var aControls = [];
                            var html = new sap.ui.core.HTML(
                                        content : "<div id='obj1' style='width: 300px; height: 200px;'></div>"
                            aControls.push(html);
                            return aControls;
    controller
    onInit: function() {
    this.getView().byId("obj1");
    Thanks.

    Hi Chen,
    The reason for this is the at
    this.getView().byId("obj1") would only work for XML views
    but for JS views
    sap.ui.getCore().byId('obj1') would work
    The difference between JS views and XML views is that the id's on DOM are different for JS view each control would get the same id as used in the definition but for XML views the id would get generated.
    Hope this helps.
    Thanks and Regards, Venkatesh

  • JS how to access objects created by plugins?

    say if a textframe was created by a third party InDesign plugin.
    How should one access and modify this "textframe" property using JS?
    Thanks in advance.

    You can only access a third-party plug-in's "text frame" if they programmed scripting support into the plugin. You would have to contact the third party to know whether they included scripting support in their plugin.

  • Problems accessing object variables in a Vector

    Hello all... perhaps someone can help:-
    I have a Vector - "ToolList" - which contains objects - "Tools". These tools have characteristics like: "ToolName", "Weight", "Dimensions".
    I'm trying to get the "ToolName" of each object listed in a ComboBox but I can't even access the "ToolName", farless list them in a combobox!
    How can this done?
    Ray.

    Hello all... perhaps someone can help:-
    I have a Vector - "ToolList" - which contains objects
    - "Tools". These tools have characteristics like:
    "ToolName", "Weight", "Dimensions".
    I'm trying to get the "ToolName" of each object listed
    in a ComboBox but I can't even access the "ToolName",
    farless list them in a combobox!I think I understand what you want. You want the name of the tool to appear in the combo box, but you're getting some garbage about Tools, right?
    When you add an object (or a vector of objects) to a ComboBox, it'll use the toString() method of those objects to get a String to display.
    So... in your Tools class, make a method
    public String toString()
        return ToolName;
    }HTH,
    Radish21
    PS Conventionally variable names start with lowerCase, as do methods. Only classes start with UpperCase.

  • Problem accessing newly created servlet in Sun IDM

    Hi, I am trying to implement Jcaptcha in Anonymous enrollment user form.
    I have done following steps to access the JCaptcha sample servlet...When i try to access this servlet am getting..."The requested resource () is not available"...I have a feeling that i am missing some configuration at some place....please let me knwo what i am missing here....
    1.Created servlet called "SimpleCaptchaServlet" and compiled and generated jar file and placed under /WEB-INF/lib...
    2. created entry in the web.xml as follows....
    <servlet>
    <servlet-name>simpletest</servlet-name>
    <servlet-class>org.xyz.captcha.SimpleCaptchaServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>simpletest</servlet-name>
    <url-pattern>/servlet/simple</url-pattern>
    </servlet-mapping>
    3. URL that am trying to access the same: "http://localhost:8080/idm/servlet/simple"

    Hi, I am not sure of what you mean...I guess you want me to test sample servlet...even sample hello world servlet does not work...again the the steps that i followed...
    1.Create a servlet and place it under ../WEB-INF/lib/sample.jar
    2.Create entry in web.xml
    ran as follows: "http://localhost:8080/idm/servlet/helloworld"
    Note: I am using "SJS app server 9.1_01" and "IDM 8.x version"...
    Thanks in advance

  • Problem accessing dynamically created table line

    Hi everyone.
    I'm unable to solve the following problem:
    In an offline scenario I have a table which contains one line at creation time. The form offers a button to add lines to the table using javascript and the instanceManager of the table.
    If the added lines are beeing filled by the user I can extract that data without a problem.
    But I cannot acces the newly generated fields with java script.
    I'm not sure, what the problem is. Here is the code, which should do the job:
    xfa.resolveNode("xfa.form.data.Inhalt.CONTACTS.DATA.NAMEV[" + position + "]").rawValue = 'Andreas';
    This works fine, for the table line, that exists right from the beginning(position = 0), but not for any added line.
    I keep getting this error: xfa.resolveNode("xfa.form.data.Inhalt.CONTACTS.DATA.NAMEV[" + position + "]") has no properties
    What am I doing wrong?
    Thanks for any hints,
    Andreas.

    Solved the problem now and it was fairly easy looking at it now.
    I don't know, why the above mentioned adressing does not work, but it works like this:
    var tab = xfa.resolveNodes("xfa.form.data.Inhalt.CONTACTS.DATA[*]");
    // get the last position
    var last = xfa.resolveNodes("xfa.form.data.Inhalt.CONTACTS.DATA[*]").length - 1;
    // fill values
    tab.item(last).NAME1.rawValue = "Andreas";
    Edited by: Andreas Heckele on May 17, 2010 11:07 AM

  • Accessing object of the main class from the thread

    Hi, I'm having problem accessing object of the main class from the thread. I have only one Thread and I'm calling log.append() from the Thread. Object log is defined and inicialized in the main class like this:
    public Text log;  // Text is SWT component
    log = new Text(...);Here is a Thread code:
    ...while((line = br.readLine())!=null) {
         try {
              log.append(line + "\r\n");
         } catch (SWTException swte) {
              ErrorMsg("SWT error: "+swte.getMessage());
    }Error is: org.eclipse.swt.SWTException: Invalid thread access
    When I replace log.append(...) with System.out.println(..) it works just fine, so my question is do the log.append(..) the right way.

    This is NOT a Java problem but a SWT specific issue.
    It is listed on the SWT FAQ page http://www.eclipse.org/swt/faq.php#uithread
    For more help with this you need to ask your question on a SWT specific forum, there is not a thing in these forums. This advice isn't just about SWT by the way but for all specific API exceptions/problems. You should take those questions to the forum or mailing list for that API. This forum is for general problems and exceptions arising from using the "core" Java libraries.

  • Problem accessing an object in a VBox

    Hi!
    I have a problem accessing an object which is in a VBox.
    I made an example so you can see my problem. I am trying to
    access pnlChat.
    If you load the swf you won't see the Alert because there is
    something wrong (and I don't know what)
    If you try to remove the <mx:VBox> tags that wrap the
    pnlChat Panel, it will work.
    Why can't I access this object when it is in a VBox?
    Thanks

    "Jimmy Jeeves" <[email protected]> wrote in
    message
    news:g8jv84$5ib$[email protected]..
    > Hi!
    >
    > I have a problem accessing an object which is in a VBox.
    > I made an example so you can see my problem. I am trying
    to access
    > pnlChat.
    > If you load the swf you won't see the Alert because
    there is something
    > wrong
    > (and I don't know what)
    > If you try to remove the <mx:VBox> tags that wrap
    the pnlChat Panel, it
    > will
    > work.
    >
    > Why can't I access this object when it is in a VBox?
    From the FAQ I'm compiling:
    Q: I need to set a property or add an event listener on a
    component
    that is in a ViewStack/TabNavigator/Accordion. When the
    component is not
    the first child of the Navigator Container, I get a null
    object error
    (#1009). What causes this, and how can I fix it?
    A: By default, the Navigator containers only create the
    children of
    each pane as that pane is viewed. The easy way to fix this is
    to set the
    creationPolicy on the Navigator to "all." However, this will
    cause your
    application to take longer to load. A better way to fix this
    is to wait for
    a later event, such as creationComplete on the component you
    want to access,
    or to use binding to "pull" the data into the component.
    The way I handle it is to call invalidateProperties() on
    change of the
    ViewStack. I then override commitProperties() and call an
    "initializer" for
    each pane. In the body of each initializer function, I check
    to see if the
    selectedItem for the viewStack is the one my initalizer cares
    about. If
    not, I return from the function immediately. Inside that
    initializer
    function, I set properties and add listeners as appropriate.

  • Can't access object using "id" or "name" if created with actionscript

    How can you register an instance of an object with actionscript so that it's id or name value is accessible?
    I included a simple example where a Button is created using mxml and in the same way it is created using actionscript.  The actionscript object is inaccessible using it's "id" and "name" property.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                   creationComplete="application1_creationCompleteHandler(event)">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                protected function application1_creationCompleteHandler(event:FlexEvent):void
                    import spark.components.Button;
                    var asBtn:Button = new Button();
                    asBtn.label = "actionscript";
                    asBtn.x = 200;
                    asBtn.id = "asButton";
                    asBtn.name = "asButtonName";
                    addElement(asBtn);
                    trace("mxmlButton="+this["mxmlButton"].label); // returns: mxml  label
                    //trace("mxmlButton="+this["asButton"].label); // returns runtime error: ReferenceError: Error #1069: Property asButton not found on TestId and there is no default value.
                    //trace("mxmlButton="+this["asButtonName"].label); // returns runtime error: ReferenceError: Error #1069: Property asButtonName not found on TestId and there is no default value.
            ]]>
        </fx:Script>
        <s:Button
            id="mxmlButton"
            label="mxml label"
            alpha="0.8"/>
    </s:Application>

    Hi Dan,
    It is a very rare occurrence when I miss not being able to access an object (object property, really) using the ["name"] notation for objects created using actionscript.
    In MXML the compiler is conveniently adding an attribute to the class with the same name as the id, so you can conveniently refer to it using the [] notation. While we explicitly specify an application container to use, the MXML compiler creates a custom container which is a derivative of the base container and to that it adds properties for the children declared in MXML. I guess it also effectively calls "addElement" for us when  the container is being constructed.
    Your example assumes that using "addElement" to add the button to the application container is the same as declaring a variable (ie property ). It isn't, so there's no point in looking for an property of the name "as3Button" using the [] notation, because it doesn't exist. The container is managing a collection of children in it's display list and that's not the same as being accessible as properties of the container.
    Generally speaking, accessing properties using the ["name"] syntax isn't necessary.
    Paul
    [edit: you may wonder why "addElement" doesn't conveniently also add the "id" attribute to be an property of the container class. Unfortunately, it can't because the container class would need to be dynamic and it's not. A further complication would be that adding properties at runtime would invite naming clashes at runtime with associated mayhem. MXML can do this because the compiler generates the class and can trap name duplication at compile time.
    Great question, BTW.
    -last edit changed my "attributes" to be "properties" in line with Adobe's terminology]

  • Accessing object by dynamically creating it's id?

    Hi All,
    hopefully this is a quick one, I just can't figure it out:
    I'd like to be able to access objects by their id, but I want to be
    able to do it dynamically.
    For example:
    I have two objects, already instantiated, object_01 and
    object_02 and would like to do something like:
    while (var i:uint = 1; i<=2, i++) {
    myMovieClip.addChild("object_0" + i.toString());
    Can this be done and if so, how?
    Thanks!

    Further to my own research, I discover 'this' (pun intended)
    while (var i:uint = 1; i<=2, i++) {
    myMovieClip.addChild(this["object_0" + i.toString()]);
    (it works)

  • How to access objects in the Child Form from Parent form.

    I have a requirement in which I have to first open a Child Form from a Parent Form. Then I want to access objects in the Child Form from Parent form. For example, I want to insert a record into a block present in Child Form by executing statements from a trigger present in Parent Form.
    I cannot use object groups since I cannot write code into Child Form to first create object groups into Child Form.
    I have tried to achieved it using the following (working of my testcase) :
    1) Created two new Forms TESTFORM1.fmb (parent) and TESTFORM2.fmb (child).
    2) Created a block named BLK1 manually in TESTFORM1.
    3) Created two items in BLK1:
    1.PJC1 which is a text item.
    2.OPEN which is a push button.
    4) Created a new block using data block wizard for a table EMPLOYEE_S1. Created items corresponding to all columns present in EMPLOYEE_S1 table.
    5) In WHEN-NEW-FORM-INSTANCE trigger of TESTFORM1 set the first navigation block to BLK1. In BLK1 first navigable item is PJC1.
    6) In WHEN-NEW-ITEM-INSTANCE of PJC1, code has been written to automatically execute the WHEN-BUTTON-PRESSED trigger for the "Open" button.
    7) In WHEN-BUTTON-PRESSED trigger of OPEN item, TESTFORM2 is opened using the following statement :
    open_form(‘TESTFORM2',no_activate,no_session,SHARE_LIBRARY_DATA);
    Since its NO_ACTIVATE, the code flows without giving handle to TESTFORM2.
    8) After invoking OPEN_FORM, a GO_FORM(‘TESTFORM2’) is now called to set the focus to TESTFORM2
    PROBLEM AT HAND
    ===============
    After Step 8, I notice that it passes the focus to TESTFORM2, and statements after go_form (in Parent Form trigger) doesnot executes.
    I need go_form with no_activate, similar to open_form.
    Edited by: harishgupt on Oct 12, 2008 11:32 PM

    isn't it easier to find a solution without a second form? If you have a second window, then you can navigate and code whatever you want.
    If you must use a second form, then you can handle this with WHEN-WINDOW-ACTIVATED and meta-data, which you have to store in global variables... ( I can give you hints if the one-form-solution is no option for you )

  • Error in accessing the create method declared in Home interface

    hi,
    I have create method in home interface which takes the following syntax:
    public ShipRemote create(ShipPK id,String name,int capacity,float tonnage) throws CreateException,RemoteException;
    In the client I create a remote object and try to call this create method, but I get a compilation error :
    it says unable to resolve the symbol with a cursor pointing the create method
    interface sampleEJB.ship.shipInfo.ShipHome ShipRemote remoteRef=(ShipRemote)homeRef.create(spk,sname,5000,100.7);
    how can i resolve this.
    I have implemented this create method in my bean

    hi i have compiled the client interfaces and the bean successfully.
    I have also imported the classes in the in the client code .
    I even deployed my jar successfully, but i have problem in accessing the create method specified .
    thank you

  • [Fwd: Security problem accessing MBeanServer from a servlet]

    Reposting to Security and Servlet newsgroups.
    -------- Original Message --------
    Subject: Security problem accessing MBeanServer from a servlet
    Date: 10 Feb 2004 13:02:09 -0800
    From: Alain <[email protected]>
    Reply-To: Alain <[email protected]>
    Organization: BEA NEWS SITE
    Newsgroups: weblogic.developer.interest.management
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer. Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine so far
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    Alain

    PaulF <paulf@reply_in_newsgroup.com> wrote:
    On 10 Feb 2004 13:02:09 -0800, Alain <[email protected]> wrote:
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer.Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine sofar
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    AlainWhat ResourceType are you trying to access. From the Exception you're
    trying to access it as an Anonymous user (principals=[]) and evidently
    you're attempting to access something that is protected. I can't tell
    what
    from the snippet you've included.
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
    Thanks Paul for your reply.
    You are right. I can access my custom MBeans if I am authenticated for example
    as an Administrator. My problem is that I want any application to access this
    MBean authenticated or not. I am trying to find how I could grant permission to
    this MBean to everyone. Still searching.
    Thanks.

  • Accessing objects with jstl

    Hello forum,
    A question about JSTL - one of the things I have not figured out until now. How can you access an object declared by a specialized tag? Generaly you c:set the variable you wish and you use EL to malipulate it. But how can you access a locale object or resource bundle object? Let's take the bundle object for example:
    The code that would declare it would be:
    <fmt:setLocale value="theLocale"/>
    <fmt:bundle basename="thebasename"/>
    Suppose that later in the code you want to access the created resource bundle object - how can you do that? Obviously a resource bundle object has been created, but how can you call one of its methods?
    Thanks in advance,
    Michael

    "and I really I am not that willing to decide that I will revert them to JSTL, at least not if they are really long"
    Well, right there is your problem. You will need to decide to do it, or not. You are experiencing one of the major problems of NOT using JSTL... when scriptlets get long they are difficult to maintain and change (which is why you shouldn't use them from the beginning.. but that is not pertinent to this topic).
    The issue is that some JSTL and some custom Tags have their own means of working with objects without sharing those objects with the application (it preserves encapsulation.. they can only be sure something is kept correct if they handle it themselves and don't let others mess with it).
    "This is a major problem for using jstl."
    This isn't a problem with JSTL, it is a problem of combining JSTL with scriptlets. JSTL should be used as a replacement for scriplets, in my opinion, not alongside them. It makes it much easier to
    1) plan what you are doing when coding
    2) read the code and understand it later when maintaining.
    So my advice would be to stick with one or the other (further I would suggest going all the way with JSTL, but the time of converting old scriptlet code is a negative that you will have to measure yourself...)

  • Problems Accessing Local Files

    Hi,
    I'm sure this has been discussed before, but I'm havign problems accessing a file on the target machine's local filesystem. I've signed all my jars and added the all-permissions tag to the jnlp file. However, my code:
    ClassLoader cl = getClass().getClassLoader();
    InputStream is = cl.getResourceAsStream("c:/resources/testsuite.xml");
    fails to find the file "testsuite.xml".
    Is this a classpath issue? I've tried to add c:/resources to the class path but with no luck.
    any help would be much appreciated
    Thanks

    Try "file://c:/resources/testsuite.xml" instead. I
    believe you are suppose to be passing in a valid URL
    and what you passed in wasn't.That's wrong. Resource name should be just a path. It could be a full path started from "/" or just a relative path from given class (here better to use this.class.getResourceAsStream() method).
    Better yet, since you are giving full security access
    to the user's local machine you don't really need to
    rely on the class loader at all. It's just a normal
    file, so you could create your File object and read it
    in the way you do normally. I would suggest to do not rely on File object at all because it can only be dealing with local file system and thats can't be changed in future.

Maybe you are looking for

  • I can't start my MacBook in safe mode or recovery mode

    I have a 2009 MacBook pro (bought in August), I am running Mavericks on it  Not entirely sure the exact patch. Last night it froze up on me out of the blue. I was able to move the mouse but wasn't able to click anything, open applications or even pul

  • How to reduce logical count and scan count for a select query

    hi, I have two tables one is master and other is history. i need to combine this two tables into one temporary table. I am using the below query to create temp table. Select * into temporders from (select * from orders union select * from ordershisto

  • Mail 4.6 and Exchange 2010

    I have a users using 10.6.8 and Mail 4.6 and when he syncs to our Exchange 2010 Server he gets his mail to June 16th but thats it. I have made use EWS is enabled and have trashed the mail.plist and all mail folders from ~/Libarary/Mail. I have also r

  • Integrate Employe with internal order other than cost center

    Dear Experts, Integrate Employe with internal order other than cost center Thanks & Regards, Mythili Edited by: Mythili.R on Jan 10, 2012 1:45 PM Edited by: Sikindar on Jan 10, 2012 6:23 PM

  • "dynamic" get_block_property

    Hi everybody, I have a problem with a "dynamic" get_block_property. The code is like that: Declare v_property varchar2(100) := 'INSERT_ALLOWED'; V_block varchar2(100) := 'BLOCK'; v_dummy varchar2(100); Begin v_dummy := get_block_property(v_block, v_p