Setting the property of a managed bean

Hello,
I have just started working on a project that I would like to use Java server Faces. I am very new to JSF so please forgive the question if it is too obvious.
We are doing a login form with a username, password and key. The key is an image that contains randomly generated characters that the user needs to type in what is in it to verify that it is a human and not an automated system trying to log in.
So my loginForm managed bean contains four properties (get/set) username, password, key, userkey (this is what the user types in and needs to equal key for the login to work).
The user will enter in (using <h:inputText />) the username, password and userkey but I need to know how to set the key to the randommly generated characters that I used to create the image with.
I know I can use <h:inputHidden /> to set the value but that would defeat the purpose because an automated system could read the page an know what the image contains (because the value would be in the HTML code sent to the browser).
The random characters and the image is generated in a servlet and the key is set in a session variable.
How can I take that session variable that contains the key (characters randommly generated) and put it in my managed bean so I can verify that the user entered the correct information?
I have been searching on Google all morning. I probably do not know what to put in for the search to get the correct information out.
Thanks in advance for any help you can provide.
Jon

Since your key is already in a session variable, you don't really need to make it a property of your managed bean, but just access it directly. For example, you could have a property called "keyCorrect" with a getter something like this:
public boolean isKeyCorrect()
    String key = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("key");
    return getUserKey().equals(key);
}

