Passing values to seperate methods

How do you pass integer values to different methods called in a program. Example: methods sum() and difference(). User has to enter two numbers. The program must print the numbers, calculate the sum and the difference, and then print the answers. I created a method that figured both the sum and difference with the use of the if / else procedure. I tried to create two seperate methods but could not get the second method to read and calculate the two numbers input. Below is what I ended up with.
import java.util.*;
Author:     Galen Rogers
Date:          09 July 06
Subject:     COM 209 Wk 3 Homework problem # 2.
Program to create "Sum & Difference" method.
public class NumbersCalc
     public static void sum()
          Scanner keyboard = new Scanner(System.in);
          int n1, n2, sum, diff;
          n1 = keyboard.nextInt();
          n2 = keyboard.nextInt();
          sum = n1 + n2;
          System.out.println("The sum of your numbers is: " + sum);
          if (n1 > n2)
               diff = n1 - n2;
          else
               diff = n2 - n1;
          System.out.println("The difference of your numbers is: " + diff);     
Main Program:
import java.util.*;
Author:     Galen Rogers
Date:          09 July 06
Subject:     COM 209 Wk 3 Homework problem # 2.
Program to add and subtract numbers entered by user and display answers.
public class Numbers
     public static void main(String[] args)
          Scanner keyboard = new Scanner(System.in);
          System.out.println("Please think of two whole numbers that you want calculated.");
          System.out.println("Please enter two whole numbers and press Enter after each number.");
          NumbersCalc.sum();
If any body can help I will really appreciate it.

Don't do input (or even output) inside the sum() or difference() methods. Instead get the input first, store the input into two variables and then call the two methods using the stored input. Make sure those methods return the calculated values and then print those values.
Your sum() method should look something like this:public int sum(int a, int b) {
  // just calculate result and return it
}Same for the difference() method.

