How to call bean funtion once page is loaded?

Hi guys,
I am doing a user activation page. I need to call a bean function once the page is loaded. For example,
http://www.abc.com/activate.jsp?code=12345678
<c:if test="$"empty param.code">
<!-- call activate function a bean -->
</c:if>
public class UserBean{
private String code;
public activateAction(){
So how to call the above function? Thanks
regards,
kmthien

Hi, how to pass in the parameter to the bean? I am
using JSF framework !If you are using JSF, I have no clue. Never used it. Maybe ask in the JSF forum.
If it works the same as normal JSP/JSTL, then that last bit of code should do it (though I misspelled the property name:
<c:if test="${empty param.code}">
  <c:set target="${instanceOfUserBean}" property="actionActivated" value="true"/>
</c:if>But like I said, if activateAction is a special method needed for JSF or something, ask in the JSF forum

Similar Messages

  • How to call java method on page load?

    How to call java method on page load?
    Thanks

    Hey Dan,
    Well, if you want to execute a java method when page is load, you need to put the clientlistener in af:document. Let me to show you an example (I can't find my post :P),
    JSPX page:
    <f:view>
    <af:document>
    <f:verbatim>
    <script>
        function loadPage(event) {
            alert('Hello World!');
    </script>
    </f:verbatim>
    <af:clientListener method="loadPage" type="load"/>
    </af:document>
    </f:view>If you try this code you can see that when the page has been load, you recieve the alert "Hello World!".
    Furthermore, this is the javascript AJAX function that let you to call a servlet:
    function ajaxFunction () {
        var httpRequest;
        if (window.XMLHttpRequest) {
            httpRequest = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            httpRequest.overrideMimeType('text/xml');
        httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
        httpRequest.open('GET', '/appname/servletname', false);
        httpRequest.send('');
    function alertContents(httpRequest) {
        if (httpRequest.readyState == 4) {
            if (!httpRequest.status == 200) {
                alert('Request error. Http code: ' + httpRequest.status);
    }Where 'appname' is your application name and 'servletname' is the name of the servlet that you want to call. Obviously, you can call any URL ;)
    JVN

  • Smartforms - how to call 2nd secondary window page

    Hi
    How to call 2nd secondary window page from Ist Main window. The scenario is i have one main page. I have already called 2nd page thru command line and now want to call another page (i mean third page) from same main window. How do I do?
    Thanx and regards,
    Rajesh Vasudeva

    Hi Rajesh,
    Go for the below link>>>>>
    [http://help.sap.com/search/highlightContent.jsp]
    thnks.

  • Every time I start Firefox, the upgrade/signup page is displayed in one tabe while google, my start;up page s displayed in another. How can I stop the firefox page from loading every time?

    Every time I start Firefox, the upgrade/signup page is displayed in one tab while google, my start-up page is displayed in another. How can I stop the firefox page from loading every time?

    See these articles for some suggestions:
    * https://support.mozilla.com/kb/Firefox+has+just+updated+tab+shows+each+time+you+start+Firefox
    * https://support.mozilla.com/kb/How+to+set+the+home+page - Firefox supports multiple home pages separated by '|' symbols
    * http://kb.mozillazine.org/Preferences_not_saved

  • How to call a action on page load in jsf

    Hi all,
    i am having a JSF page where i want to display the records from the datatable. I have a method in bean which call database and gets the list of records. If i call this method from a link (action on this link) present on this page i can display the records on this page.
    But i want to display these records at the time of page load only. How we can do this? How to call a action at the time of page load?
    Thanks in adv.

    If i am calling the database class and get the list in constructor only i am able to display list in the datatable on page load. This works fine. But the requirment is that if there are no records in the list display a error page with message-No records found! . But how i can navigate from the constructor to error page?
    Like-
    class MyBeam{
    MyBean{
    private List requestVOList = null;
    MyDao dao = new MyDao() //for fetching list from DB
    List records = dao.getList()  //get list from dao class
    if(records==null)
        //Navigate to error page. How to do this navigation here?
    else
        requestVOList  = records;
    //setter/getters for requestVOList 
    }

  • Calling a method in backing bean whenever a page is loaded/reloaded

    Hi,
    What is the best way to call a certain method in a backing bean whenever the jsp page is reloaded?
    I have a managed bean that provides the data for a form and the bean gets it's data from a SQL DB. I want the bean to reload the data from the DB when and only when the page is loaded or reloaded. (I.e. it should the call method loadData() )
    What is the best way to do this?
    /R

    If the bean is request scoped, just call the logic in the init block or in the constructor, or even in the accessor.
    If the bean is session scoped, call the logic in the accessor.
    http://balusc.xs4all.nl/srv/dev-jep-dat.html might give some insights.

  • How to call parameter of 101 page on page 1

    Greetings,
    i wanted to call parameter on login page "P101_USERNAME" on page 1 .
    Cust_user is a table from where i m authticating my username and password, Authtication is doing fine but i want the customer id of the specific customer in the cust_user table to display after login on page 1. for that i wrote query on page 1 "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER(:P101_USERNAME), but it is displaying nothing , if i harcore the specific username instead of :p101_username it is working fine e.g "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER('test'),
    Please gudie me how to get value of text field (p101_username login page ) on page 1, that is first page after login.

    Hi,
    i wanted to call parameter on login page "P101_USERNAME" on page 1 .Cust_user is a table from where i m authticating my username and password, Authtication is doing fine but i want the customer id of the specific customer in the cust_user table to display after login on page 1. for that i wrote query on page 1 "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER(:P101_USERNAME), but it is displaying nothing , if i harcore the specific username instead of :p101_username it is working fine e.g "SELECT cust_id FROM cust_user WHERE UPPER (USERNAME) =UPPER('test'),
    Please gudie me how to get value of text field (p101_username login page ) on page 1, that is first page after login.>
    Use :APP_USER. If your authentication scheme is working right then the username should be in :APP_USER.
    Cheers,

  • Calling Beans from JSP page

    hi,
    I tried to my best to call java beans from JSP page but it generate error that "unable to load class....", please help me that in which directory jsp file and bean *.class file reside, currently my setting are as follows.
    Note: I am using tomcat server and my jsp and servlet files are running seccessfuly, there is any special change in classpath for java beans? if any please tell
    My jsp file is in tomcat-->webapps-->jsp--><my file>
    My bean (*.class) file-->webapps-->Root-->web-inf-->classes--><my file>
    Pleae help me for the above problem.
    Mubashar ([email protected])

    According to J2EE standards:
    The web appl directory structure should be:
    WebAppRootDirectory
    |
    |---html, jsp, images etc
    |
    |---WEB-INF---
    |---classes--
    |---lib
    |
    |
    1) Make sure WEB-INF is in capital letters
    2) Place all ur beans in classes dir or sub-directory in
    classes
    3) In Tomcat place WebAppRootDirectory in webapps
    directory
    [email protected]

  • How to call webservices from ADF page

    Hi,
    I am using ADFBC.
    I want to call webservices from ADF page.please give examples of sample program on how to call a web service from the ADF pages.please give examples.
    please help me.
    Thanks,

    http://marianne-horsch-adf.blogspot.com/2011/03/how-to-create-web-service-based-adf.html
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/70-dependent-listboxes-using-ws-286107.pdf
    http://www.oracleimg.com/technetwork/developer-tools/jdev/adfcomplexwstypes-101013.html
    http://technology.amis.nl/blog/9726/quickly-creating-reploying-and-testing-a-webservice-interface-for-adf-business-components
    http://oracamp.com/passing-parameters-between-web-services-and-jsf-pages

  • How to call Servlet from jsp page and how to run this app using tomcat..?

    Hi ,
    I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
    Please tell me how to do this into jsp page..?
    Also i wanted to execute this application using tomcat.
    Please tell me how to do this...? what setting are required for this...? what will be url ..??
    Thanks.

    well....my problem is as follows:
    whenever i type...... http://localhost:8080/appName/
    i am getting 404 error.....it is not calling to login.jsp (default jsp)
    but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
    Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
    In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
    plz help me.

  • How to call oracle funtion/procedure from OA controller

    HI,
    i need to call oracle funtion to my controller. How can i invoke funtion from OAF. Thing is i need to set the value in messageStyleText ,which will be coming from funtion. How can do that???? I am strugglin a alot on this .
    Could you please help me anybody who have any idea.

    You can create a view object with a simple select statement fetching the value from the function. Attach with VO to the AM programatically. Bind this VO Name and Attribute to the messageStyleText.
    HTH

  • How to execute a method when page is loaded

    hi ,
    I have a custom method in backing bean of a .jspx page. I want to execute it by default when the .jspx page is loaded.can anyone say how to do it?

    Hi,
    depends on what this is doing: You can call it in a PhaseListener, or from the page using a EL reference (e.g. output textfield that shows empty) or by customizing the ADF pagelifecyce.
    You may want to have a look at
    http://thepeninsulasedge.com/frank_nimphius/2007/08/09/jsf-hook-into-the-javaserver-faces-page-load/
    Frank

  • How to layout beans for single page design

    Hey guys. I'm designing a site that uses the Icefaces framework. I've been reading a book called Real World Java EE patterns. I'm kind of confused how to layout the pages. Normally I would have just a POJO class implement serializable for a bean. This bean would then back each page. With a single page design I'm going to have a bunch of elements on the page. Datatables, trees, inputs, calendars etc. Is it normal or best practice to have separate beans for each datatable, calendar, etc or put that all in one bean? I'm not sure how to approach this. Right now each element is a bean and I'm using the @Inject annotation to have the data table talk to the tree and vise versa. This creates really bad code and if I put this as a member of the class I will get a circular reference because the data table bean has to inject the calendar and the calendar has to inject the data table.
    Thanks for any help.

    'best' practice is to not follow blindly what other people say, but to reason yourself what works best for you. It has been stated many times before and I will state it again: best practice does not exist. Only personal opinions about what is best exist. Personal opinions are not facts.
    So choose what works for you. Is the code easy to maintain? Is it readable? Can you perhaps re-use parts of it? Then I'd say you have a winner.
    I'll give you my personal favorite. When working with a page that has input elements, I tend to have two or three beans. Replace XXX with a logical and context sensitive name.
    XXXForm - this is a simple request scoped bean that has the action and event methods and will hold some data for reading purposes for the view, possibly taken from a database.
    XXXStorage - this is a session scoped bean that holds information from the form; if it is an editing function I initialize it with the current state first. Storing this stuff in a session bean makes it very easy to do Ajax stuff and create input cycles that span multiple requests. Also when data is split in multiple pages, the storage class is the one to remember which page is being displayed.
    Optionally, I also have an XXXSearch object, which is a session scoped bean that stores search/sort/filter parameters. I make this session scoped so the information is remembered for the duration of the user's visit, meaning he can navigate away from the page in question, come back and all his choices will still be in place.
    So no, I don't have beans specifically for each component, although I might make simple POJOs to hold information gathered from several sources (for example, information gathered from several database tables). These beans are generally used to fill the rows of a datatable and are just created from within the form class, for example in a @PostConstruct annotated method.

  • How to call and run HTML pages from an Applet?

    I want to run another HTML page when pressed a button in an Applet,how can i do it?

    Are you looking for this?
    applet.getAppletContext().showDocument("http://cullenwines.com.au", "_top");

  • How to get system date automatically in date field once page is loaded

    Hai all,
    I am a newbie to jsp programming. I had a jsp page where there is a date field with a calendar available. Initially when the page loads it should have the system date in the date field. If the user wants any other date there he can select it from the calendar. But how can i get the system date to be loaded initially into the date field? Should i use the javascript here?
    Thanks in advance....

    #SYSDATE

Maybe you are looking for

  • Communication between SAP and Webserver

    Hi, we customize the communication between our sap ecc system (module HR) and https-Server of ELENA (see sap note 1408879). Between both server should be installed a proxy server. Is it possible to communicate from sap system (transaction sm59) over

  • Error in precompiling JSPs using OJSPC

    Hi, I am precompiling JSPs in war file using ojspc as specified below.      ojspc -output myapp.war app.war However I am getting following error: Detected archive, now processing contents of app.war... Setting up temp area... Expanding archive in tem

  • Carriage Return

    Hi Friends, Few days back one of clients of my company had a problem with carriage Returns in the data.To make it simple we take column data from the tables and output it to a flat file like notepad onto the server.This process is repeated for a numb

  • Genius can't send info to Apple

    The very first time I ran Genius it worked perfectly but when I tried to sync my iphone it wouldn't sync so I turned genuius off. Now when I try to turn Genius back on again it gives me this error: *"Genius results can't be updated right now. An unkn

  • IPod sync error - 13014

    This problem started yesterday - out of absolutely nowhere! I plugged in my ipod to play on my Macbook Air and this error keeps popping up about every 15-30 seconds. Needless to say it's irritating and interrupts everything else I'm doing on my compu