Similar Messages

  • How to output some JSF codes depend on the value of a managed bean

    like this:
    <?
    if (managedbean.propertyA == "1"){
    ?>
    <h:commandButton action="#{managedbean.update}" value="update"/>
    <?
    }else {
    ?>
    <h:commandButton action="#{managedbean.delete}" value="delete"/>
    <?
    ?>
    I know how to get the instance of a managed bean from jsp,
    but i think It is not a good idea that writing scriptlets to get the instance, then writing code like above .
    Is there a simple/reasonable way to implement this?
    Thanks.
    David

    Try this:
    <h:commandButton action="#{managedbean.update}" value="update" rendered="#{managedbean.propertyA == \"1\"}"/>
    <h:commandButton action="#{managedbean.delete}" value="delete" rendered="#{managedbean.propertyA != \"1\"}"/>

  • Catch exceptions that occur in the constructor of a managed bean

    Hello,
    I would like to catch exceptions that might occur in the constructor of a managed bean and redirect to an error page. My beans need to get data from a database and if the database is not accessible, an error page is to tell the user "try again later". I don't want to write an action or actionListener that is invoked by a button klick on the previous page to make error handling easier, because an actionListener should not know about the next page and what data the next page will need.
    I read all postings about this topic I could find in this forum. And there are three solutions I tried:
    1) register an error-page in web.xml
    Is there an example for using this in a JSF application? It did not work. I got a "Page not found" exception
    2) Use a phase listener. But how can a phase listener do this? Is there an example? I don't think it can do it in the beforePhase method because this method is called before the constructor of the managed bean is called.
    3) Use a custom ViewHandler. This is my renderView method which creates a "Page not found" Exception.
    public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
    ViewHandler outer = context.getApplication().getViewHandler();
    try {
    super.renderView(context, viewToRender);
    } catch (Exception e) {
    context.getExternalContext().redirect("/error.jspx");
    Several people write they've done it one or the other way. Please share your knowledge with us !!
    Regards,
    Mareike

    Hallo Mareike,
    Maybe I should abandon managed beans, create my own
    "unmanaged" ones inside of an action listener and put
    them somewhere my pages can find them.
    Its a pity, because I like the concept of managed
    beans.sure setter injection of JSF is fine!
    well workaround could be using <h:dataTable rendered="#bean.dbAccessible" ...>
    In your constructor you catch the exception and set
    dbAccessible = false;
    or you use error pages of webcontainer,
    but the pages couldn't contain JSF components, IMHO
    only plain JSP files.
    BTW perhaps somebody on MyFaces' list knows the solution:
    http://incubator.apache.org/myfaces/community/mailinglists.html
    Regards,
    Mareike-Matthias

  • How can I set the value to a session bean from backing bean

    Hi Experts,
    How can I set the value to a session bean from backing bean where I have created getter and setter
    methods for that variable.
    Basically I am using ADFUtils class where I am able to get the value from session bean
    using following expression
    String claimType =
    (String)ADFUtil.invokeEL("#{ClaimValueObj.getClaimType}");
    Thanks
    Gayaz

    Gayaz,
    Wrong Post !!
    Post in JDeveloper and ADF
    Thanks
    --Anil                                                                                                                                                                                                                               

  • Setting the property "Cache Level" of the pcd object to "None".

    Hi all
    I have an EP 6.0 on NW04 SPS 17. I need to solve a problem and found note 960975. My question is, how could we change the setting the property "Cache Level" of the pcd object to "None"? Where should I go? Is it on the NWA, Visual Admin, Configtool or somewhere else?
    Many thanks before.
    Regards
    Agoes
    Message was edited by:
            Agoes Boedi Poerwanto

    Hi Agoes,
    By using the tool Support Desk -> Portal Content Directory -> PCD Administration you can do this. Please note that this tool should only be used in debugging situations.
    There is a new section "Release a Unit from the cache cluster wide" in this tool. With this new functionality, you can remove an object from the cache on all nodes in the cluster. If the object is still in use, it will be reread immediately from the database
    Releasing the entire PCD cache can severely affect performance. Hence, if there are inconsistencies suspected with a single object, e.g. a role or an iview, the new section "Release a Unit from the cache cluster wide" can be used to evict the given object from the cache on all nodes in the cluster.
    Cheers,
    shyam

  • Exception setting the property 'dbcFile' on the DataSource. Exception:

    Hello,
    I just upgraded 12.1.3. and I could not see my loging page(Non SSL)
    oracle.oc4j.sql.DataSourceException: Exception setting the property 'dbcFile' on the DataSource. Exception: java.lang.reflect.InvocationTar
    getException
    Any one had this problem before or had some experience, Please share some info
    Thanks
    Prince

    Prince,
    oracle.oc4j.sql.DataSourceException: Exception setting the property 'dbcFile' on the DataSource. Exception: java.lang.reflect.InvocationTar
    getException
    Any one had this problem before or had some experience, Please share some info Please see these docs.
    How to Configure OTA For XML Gateway in Release 12 [ID 418926.1]
    Oracle E-Business Suite Integrated SOA Gateway Troubleshooting Guide, Release 12 [ID 726414.1]
    Cannot Start OXTA After Upgrade To R12.1.x [ID 1087499.1]
    OXTA Not Starting In R12 [ID 1267410.1]
    Troubleshooting and Known Issues for EBS SOA Suite Deployment in R12.1.1 [ID 797596.1]
    Thanks,
    Hussein

  • How to set a value in a managed bean when click on a button

    Dear all
    I have a managed bean that contains an attribute of type string as follow:
    the attribute name is taskFlowId
    package dhamanADM.view.beans;
    import oracle.adf.controller.TaskFlowId;
    public class dynamicTaskFlowManager {
       private String taskFlowId = "/WEB-INF/flows/procedureMaster.xml#procedureMaster";   
        public dynamicTaskFlowManager() {
            super();
      public TaskFlowId getDynamicTaskFlowId() {
       return TaskFlowId.parse(taskFlowId);
    }I want to change the value of this attribute when clicking on a commandMenuItem as follow
       <af:commandMenuItem text="Mission Persons" id="pt_cmi1"
                                                action="missionPers">
       <af:setActionListener from="/WEB-INF/flows/editPersionMission.xml#editPersionMission"
                                      to="#{pageFlowScope.dmDynamicTaskFlowManager.dynamicTaskFlowId}"/>
       </af:commandMenuItem>at run time when clicking on the menu this error appears
    java.lang.IllegalArgumentException: Cannot convert /WEB-INF/flows/editPersionMission.xml#editPersionMission of type class java.lang.String to class oracle.adf.controller.TaskFlowId
    My target is just to change the value of the attribute "taskFlowId" when clicking on the commandMenuItem
    how can i do this?
    Thanks in advance
    Edited by: ta**** on Mar 29, 2011 1:24 PM

    You are setting to set a String value where a type of TaskFlowId is required.
    Looks like, you are trying to set the taskFlowId for the dynamic region. Modify the code as follows:
    public class dynamicTaskFlowManager {
    private String taskFlowId = "/WEB-INF/flows/procedureMaster.xml#procedureMaster";
    public dynamicTaskFlowManager() {
    super();
    *public TaskFlowId getDynamicTaskFlowId() {*
    AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
    String currentTaskFlowId =
    *(String)adfFacesContext.getPageFlowScope().get("CurrentTaskFlowId");*
    if (currentTaskFlowId == null ||
    *currentTaskFlowId.trim().equals("") == true) {*
    currentTaskFlowId = taskFlowId;
    return TaskFlowId.parse(currentTaskFlowId);
    In the MenuItem, modify it as follows:
    <af:commandMenuItem text="Mission Persons" id="pt_cmi1"
    action="missionPers">
    *<af:setActionListener from="/WEB-INF/flows/editPersionMission.xml#editPersionMission"*
    *to="#{pageFlowScope.CurrentTaskFlowId}"/>*
    </af:commandMenuItem>
    Thanks,
    Navaneeth

  • Accessing property of one managed bean to another in request scope

    Right now my applications managed beans are in session scope.
    I want to change them to request scope .But the problem is how to access the bean methods to another if they are in request scope

    Use RequestMap instead of SessionMap.
    Having multiple and independent managed beans in the request scope for 1 request and the need to access the other bean is somewhat odd design however. You may need to rethink about it. For example, add one of the beans as property of the other bean.

  • How to programmatically Identify the Phase from a managed bean

    How can we identify the Phase from a normal managed bean method ?
    This managed bean method is a method activity in a task-flow. How can we identify the phase..?
    If there is an event then, we can identify the phase using event.getPhaseId() but here there is no event. Can I get the phase programmatically ?
    Thanks

    Hi,
    You won't need that with a PhaseListener. You could use something like the following:
    public class CurrentPhaseListener implements PhaseListener
        private static ThreadLocal<PhaseId> currentPhaseId = new ThreadLocal<PhaseId>();
        public static PhaseId getCurrentPhaseId()
            return currentPhaseId.get();
        public void afterPhase(PhaseEvent ev)
            currentPhaseId.remove();
        public void beforePhase(PhaseEvent ev)
            currentPhaseId.set(ev.getPhaseId());
        public PhaseId getPhaseId()
            return PhaseId.ANY_PHASE;
    }Regards,
    ~ Simon

  • Sitestudio - Set the property of a section automatically

    Hi,
    I am using Sitestudio 10gR4.
    Is it possible to set the "URL Directory Name" property of a section automatically?
    I want to set the "URL Directory Name" equal to the "Section Id" property. Please let me know if someone has an idea.
    Thanks
    Bodhy

    the problem is, that the "url directory name" is set automatically equal to the "label". But I want the "url directory name" to be set to the "Section ID".

  • Problem while setting the property of column in ALV

    Hi ,
    I have created a alv dynamically and setting the properties of the column like column header text but its not getting updated .
    see the below code for ref.
    lr_column_settings ?= lr_config_table.
      data:
        lt_columns type salv_wd_t_column_ref.
      lt_columns = lr_column_settings->get_columns( ).
      data: lr_column      type ref to cl_salv_wd_column,
        lr_header      type ref to cl_salv_wd_column_header,
        ls_column type salv_wd_s_column_ref.
      loop at lt_columns into ls_column.
        case ls_column-id.
          when 'MOIST'.
            lr_column = ls_column-r_column.
        lr_header = lr_column->get_header( ).
        lr_header->set_text( 'Moisture %' ).
    I am able to set the alv properties like  visible row count etc ..
    can anybody help out in this issue
    Regards
    Yash

    I was just able to change my headers with the following:
    data:
        lt_columns     type salv_wd_t_column_ref,
        ls_column      type salv_wd_s_column_ref,
        lr_header      type ref to cl_salv_wd_column_header.
      lt_columns = lo_value->if_salv_wd_column_settings~get_columns( ).
      loop at lt_columns into ls_column.
        lr_column = ls_column-r_column.
        lr_header = lr_column->get_header( ).
        lr_header->set_ddic_binding_field( if_salv_wd_c_column_settings=>ddic_bind_title ).
        lr_header = lr_column->create_header( ).
        case ls_column-id.
          when 'CNT_LINEITEMS'.
            lr_column->r_header->set_text( 'Line Items' ).
          when 'VAL_OPEN'.
            lr_column->r_header->set_text( 'Open Amount' ).
          when others.
        endcase.
    endloop

  • Digital Signature Turns Invalid while setting the Property Dynamically to an Input Field

    I have an Input box that turns mandatory only if a check box is clicked.
    The Script goes Something Like This;
    if(chkbox.rawValue === 1){
         inputField.mandatory = "error";
         inputField.mandatoryMessage = "This Field cannot be left Blank";
         inputField.presence = "visible";
    } else {
         inputField.mandatory = "disabled";
         inputField.mandatoryMessage = "";
         inputField.presence = "hidden";
    I am working with Assembler Service and the Signature field is placed in the cover page after which this form is attached.
    Any clue of why the property change Invalidates the Signature?
    Note: The stand alone form where the Check box and Input field is present doesnot have a preSign event as this form doesnot contain a Signature field unless its merged using assembler. This Script is added to the Click Event of the Checkbox.
    Cheers
    Mahesh Krishnan

    weblogic.common.resourcepool.ResourceDisabledException: Pool mds-soa is Suspended, cannot allocate resources to applications ..Check server logs to find out why mds-soa is suspended. Make sure that datasource mds-soa is up and running on SOA servrs before deploying an application.
    Regards,
    Anuj

  • How to change the package name of Managed Bean class

    Hi: Gurus, when ever I create a new JSP page the Creator creates a code behind file with a package name untitled. Is there any way to change this package name? Can't the Creator gives us an option before genereating manged bean page to choose a package name? And then create the Java source directory structure on the basis of the pakcage name?
    Regards,
    Rashid.

    In the Project Navigator (default location is middle right), go to Java Sources, and you can rename the package ("untitled") to something else by right-clicking it or by left-clicking (just like Windows Explorer).
    I agree, though, that giving the developer an option during creation of the JSP page would be nice.

  • Accessing the ViewRowImpl in Managed Bean

    Hi,
    I am having the requiredment like setting the data to view object based on some conditions. Here after setting the data to a view object, i dont want to make my transaction as dirty, so am using the populateAttribute. since am setting the single attribute am planing to get the ViewRowImpl and want set the data in my managed bean instead of writing the service method in viewImpl.
    is it the good approach to get the viewRowImpl in managed Bean.. Please suggest...
    Reg,
    Brahma B.

    Hi Frank Thanks for your reply...
    Here i will create a record before loading the screen in add mode for accepting the user input. after creation of the record i will set some data programatically(the data may be usefull for dropdown which i attached to the a perticular column).
    Reg,
    Brahma B.

  • Binding af:selectOneChoice to value in managed bean

    Hi all,
    I am trying to create a simple screen that has a selectOneChoice that allows the user to change the value of a property in a session-scoped managed bean. I've got a View Object that will display the values for the user to select. I can easilly set the value on my managed bean in an actionlistener when the user clicks "OK"
    However, I have these problems:
    1). I can't find any way to put an af:selectOneChoice on the screen without binding it to something. I want to bind it to a value in a managed bean - how to do this?
    2). I tried creating a "dummy" view object (select :bindVariable from dual) and then put an executeWithParams in the executable of my page to set the bind variable to the backing bean value. I then bound the selectOneChoice to that field from the VO. This worked fine the first time, but the second time I tried to call it in the same session, it bombed with JBO errors. This also seems like a very inefficient and round-about way to accomplish this task.
    Can anyone provide any pointers as to how I might accomplish this? If it would help, my use case is this: a user is logged on with "super-user" athority and can review information from any of the field offices. The field office ID that the user is currently looking at is stored in the session-scoped bean. I need a way for the user to change what field office they are reviewing.
    Thanks and regards,
    John

    Wow - this is harder than I thought....
    I have got something working in a rudimentary fashion, although I'm not completely satisfied yet. What I did was to create my own List binding in the page definiton that looks like this:
    <list ListOperMode="1" IterBinding="LKUP_OfficeViewIterator" id="OfficeId">
          <AttrNames>
            <Item Value="OfficeName"/>
            <Item Value="OfficeId"/>
          </AttrNames>
        </list>
    </list>I then dropped a selectOneChoice from the component pallette (not the data control pallette) on to my page. The f:SelectItems component inside the af:SelectOneChoice, I bound the value property to "#{bindings.OfficeId.items}" I could not find any documentation on this, but it seems to work. The only issue is that my list shows both the office name and the id (I'd like to show the name and hide the id).
    Then, in my backing bean action listener bound to the OK button, I do:
        JUCtrlListBinding o = (JUCtrlListBinding) JSFUtils.resolveExpression("#{bindings.HotelId}");
        // list is bound to my af:SelectOneChoice
        Row r = (Row) o.getValueList()[((Integer)list.getValue()).intValue()];
        Integer officeID = (Integer) r.getAttribute(0);
        String officelName = (String) r.getAttribute(1);
       // getUserInfo gets my session-scoped bean
        super.getUserInfo().setOfficeInformation(officeID, officeName);
         AdfFacesContext.getCurrentInstance().returnFromDialog("ChangeOffice:OK", null);My 2 problems with this approach:
    1). How do I get the list to just show the office name (but still make the ID available)?
    2). No matter what I put for the value of the af:SelectOneChoice, I can't seem to make it have the current value from userInfo.getOfficeID selected in the list. Even when I hard-code a number in the list, nothing is selected. When I bind the value to an EL property referring to userInfo.officeID, the selectOneChoice doesn't even render!
    Regards,
    John

Maybe you are looking for

  • Shell script for exp

    Hello All, OS: AIX 5.2 we are doing full export of our database schema as below: exp username:schema name Enter array fetch buffer size: 4096 >Export file: expdat.dmp > exp020806v1.dmp (2)U(sers), or (3)T(ables): (2)U > U Export grants (yes/no): yes

  • How to Display all xml files at time in the browser

    Hi, In my solution , it have one folder contain all xml files onliy like Billersettings.111.2.xml , Billersettings.113.2.xml...etc. Each xml file have only one record like biillerid,name,amount,date..etc. Now , when i run the page ,it should be show

  • How do I change the fixed song length in iTunes?

    I have a song that's 6:50 in length, but iTunes reports it as 5:42. It plays the whole song OK, but freezes the progress bar at the 5:42 mark with "time remaining: 0:00" displayed on the screen for the final 1:08. Also, no matter how many times I lis

  • CFDocument - controling file File size

    Hi, I am using cfdocument to generated a PDF file. It is a single page (A4), just HTML (not too heavy), no images. The resulting PDF file size is coming out at 500k+. This seems ridiculously high for what it is. I would expect it to be well under 100

  • How could a down-mix APOs receiving multi-channel audio data from the application

    Hello,     Now I am integrating my DSP algorithm to the APO whichs convert to 7.1 input to stereo output(we call it virtualization), but the endpoint just supports stereo input. My first question is can my APOs receiving a 7.1 input data from applica