Similar Messages

  • How to pass value from one method to another method

    Hi all,
    I have created a funtion module and i am calling this function module inside a method and it is exporting some value in a table, now i have to pass table value to another method where i have do some thing based upon this values.
    I think there a marco available to move the values from one method to another method.
    Please help me in this issue.
    Regards
    Balaji E.

    Hi,
    Let me make certain assumptions!
    Method 1 - You export the table values
    Method 2 - The method where you need the table values
    Once you create a method from a function module which has tables as one of the export parameters then the code automatically puts in the macro code which looks like : SWC_SET_TABLE CONTAINER 'Table' TABLE.
    The 'Table' in the above code is the container element which is created by the workflow once you use this method and the TABLE (The table that gets filled in the function module) is the variable to code automatically created.
    Now you can use the other function module in the workflow as a background step and pass the values from the 'Table' container to this method using the binding. When you use this then the method automatically has the macro SWC_GET_TABLE CONTAINER 'Table' ITABLE. Here the 'Table' is the same container table you used in the binding and the ITABLE would be the variable you can use in the other function module.
    Hope this helps,
    Sudhi

  • Passing values to a method

    Hello,
    My program did work for one layer of directories. Now I want it to do multiple layers therefore the code needs changing.
    public void process(String[] argStrings, File allFiles)
    // lots more code that does not need to be shown
        String dirName = new String(name);
        dirMapper(dirName);
        MultiFilter multiFilter = new MultiFilter(fileExtensionOne);
        File[] htmlFiles = allFiles.dirMapper(multiFilter);
        multiFilter.setExtension(fileExtensionTwo);
        File[] phpFiles = allFiles.dirMapper(multiFilter);
        File[] filesToLog = mergeFiles(htmlFiles, phpFiles);
        log(filesToLog, archiveLimit, copyLimit);
      public File dirMapper(String dirName)//method decleration
        int i;
        File[]files = dirName.listFiles();
        for(i=0;i<files.length;i++)
          files.getName();
         if(files[i].isDirectory())
         dirMapper(dirName+"\\" + files[i].getName());
         File allFiles = new File(dirMapper);
         return allFiles;
    At the moment I am getting compile errors as shown below:
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:196: cannot find symbol
    symbol : method dirMapper(Crawler.MultiFilter)
    location: class java.io.File
    File[] htmlFiles = allFiles.dirMapper(multiFilter);
    ^
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:199: cannot find symbol
    symbol : method dirMapper(Crawler.MultiFilter)
    location: class java.io.File
    File[] phpFiles = allFiles.dirMapper(multiFilter);
    ^
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:209: cannot find symbol
    symbol : method listFiles()
    location: class java.lang.String
    File[]files = dirName.listFiles();
    ^
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:218: cannot find symbol
    symbol : variable dirMapper
    location: class Crawler
         File allFiles = new File(dirMapper);
    ^
    4 errors
    Thanks anyone
    John

    Well I had a break from Java for about two weeks therefore I a a bit rusty on it.
    Anyway I have got it down to 2 errors now, maybe someone could suggest some of the code as I have not got much time to complete it in.
    Heres what I got:
    public void process(String[] argStrings, File allFiles)
       File dirName = new File(name);
        dirMapper(dirName);
        MultiFilter multiFilter = new MultiFilter(fileExtensionOne);
        File[] htmlFiles = allFiles(multiFilter);
        multiFilter.setExtension(fileExtensionTwo);
        File[] phpFiles = allFiles(multiFilter);
        File[] filesToLog = mergeFiles(htmlFiles, phpFiles);
        log(filesToLog, archiveLimit, copyLimit);
      public File dirMapper(File dirName)//method decleration
        int i;
        File[] files = dirName.listFiles();
        for(i = 0; i < files.length; i++)
          files.getName();
         if(files[i].isDirectory())
         File allFiles = (dirName + "\\" + files[i].getName());
         return allFiles;
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:196: cannot find symbol
    symbol : method allFiles(Crawler.MultiFilter)
    location: class Crawler
    File[] htmlFiles = allFiles(multiFilter);
    ^
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:199: cannot find symbol
    symbol : method allFiles(Crawler.MultiFilter)
    location: class Crawler
    File[] phpFiles = allFiles(multiFilter);
    ^
    E:\Programming assignment 2\Application\Crawler\Source\Crawler.java:217: incompatible types
    found : java.lang.String
    required: java.io.File
         File allFiles = (dirName + "\\" + files[i].getName());
    ^
    3 errors
    Tool completed with exit code 1
    What do you mean by parens - parentheses? I have heard of this but do not remember what it is.
    Cheers
    John

  • In BADi , How to pass the values between two Method

    Hi Experts,
    We have two methods in BADis. How to pass the value  between two Methods. Can you guys explain me out with one example...
    Thanks & Regards,
    Sivakumar S

    Hi Sivakumar!
    Create a function group.
    Define global data (there is a similiar menu point to jump to the top include).
    Create one or two function modules, with which you can read and write the global data.
    In your BADI methods you can access the global data with help of your function modules. It will stay in memory through the whole transaction.
    Regards,
    Christian

  • Help with passing values to methods

      GregorianCalendar baseTime = new GregorianCalendar();
      long baseSystemTime = System.currentTimeMillis();
      // After some iterations I want to update the
      // calendar to reflect the current time.
      // I do not want to go through instantiating a new calendar
      baseTime = updateTimestamp(baseTime,baseSystemTime);
      private static GregorianCalendar updateTimestamp(GregorianCalendar GC, long lastTime){
        // This gets the difference between the last time check and now.
        // It then adds that difference to the calendar and returns the updated
        // calendar.
        int msDifference =
          new Long(System.currentTimeMillis() - lastTime).intValue();
        GC.add(GregorianCalendar.MILLISECOND,msDifference);
        lastTime = new Long(System.currentTimeMillis()).longValue();
        return GC;
      }The problem is that the lastTime variable that it passed gets updated to the current MS value. But, the original baseSystemTime never changes.
    I thought that if you pass something to a method and it gets altered in the method the original object is updated. Am I wrong?

    So objects are passed by reference but primitives are
    passed by value?Simply speaking: Yes.
    Strictly speaking: No. Every parameter is passed by value because Object obj IS a reference. So when you do call(myObject), you are passing the value of the reference of the object (the adress of the object).

  • Default method - how to pass value to method container?

    Hello,
    I am dealing with a hyperlink in 'Objects and Attachements' section of the workitem.When i click on the link, the default method of the business object gets called automatically.
    My question is: How to pass values to the default method (i.e. method container) as i don't invoke the method in my workflow explicitly?  The method gets called when we click on the hyperlink.
    Regards,
    Monica.

    Hello Monica,
    a default method doesn't require parameters (and cannot make use of them), as they are designed to be called from various situation, such as the view from a workflow container, the display button within a workitem or the attachment list. So this is part of the system design.
    To make an object dependent of workitem values I usually follow two different design patterns:
    <b>1) Using a flowitem/workitem instance with a special default method</b>
    - Create a subobject from type WORKITEM (if I'm going to use values from the current workflow instance) or subobject from type WORKINGWI (if I'm going to use values from the current dialog workitem).
    - Do not make a general substitution for this new object type
    - If using a ZWORKITEM, create an instance of this object type before the dialog step and then pass this object to the dialog workitem
    - If using ZWORKINGWI, assign the object instance during the data flow to the step.
    - In the properties of the object choose (any one) default method
    - Within the coding you have the reference to the workitem/flowitem as object-key-... and you can further use functions/methods to read the workitem/flowitem container and do whatever has to be done
    <b>2) Retrieving values from the current workitem on-the-fly</b>
    Within the coding of the default method call the function module SWO_QUERY_REQUESTER that returns the instance/id of the current workitem-in-work (with is also set when using the hyperlink from a workitem). If the list is empty, there's no active workitem, otherwise use functions/methods to read the workitem container.
    --> edit: Solution is not release safe, is it aint working with SAP R/3 Enterprise and higher
    Best regards,
       Florin
    Message was edited by:
            Florin Wach

  • Passing value from method to Workflow

    Hi All,
    I am new to workflow. I am trying simple examples to understand the concepts of work flow.
    I have copied a std business object and I have a method in that. Now, I am trying to pass some value to this method from the work flow and get back some value after manipulation with in this method.
    In the program for the method,  I need to get 2 parameters as input and one parameter as outut. With in this method I am trying to write the code for adding this 2 nos. I have seen some Help docs and came to know I should use SWC_GET_ELEMENT_CONTAINER and SWC_SET_ELEMENT_CONTAINER for this. But, I am ot sure of the syntax.
    Can you help me with a sample program for this...
    Any help is highly appreciated.
    Thanks,
    Jai Shankar

    hi Jai Shankar,
    I give you the sample code of the method where i am finding number of agents
    BEGIN_METHOD ZLCPRNUMBEROFUSERS CHANGING CONTAINER.
    DATA:
          TEMAILID LIKE SOLI OCCURS 0,
          TAPPROVERS LIKE ZSAFAPPROVERS OCCURS 0,
          WAPPROVERS LIKE TABLE OF ZSAFAPPROVERS WITH HEADER LINE.
          DATA NUMBER LIKE VBAK-VBTYP.
          DATA emailid TYPE STRING.
          data userid type string.
    this is the coding where the value that you give the method container
      SWC_GET_TABLE CONTAINER 'TEmailId' TEMAILID.
      SWC_GET_TABLE CONTAINER 'TApprovers' TAPPROVERS.
      SWC_GET_ELEMENT CONTAINER 'NUMBER' NUMBER.
    here you can use your own coding like (select query or any other)
      CALL FUNCTION 'Z_LC_PR_NUMBER_OF_USERS'
        TABLES
          T_EMAIL_ID = TEMAILID
          T_APPROVERS = TAPPROVERS
        EXCEPTIONS
          OTHERS = 01.
      CASE SY-SUBRC.
        WHEN 0.            " OK
        WHEN OTHERS.       " to be implemented
      ENDCASE.
      SWC_SET_TABLE CONTAINER 'TEmailId' TEMAILID.
      SWC_SET_TABLE CONTAINER 'TApprovers' TAPPROVERS.
    READ TABLE TAPPROVERS INDEX NUMBER INTO WAPPROVERS.
    CALL FUNCTION 'Z_LC_GET_EMPLOYEE_INFO'
    EXPORTING
        USER_ID                   = WAPPROVERS-APPROVER_USRID
    IMPORTING
         EMP_EMAIL                 = emailid.
    here i am doing some manupulation in the function module and i am getting that value to the method container as below.
      SWC_SET_ELEMENT CONTAINER 'EMAILID' emailid.
      SWC_SET_ELEMENT CONTAINER 'USERID' WAPPROVERS-APPROVER_USRID.
    SWC_SET_TABLE CONTAINER 'EMAILID' emailid.
    SWC_SET_TABLE CONTAINER 'TApprovers' TAPPROVERS.
    END_METHOD.
    I think it is helpful for you,
    Regards,
    Balaji E.

  • Is it possible to pass a null value to a method?

    is it possible to pass a null value to a method?
    like this
    public String getParameterXX(String testvalue)
    String strX = "whatever";
    if(testvalue!=null)
    strX = strX + " man " ;
    Is this possible ?
    is this legal
    String i = getParameterXX(null);

    I also ran a similar code using null in a method, it just considers null as another string and concatenates it so
    public String getParameterXX(String testvalue)
    String strX = testvalue+"whatever";
    return strX;
    public static void main(String [] args)
    Test tt = new Test();
    String i = tt.getParameterXX(null);
    System.out.println(i);
    Gives me "nullwhatever"

  • How to pass value from EXIT to method

    Hi friends
    1)  My requirement is that when the person change the amount field in TRIP t-code i need to send a mail to the manager. So i found a exit FIT0002 here when ever the traveler change the amount i am setting the flag as x when he change and y when no amount is changed in exit. I did export to memory id and in my method i did import from memory id. But this is not performing gud. If at a time many users apply the trip and changes the advance the flag is not getting set. I checked in the log. No flag is set its empty no x nor y. After clearing the buffer SWU_OBUF. Again all the users applied the trip then the flag is set and every manager got the mail. But why this is happening?. Is there any other way to achieve it. I want to get the flag value to my method. Is there any other work around.
    2)  I tried with SAP_WAPI_WRITE_CONTAINER directly getting the value and writing to the workflow container its not correct way since i need to write commit work. But the exit itself does commit.
    3) I tried with SET/GET parameter but i don't no how to divert my flow from my method to exit when i use SET/GET parameters.
    Can any one throw some light on this issue.
    Regards
    vijay

    If you are able to get the workitem ID then try to use the below code snippet and check because even Iam setting some value back to the workitem container
    DATA :
          w_wiid      TYPE             sww_wiid     VALUE   'XXXX',
          w_ref       TYPE REF TO      if_swf_run_wim_internal,
          w_ref_cnt   TYPE REF TO      if_wapi_workitem_context,
          w_wi_ref    TYPE REF TO      if_swf_ifs_parameter_container,
          ls_agent    TYPE             swr_wihdr.
    TRY.
        CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
          EXPORTING
            im_wiid     = w_wiid
          RECEIVING
            re_instance = w_ref.
      CATCH cx_swf_run_wim_enq_failed .
      CATCH cx_swf_run_wim_read_failed .
      CATCH cx_swf_run_wim .
    ENDTRY.
    CALL METHOD w_ref->get_workitem_context
      RECEIVING
        re_ctx = w_ref_cnt.
    CALL METHOD w_ref_cnt->get_wi_container
      RECEIVING
        re_container = w_wi_ref.
    TRY.
        CALL METHOD w_wi_ref->set             " Setting the Value Back to WORKITEM CONTAINER
          EXPORTING
            name       = lc_result
            value      = lv_value       
          IMPORTING
            returncode = lv_return.
      CATCH cx_swf_cnt_cont_access_denied .
      CATCH cx_swf_cnt_elem_access_denied .
      CATCH cx_swf_cnt_elem_not_found .
      CATCH cx_swf_cnt_elem_type_conflict .
      CATCH cx_swf_cnt_unit_type_conflict .
      CATCH cx_swf_cnt_elem_def_invalid .
      CATCH cx_swf_cnt_container .
    ENDTRY.

  • Text Fields not retaining passed values.

    I've tried several options to fix this issue, to be more descriptive, I pass a value to the textfield and the page refreshes, after the page refreshes the value is gone. I stepped through the code and the value is there for the time being until the page refresh. I.e:
    public String test () {
    txtTest.setText("asdas");
    String temp = txtTest.getText();
    return null;
    }When i get the value of temp when stepping through the code... temp = asdas meaning it was correct. However when the page refreshes from the return null statment it clears the values, I've used this type of code several times before and it has never given me this issue.

    This has me really stumped, the only thing I really changed from the previous forms where I've done this before is the fact that I put some of the database calls into seperate methods instead of embedding them directly within the action call events.

  • Passing Parameters via Post Method from Webdynpro Java to a web application

    Hello Experts,
    I want to pass few parameters from a web dynpro application to an external web application.
    In order to achieve this, I am referring to the below thread:
    HTTP Post
    As mentioned in the thread, I am trying to create an additional Suspend Plug parameter (besides 'Url' of type String) with name 'postParams' and of type Map.
    But when I build my DC, I am getting the same error which most of the people in the thread have mentioned:
    Controller XXXCompInterfaceView [Suspend]: Outbound plug (of type 'Suspend') 'Suspend' may have at most two parameters: 'Url' of type 'string' and 'postParams' of type 'Map'.
    I am using SAP NetWeaver Developer Studio Version: 7.01.00
    Kindly suggest if this is the NWDS version issue or is it something else that I am missing out.
    Also, if it is the NWDS version issue please let me know the NWDS version that I can use to avoid this error.
    Any other suggestion/alternative approach to pass the parameters via POST method from webdynpro java to an external web application apart from the one which is mentioned in the above thread is most welcome.
    Thanks & Regards,
    Anurag

    Hi,
    This is purely a java approach, even you can try this for your requirement.
    There are two types of http calls synchronous call or Asynchronous call. So you have to choose the way to pass parameters in post method based on the http call.
    if it is synchronous means, collect all the values from users/parameters using UI element eg: form and pass all the values via form to the next page is nothing but your web application url.
    If it is Asynchronous  means, write a http client in java and integrate the same with your custom code and you can find an option for sending parameters in post method.
    here you go and find the way to implement Asynchronous  scenario,
    http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload
    http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html
    http://digiassn.blogspot.com/2008/10/java-simple-httpurlconnection-example.html
    Thanks & Regards
    Rajesh A

  • Re: Help needed in passing values from workflow to Approve Forms

    Dear Experts,
    how do I pass values from a workflow to a step (Form) - approve form?
    I am using a customized table structure as my data source (FORMCONTAINERELEMENT) but am stuck on how to access the data when i get to to the screen painter's flow logic... What am i missing? Can you give me a step by step example. the ones i see on the net are input fields that update the screen... nothing that shows value being passed from the outside.
    I need to pass an exisitng value in the workflow into the form for approval of the the assigned agent.
    Please help!!
    Thank you.

    Hello !
             Create a method just before the form step.This method should populate the values for the fields maintained in the form.
             Pass the values populated from this method to your customized table structure (data source).In other words, you have to pass all the values to the workflow container.
            To the step, pass this workflow container by binding.In the control tab of form step, you have to do the binding.
    Regards,
    S.Suresh

  • How to pass values to Oracle store procedure in Crystal Report

    Hi all,
    I am newbie on passing values to stored procedure parameters. I created a Crystal Report using the Crystal Report wiward with PULL method and data come from Oracle stored procedure. In an ASP.NET page, I have stored two values in Session and need to pass them as input parameters to Oracle stored procedure to print the report. In Crystal reports 2010 once you connect to a stored-procedure as data source, it automatically creates the parameter fields with Crytal Report Viewer. Please show me how I pass values to store procedure at runtime automatically.
            'Set the parametter value
            myReport.SetParameterValue("@P_COURSE", "CoursetNo")
            myReport.SetParameterValue("@P_CLASS", "ClassNo")
        End Sub
    I tried to apply above codes from Brian Bischof book but display the error from the following lines:
            myReport.SetParameterValue("@P_COURSE", "CoursetNo")
            myReport.SetParameterValue("@P_CLASS", "ClassNo")
    I also enclosed my code. Any experts, please let me know anything wrongs on my code . I tried several methods that searching via google, but did not solve my issues. Thanks.
    Edited by: avt2K7 on Mar 15, 2011 7:02 AM

    Hi,
    Thank you for your response. Here are the detailed code and error as following:
    Please show what I am missing in my below VB.NET codes:
    ===========================================================================================
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            LogonToTables("username", "password", "servername", "")
        End Sub
        Private Sub LogonToTables(ByVal myUserId As String, ByVal myPassword As String, ByVal myServerName As String, ByVal myDataBaseName As String)
            Dim Course, Class As String
            Course = Session.Item("CourseNumber"))
            Class = Session.Item("ClassNumber"))
            Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            myReport.Load(Server.MapPath("CrystalReport1.rpt"))
            Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
            'Set the database properties and security credentials
            Dim myConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
            myConnectionInfo.ServerName = "servername"
            myConnectionInfo.DatabaseName = ""
            myConnectionInfo.UserID = "username"
            myConnectionInfo.Password = "password"
            'Apply the ConnectionInfo to the report tables
            Dim myTables = myReport.Database.Tables
            For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
                myTableLogonInfo = myTable.LogOnInfo
                myTableLogonInfo.ConnectionInfo = myConnectionInfo
                myTable.ApplyLogOnInfo(myTableLogonInfo)
            Next
            'Set the parametter value to Crystal Report parameter named P_COURSE and P_CLASS
            myReport.SetParameterValue("@P_COURSE", "Course")
            myReport.SetParameterValue("@P_CLASS", "Class")
        End Sub
    =================================================================================
    I put a break point to debug but display the error at the following lines:
            myReport.SetParameterValue("@P_COURSE", "Course")
            myReport.SetParameterValue("@P_CLASS", "Class")
    Eventhough, if I set a specific value to Course=1000 and Class = math and still receive the error:
    Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
    I tried several sources from Google search but it is not working. I really appreciate any detailed code either in C# or VB.NET to solve my issues. Thanks in advance.

  • In portlets, how to use a html form passing  values to the another page?

    it is well known that in web developing , we have two methods to pass values to another page.<!--
    1. passing values
    2.<form action="nextPage" method ="post"></form>-->
    but how to use two methods in oracle portal portlets?
    I have got a simple example which submit two values to the page for itself, means a page has a form with submit botton, user input the form with values and then submit them by submit botton, then the page recevice those values and show it .
    this example is powered by oracle ,
    please have a look at these code:
    <br><br>
    <%@ page contentType="text/html;charset=UTF-8" %>
    <%@page import="java.util.*, oracle.portal.provider.v2.*" %>
    <%@page import="oracle.portal.provider.v2.http.HttpCommonConstants" %>
    <%@page import="oracle.portal.provider.v2.render.PortletRendererUtil" %>
    <%@page import="oracle.portal.provider.v2.render.PortletRenderRequest" %>
    <%@page import="oracle.portal.provider.v2.render.http.HttpPortletRendererUtil" %>
    <%@page import="oracle.portal.provider.v2.url.UrlUtils" %>
    <%
    // The form submit URL refers to the current Portal page. All portlets
    // on this page share this URL. This means that the per portlet parameters
    // are in the same request. Portlets must ensure that its paramerters don't
    // collide either with other portlets or other instances of itself. This
    // is generally accomplished by using "fully-qualified" parameter names. A
    // fully-qualified parameter name prepends the (unique) portlet reference to
    // the parameter. The JPDK provides a utility to accomplish this.
    String portletParamName = "mName";
    String portletParamAge = "mAge";
    String portletParamSubmit = "mSubmit";
    String fName = HttpPortletRendererUtil.portletParameter(request, portletParamName);
    String fAge = HttpPortletRendererUtil.portletParameter(request, portletParamAge);
    String fSubmit = HttpPortletRendererUtil.portletParameter(request, portletParamSubmit);
    // These are the session attribute names used to store the current values.
    // Because all instances of this portlet share the same user session we must
    // also fully-qualify these names to avoid collisions.
    String sName = HttpPortletRendererUtil.portletParameter(request, "sName");
    String sAge = HttpPortletRendererUtil.portletParameter(request, "sAge");
    PortletRenderRequest pRequest = (PortletRenderRequest)
    request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
    String formName = UrlUtils.htmlFormName(pRequest,null);
    ProviderUser user = pRequest.getUser();
    ProviderSession providerSession = user.getSession();
    if (providerSession == null)
    %>
    Your provider session has been terminated or has timed out
    and you need to logout and then login to re-establish the session.
    <%
    else
    // Record, in session storage, the last values submitted.
    if (pRequest.getQualifiedParameter(portletParamSubmit) != null)
    providerSession.setAttribute(sName, pRequest.getQualifiedParameter(portletParamName));
    providerSession.setAttribute(sAge, pRequest.getQualifiedParameter(portletParamAge));
    %>
    <!-- Output the HTML content -->
    <center>
    <table width="70%">
    <tr>
    <td>
    <b>This portlet shows how to post and process information from HTML forms.</b>
    </td>
    </tr>
    </table>
    <form name="<%= formName %>" method="POST"
    action="<%= UrlUtils.htmlFormActionLink(pRequest,UrlUtils.PAGE_LINK) %>">
    <%= UrlUtils.htmlFormHiddenFields(pRequest,UrlUtils.PAGE_LINK, formName) %>
    <table>
    <tr>
    <td>
    <b>Name :</b>
    </td>
    <td>
    <input type="text" size="20" name="<%= fName %>" value="">
    </td>
    </tr>
    <tr>
    <td>
    <b>Age : </b>
    </td>
    <td>
    <input type="text" size="3" name="<%= fAge %>" value="">
    </td>
    </tr>
    </table>
    <br>
    <INPUT TYPE=submit name="<%= fSubmit %>" Value="Submit">
    </form>
    <%
    if ((providerSession.getAttribute(sName) == null)&& (providerSession.getAttribute(sAge) == null)) {
    %>
    <b>No values have been submitted yet.</b>
    <%
    } else {
    %>
    <b> Last submitted values:</b><br>
    <table>
    <tr>
    <td>
    <b>Name: </b>
    </td>
    <td>
    <b><%= providerSession.getAttribute(sName) %></b>
    </td>
    </tr>
    <tr>
    <td>
    <b>Age: </b>
    </td>
    <td>
    <b><%= providerSession.getAttribute(sAge) %></b>
    </td>
    </tr>
    </table>
    <%
    %>
    </center>
    <%
    %>
    <br><br>
    <br><br>
    <br><br>
    but I want to write the form in a page , and then show it on another page , how to write it ?
    I have read the pdk:
    oracle.portal.provider.v2.url Classes
    UrlUtils
    then I use these method , as this :
    //frist page:
    <br><br><br><br>
    <%@page contentType="text/html; charset=Big5"
    import="oracle.portal.provider.v2.render.PortletRenderRequest"
    import="oracle.portal.provider.v2.http.HttpCommonConstants"
    %>
    <%@ page import="oracle.portal.provider.v2.*"%>
    <%@ page import="oracle.portal.provider.v2.render.PortletRendererUtil"%>
    <%@ page import="oracle.portal.provider.v2.render.http.HttpPortletRendererUtil"%>
    <%@ page import="oracle.portal.provider.v2.url.UrlUtils"%>
    <%
    PortletRenderRequest pReq = (PortletRenderRequest)
    request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
    %>
    <P>Hello <%= pReq.getUser().getName() %>.</P>
    <P>This is the <b><i>Show</i></b> render mode!</P>
    this is a program to test the passing value
    <%
    String portletParamName = "mName";
    String portletParamAge = "mAge";
    String portletParamSubmit = "mSubmit";
    String fName = HttpPortletRendererUtil.portletParameter(request, portletParamName);
    String fAge = HttpPortletRendererUtil.portletParameter(request, portletParamAge);
    String fSubmit = HttpPortletRendererUtil.portletParameter(request, portletParamSubmit);
    PortletRenderRequest pr=(PortletRenderRequest)request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
    String formName=UrlUtils.htmlFormName(pr, null);
    %>
    <form name="<%=formName%>" method="post" action="<%=UrlUtils.htmlFormActionLink("/htdocs/passingvalues4/getValues.jsp")%>">
    <%= UrlUtils.htmlFormHiddenFields("/htdocs/passingvalues4/getValues.jsp") %>
    name:<input type="text" size="20" name="<%= fName %>" value="">
    p w :<input type="text" size="3" name="<%= fAge %>" value="">
    <INPUT TYPE=submit name="<%= fSubmit %>" Value="Submit">
    </form>
    //getValues.jsp<br><br>
    <br><br>
    <%@page contentType="text/html; charset=Big5"
    import="oracle.portal.provider.v2.render.PortletRenderRequest"
    import="oracle.portal.provider.v2.http.HttpCommonConstants"
    %>
    <%@ page import="oracle.portal.provider.v2.*"%>
    <%@ page import="oracle.portal.provider.v2.render.PortletRendererUtil"%>
    <%@ page import="oracle.portal.provider.v2.render.http.HttpPortletRendererUtil"%>
    <%@ page import="oracle.portal.provider.v2.url.UrlUtils"%>
    <% String portletParamName = "mName";
    String portletParamAge = "mAge";
    String portletParamSubmit = "mSubmit";
    String fName = HttpPortletRendererUtil.portletParameter(request, portletParamName);
    String fAge = HttpPortletRendererUtil.portletParameter(request, portletParamAge);
    String fSubmit = HttpPortletRendererUtil.portletParameter(request, portletParamSubmit);%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=Big5">
    <title>untitled</title>
    </head>
    <body>
    Name:<%=fName%>
    Age :<%=fAge%>
    </body>
    </html>
    <br>then I deployed them on the portal , run it , the result is :after I submit it , the browser give me : http 404 page not found!
    [b]here is the provider.xml<br>[b[i]]<?xml version = '1.0' encoding = 'UTF-8'?>
    <?providerDefinition version="3.1"?>
    <provider class="oracle.portal.provider.v2.DefaultProviderDefinition">
    <session>true</session>
    <passAllUrlParams>true</passAllUrlParams>
    <portlet class="oracle.portal.provider.v2.DefaultPortletDefinition">
    <id>1</id>
    <name>PassingValues4</name>
    <title>PassingValues4</title>
    <description>PassingValues4</description>
    <timeout>60</timeout>
    <showEditToPublic>false</showEditToPublic>
    <hasAbout>false</hasAbout>
    <showEdit>false</showEdit>
    <hasHelp>false</hasHelp>
    <showEditDefault>false</showEditDefault>
    <showDetails>false</showDetails>
    <renderer class="oracle.portal.provider.v2.render.RenderManager">
    <renderContainer>true</renderContainer>
    <renderCustomize>true</renderCustomize>
    <autoRedirect>true</autoRedirect>
    <contentType>text/html</contentType>
    <showPage>/htdocs/passingvalues4/PassingValues4InputPage.jsp</showPage>
    <showPage>/htdocs/passingvalues4/getValues.jsp</showPage>
    </renderer>
    </portlet>
    </provider>
    <br><br><br>
    <br><br>
    would you kind enough to help me ? thanks!!!
    Message was edited by:
    moonsoft

    Hi Moonsoft,
    I have already answered this query in the other post at Re: how to link more than one links in portlet?(jsp develop)
    <form name = "showPageForm" method = "POST" action = "<%= UrlUtils.htmlFormActionLink(pReq,UrlUtils.PAGE_LINK) %>">
      <%= UrlUtils.htmlFormHiddenFields(pReq,UrlUtils.PAGE_LINK, "showPageForm") %>
      <input type="text" name="param1">
      <input type="text" name="param2">
      <input type="hidden" name="myPPN" value="/htdocs/page2.jsp">
    </form>then in your jsp code on page2.jsp, you will extract the parameters by specifying
    <%
      String p1 = request.getParameter("param1");
      String p2 = request.getParameter("param2");
    %>
    >>this is easy common jsp or asp development, but in oracle is too diffcult!!!!
    :-) .. there is a difference between web-applications and portlets, you just need to get used to it once. I hope this does clarify your doubts.
    thanks,
    Harsha

  • ABAP OO - Passing Internal Tables from Method to Method

    I'm new to writing methods.
    I have a need to build an internal table in METHOD1 and pass the internal table to METHOD2. I'm confused how to declare the table in 'Parameter' section of the METHOD2. I have specified the following:
    Parameter = WTAB1
    Type = Import
    Pass value = blank
    Optonal = Blank
    Typing Method = Type
    Associated type =  ZSCIW and this is declared in DDIC as a data type with fields ZZLINE(72) and ZZPOS(4)
    Default value = blank
    METHOD1 (simplified example)
    method METHOD1.
    Table of individual words from source code
      types: begin of wline,
               WORD(72),
               POSN(4),
             end of wline,
             wlines     type standard table of wline  with default key.
      data:  wx          type wlines,
               wa          like line of wx.
    Clear past results
      REFRESH: Wx.
    Look through source code...
      LOOP AT ref_include->lines into wa.
        APPEND wa.
      ENDLOOP.
    Call METHOD2 and pass internal table wa
    METHOD2 ( ).
    1. How to you define the parameters in METHOD2.
    2. What is the coding in METHOD1 to call METHOD2.
    Your help will really be appreciated.
    Thanks.
    Soyab

    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    Check these links.
    http://www.henrikfrank.dk/abapuk.html
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/abap%20objects/abap%20code%20sample%20to%20learn%20basic%20concept%20of%20object-oriented%20programming.doc
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
    Go through the below links,
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    OO ABAP links:
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    go through these links
    http://www.erpgenie.com/abap/index.htm
    http://sic.fh-lu.de/sic/bic.nsf/(vJobangebote)/EC8AD2AE0349CE92C12572200026FDB8/$File/Intern%20or%20Working%20Student%20as%20ABAB%20OO%20Developer.pdf?Open
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    ABAP_OBJECTS_ENJOY_0 Template for Solutions of ABAP Object Enjoy Course
    ABAP_OBJECTS_ENJOY_1 Model Solution 1: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_2 Model Solution 2: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_3 Model Solution 3: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_4 Model Solution 4: ABAP Objects Enjoy Course
    ABAP_OBJECTS_ENJOY_5 Model Solution 5: ABAP Objects Enjoy Course
    DEMO_ABAP_OBJECTS Complete Demonstration for ABAP Objects
    DEMO_ABAP_OBJECTS_CONTROLS GUI Controls on Screen
    DEMO_ABAP_OBJECTS_EVENTS Demonstration of Events in ABAP Objects
    DEMO_ABAP_OBJECTS_GENERAL ABAP Objects Demonstration
    DEMO_ABAP_OBJECTS_INTERFACES Demonstration of Interfaces in ABAP Objects
    DEMO_ABAP_OBJECTS_METHODS Demonstration of Methods in ABAP Objects
    DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen
    check the below links lot of info and examples r there
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    <b>good book on ABAP objects(OOPS)
    http://www.esnips.com/doc/bc475662-82d6-4412-9083-28a7e7f1ce09/Abap-Objects---An-Introduction-To-Programming-Sap-Applications</b>
    Rewards if useful..............
    Minal

Maybe you are looking for

  • Rounding up doubles

    Just wondering if anyone knows how to round up a double so that for instance 100.232323 can be up to 100. This is due to trying to convert a price in pence to a meaningful price. Also is there anyway to represent a figure in pounds and pence??? Regar

  • Can you DEBUG Fireworks files?

    I've created a flyout menu using Fireworks. When I "test" the flyout from Fireworks it appears to work fine - all levels of the menu working as I had designed. I integrated the nav menu into my Dreamweaver template for a client's website and FTP'd th

  • What happens if we kill SMON and PMON Back ground processes

    Dear All, It is an interview question to me. What happens to the database if we kill SMON and PMON background processes? I was unable to answer this, please let me know. Thanks Mahi

  • Change Change System Keychain Password

    I can unlock the system keychain but when I choose "Change Password for Keychain "System"..." it tells me "Sorry, you entered an invalid password" Why?

  • SMS Modem

    I would like to know how to configure SMS modem using ColdFusion. Can anyone know how? I need to understand to its work. Thanks