This discussion is archived
2 Replies Latest reply: Aug 2, 2013 12:43 AM by Christian Erlinger RSS

How to pass the parameter in java code

Sachinmrt Explorer
Currently Being Moderated

My version is ;-

 

Jdeveloper 10.1.2

Form builder 10.1.2

 

 

I create the SMS java class in Jdeveloper -

 

 

 

 

package mypackage;

import java.io.*;

import java.net.*;

import java.util.*;

import oracle.forms.handler.IHandler;

import oracle.forms.properties.ID;

import oracle.forms.ui.VBean;

 

 

public class CallSmscApi extends VBean

{

  protected static final ID SMS = ID.registerProperty("SMS");

 

 

   public CallSmscApi()

  {

    super();

  }

 

   public void init(IHandler handler)

{

    super.init(handler);

  }

 

  public Object getProperty(ID property)

  {

   String mAdd="" ;

   if (property == SMS)

    {

     System.out.println("Sms");

     try

     {

       mAdd = CallSmscApi();

       return  mAdd;

     }

     catch (Exception e) { e.printStackTrace();}

    return mAdd;

    }

    else

    {

      return super.getProperty(property);

    }

  }

 

  String CallSmscApi() throws IOException

  {

  String postData="";

  String retval = "";

 

 

  //give all Parameters In String

  String User ="user";

  String passwd = "passed";

  String mobilenumber = "mobileno";

  String message = "MSG";

  String sid = "sid";

  String mtype = "N";

  String DR = "Y";

 

 

 

  postData += "User=" + URLEncoder.encode(User,"UTF-8") + "&passwd=" + passwd + "&mobilenumber=" + mobilenumber + "&message=" + URLEncoder.encode(message,"UTF-8") + "&sid=" + sid + "&mtype=" + mtype + "&DR=" + DR;

  URL url = new URL("http://domain_name/WebserviceSMS.aspX");

  HttpURLConnection urlconnection = (HttpURLConnection) url.openConnection();

 

 

  // If You Are Behind The Proxy Server Set IP And PORT else Comment Below 4 Lines

  //Properties sysProps = System.getProperties();

  //sysProps.put("proxySet", "true");

  //sysProps.put("proxyHost", "Proxy Ip");

  //sysProps.put("proxyPort", "PORT");

 

 

  urlconnection.setRequestMethod("POST");

  urlconnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

  urlconnection.setDoOutput(true);

  OutputStreamWriter out = new OutputStreamWriter(urlconnection.getOutputStream());

  out.write(postData);

  out.close();

  BufferedReader in = new BufferedReader( new InputStreamReader(urlconnection.getInputStream()));

  String decodedString;

  while ((decodedString = in.readLine()) != null) {

  retval += decodedString;

  }

  in.close();

 

 

  System.out.println(retval);

    return retval;

  }

  }

 

After that i create the SMS.jar file and add into the formweb.cfg and default.env.

 

In Form builder -

 

:t1 := get_custom_property('bean_sms',1,'SMS');

 

Now I am able to send message. but now my problem is that i want to pass the mobile no and message from the form. I don't know how to pass the value. Please help me.

 

I am new in Jdeveloper.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points