Can a constructor return 'null'?

Consider the following code snippit.
MyClass myObj = new MyClass();Is it safe to say that myObj IS NOT NULL?
Of course the constructor may have created a useless object, but the object reference itself (myObj) shouldn't be null. Correct?
Also, I realize that the constructor might throw an exception or something like that, but that's a different issue.

Of course the constructor may have created auseless
object, but the object reference itself (myObj)
shouldn't be null. Correct?Right, new will return a non-null object.<pb>
new returns a non-null reference to an object.
</pb>
Also, I realize that the constructor might throwan
exception or something like that, but that's a
different issue.I'm not sure what happens when the constructor throws
an exception, I've never written a constructor to
throw one. Write a simple program to test it. Create
a class that does nothing but throw an exception in
the constructor, then in main, try to instantiate it.
In the catch block, access the reference to see if
it's null.
try {
    Foo foo = new foo(); // ctor throws exception
catch (Exception exc) {
    System.out.println(foo); // won't compile, foo is not in scope
Foo foo;
try {
    foo = new foo(); // ctor throws exception
catch (Exception exc) {
    System.out.println(foo); // won't compile, foo might not have been set.
}If the c'tor throws an exception, it doesn't return a value, the assignment statement completes abrubtly, and nothing is assigned to the variable.

Similar Messages

  • Could Constructor return null?

    Hi everybody,
    Could we let a constructor return null?
    I think this is an easy way to let caller know we
    can't create such an object.
    Thanks in advance.

    as cited before, you should prefer the exception handling .. but, just for your curiousity:
    public class NullDemo
         static public void main(String[] args)
              System.out.println(Example.createAnExample(new String[]{"all ", "right"}));
              System.out.println(Example.createAnExample(null));
    class Example
         final String text;
         private Example(String[] args)
              String temp = "";
              for(int i=0; i<args.length; i++)
                   temp += args;
              text = temp;
              //i = i/0;
         static public Example createAnExample(String[] args)
              try
                   Example e = new Example(args);
                   return e;
              catch(Exception error)
                   return null;
         public String toString()
              return text;

  • How can I return null in a double method

    I have a method, and like this:
    public double fu(){
    In some case I want to return null instead of a double value, how can I make it?
    Thanks.

    The approach with the wrapperclass works. But you should consider, why you want to return null. Is it just to express that an error occured? Then better throw an exception. Or do you want to return that there cannot be a usefull return. Then try to define a special value for that like -1. Normally there is a better approch then returning null.
    public class Doubles {
      public static void main(String[] args) {
        double d = 0;
        try {
          d = doIt();
        } catch (DoubleException d) {
          System.err.println("You made an error.");
      public static double doIt() throws DoubleException {
        if (allOk)
          return 10.123;
        else if (noUsefullAnswer)
          return -1;
        else if (bigError)
          throw new DoubleException("You made a mistake, dummy.");
    public class DoubleException extends Exception {
      public DoubleException(String s) {
        super(s);
    }

  • I am trying to raise event at UserControl, and catch it at Main program, But the event always return null

    I am trying to raise a event in one of classes of userControl, and Fire it in the Main class. I tried two different ways to fire this event, one of them works, But I still want to know why other way cannot work, and how to fix it.
    My userContol class:
    public partial class UserControl1 : UserControl
    public UserControl1()
    InitializeComponent();
    if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
    return;
    Class1 c = new Class1();
    Thread accept = new Thread(
    () =>
    c.connection();
    accept.Start();
    And the Class1:
    public class Class1
    public delegate void myhandler(object sender, EventArgs e);
    public event myhandler test;
    public Class1()
    public void connection()
    test(this, new EventArgs());
    In the Main, I just simply add into referent, and add
    xmlns:my="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
    then I try to subscribe this event in the main
    public partial class SurfaceWindow1 : SurfaceWindow
    /// <summary>
    /// Default constructor.
    /// </summary>
    public SurfaceWindow1()
    InitializeComponent();
    Class1 c = new Class1();
    c.test+=new Class1.myhandler(c_test);
    // Add handlers for window availability events
    AddWindowAvailabilityHandlers();
    public void c_test(object sender, EventArgs e)
    MessageBox.Show("fire");
    If I only raise this event not into thread, it works fine, but If I try to let it raise in this thread, this test event only return null, and shows:
    Object reference not set to an instance of an object.
    looks like I did not subscribe it ever. So How to fix it if I must use it in thread.

    Subscribing to events window to class is not a great approach.
    You have to then go un subscribe those handlers in order to allow your instance to be disposed.
    Forget that and you'll eventually notice you have memory leaks.
    The way I do this sort of thing is using mvvm light messenger.
    You can keep everything decoupled then.
    http://social.technet.microsoft.com/wiki/contents/articles/26070.aspx
    I just did a bit of code for someone else which shows how to do cross thread stuff with this approach.
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    Messenger.Default.Register<String>(this, (action) => ReceiveString(action));
    private void ReceiveString(string msg)
    MessageBox.Show(msg);
    Dispatcher.BeginInvoke((Action)delegate()
    tb.Text = msg;
    private void Button_Click(object sender, RoutedEventArgs e)
    Task.Factory.StartNew(() => {
    Messenger.Default.Send<String>("Hello World");
    Note that the message arrives on the thread it was sent from. That's not the ui thread because it was sent from that task.factory.startnew to deliberately put it on a different thread.
    In order to change UI controls, it uses dispatcher.begininvoke to run code on the UI thread.
    Although this is in one piece of code behind publisher and subscriber can be in two totally different classes which have no reference of knowledge of each other.
    Meaning you can send a message<t> from any class1 or whatever you like and your mainwindow can subscribe and act of receipt of a message<t>.
    It is the type which defines which message one is. You put data you want to send in t and use it in the subscriber.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Output parameters always return null when ExecuteNonQuery - No RefCursor

    I am trying to call a procedure through ODP that passes in one input parameter and returns two (non-RefCursor) VARCHAR2 output parameters. I am calling the procedure using ExecuteNonQuery(); however, my parameters always return null. When I run the procedure outside of ODP, such as with SQLPlus or SQL Navigator, the output parameters are populated correctly. For some reason, there appears to be a disconnect inside of ODP. Is there a way to resolve this?
    Anyone have this problem?
    Here is the basic code:
    ===========================================================
    //     External call of the class below
    DBNonCursorParameterTest Tester = new DBNonCursorParameterTest();
    ===========================================================
    //     The class and constructor that calls the procedure and prints the results.
    public class DBNonCursorParameterTest
         public DBNonCursorParameterTest()
              //     The test procedure I used is a procedure that takes a recordID (Int32) and then returns a
              //     general Name (Varchar2) and a Legal Name (Varchar2) from one table with those three fields.
              string strProcName                    = "MyTestProc;
              OracleConnection conn               = new OracleConnection(DBConnection.ConnectionString);
              OracleCommand cmd                    = new OracleCommand(strProcName,conn);
              cmd.CommandType                         = CommandType.StoredProcedure;
                   //     Create the input parameter and the output cursor parameter to retrieve data; assign a value to the input parameter;
              //     then create the parameter collection and add the parameters.
              OracleParameter pBPID               = new OracleParameter("p_bpid",               OracleDbType.Int32,          ParameterDirection.Input);
              OracleParameter pBPName               = new OracleParameter("p_Name",               OracleDbType.Varchar2,     ParameterDirection.Output);
              OracleParameter pBPLegalName     = new OracleParameter("p_LegalName",     OracleDbType.Varchar2,     ParameterDirection.Output);
              pBPID.Value = 1;
              //     Open connection and run stored procedure.
              try
                   conn.Open();
                   cmd.Parameters.Add(pBPID);
                   cmd.Parameters.Add(pBPName);
                   cmd.Parameters.Add(pBPLegalName);
                   cmd.ExecuteNonQuery();
                   Console.Write("\n" + cmd.CommandText + "\n\n");
                   //for (int i = 0; i < cmd.Parameters.Count; i++)
                   // Console.WriteLine("Parameter: " + cmd.Parameters.ParameterName + " Direction = "     + cmd.Parameters[i].Direction.ToString());
                   // Console.WriteLine("Parameter: " + cmd.Parameters[i].ParameterName + " Status = "          + cmd.Parameters[i].Status.ToString());
                   // Console.WriteLine("Parameter: " + cmd.Parameters[i].ParameterName + " Value = "          + cmd.Parameters[i].Value.ToString() + "\n");
                   foreach (OracleParameter orap in cmd.Parameters)
                        Console.WriteLine("Parameter: " + orap.ParameterName + " Direction = "     + orap.Direction.ToString() + " Value = " + orap.Value.ToString());
                        Console.WriteLine("Parameter: " + orap.ParameterName + " Status = "          + orap.Status.ToString());
                        Console.WriteLine("Parameter: " + orap.ParameterName + " Value = "          + orap.Value.ToString() + "\n");
                   //     End Test code.
              catch (Exception ex)
                   throw new Exception("ExecuteQuery() failed: " + ex.Message);
              finally
                   this.Close();
         public void Close()
              if (conn.State != ConnectionState.Closed)
                   conn.Close();
    =========================================================
    Other things to note:
    I have no problems with returning RefCursors; they work fine. I just don't want to use RefCursors when they are not efficient, and I want to have the ability to return output parameters when I only want to return single values and/or a value from an insert/update/delete.
    Thanks for any help you can provide.

    Hello,
    Here's a short test using multiple out parameters and a stored procedure. Does this work as expected in your environment?
    Database:
    /* simple procedure to return multiple out parameters */
    create or replace procedure out_test (p_text in varchar2,
                                          p_upper out varchar2,
                                          p_initcap out varchar2)
    as
    begin
      select upper(p_text) into p_upper from dual;
      select initcap(p_text) into p_initcap from dual;
    end;
    /C# source:
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    namespace Miscellaneous
      class Program
        static void Main(string[] args)
          // change connection string as appropriate
          const string constr = "User Id=orademo; " +
                                "Password=oracle; " +
                                "Data Source=orademo; " +
                                "Enlist=false; " +
                                "Pooling=false";
          // the stored procedure to execute
          const string sql = "out_test";
          // simple input parameter for the stored procedure
          string text = "hello!";
          // create and open connection
          OracleConnection con = new OracleConnection(constr);
          con.Open();
          // create and setup connection object
          OracleCommand cmd = con.CreateCommand();
          cmd.CommandText = sql;
          cmd.CommandType = CommandType.StoredProcedure;
          // the input paramater
          OracleParameter p_text = new OracleParameter("p_text",
                                                       OracleDbType.Varchar2,
                                                       text.Length,
                                                       text,
                                                       ParameterDirection.Input);
          // first output parameter
          OracleParameter p_upper = new OracleParameter("p_upper",
                                                        OracleDbType.Varchar2,
                                                        text.Length,
                                                        null,
                                                        ParameterDirection.Output);
          // second output parameter
          OracleParameter p_initcap = new OracleParameter("p_initcap",
                                                          OracleDbType.Varchar2,
                                                          text.Length,
                                                          null,
                                                          ParameterDirection.Output);
          // add parameters to collection
          cmd.Parameters.Add(p_text);
          cmd.Parameters.Add(p_upper);
          cmd.Parameters.Add(p_initcap);
          // execute the stored procedure
          cmd.ExecuteNonQuery();
          // write results to console
          Console.WriteLine("   p_text = {0}", text);
          Console.WriteLine("  p_upper = {0}", p_upper.Value.ToString());
          Console.WriteLine("p_initcap = {0}", p_initcap.Value.ToString());
          Console.WriteLine();
          // keep console from closing when run in debug mode from IDE
          Console.WriteLine("ENTER to continue...");
          Console.ReadLine();
    }Output:
       p_text = hello!
      p_upper = HELLO!
    p_initcap = Hello!
    ENTER to continue...- Mark

  • FindNode returning Null And XML Not Accepting Special Characters

    Hi All,
    i am trying the get the attribute value in the element "ns4:InfoCFDi" using FindNode method, but the method is returning NULL. I used the same code for other sample as well and was successfull. but for this specific XML file(which is below) I am getting a Null.
    i can get till S:Body, but when i try to use FindNode for ":Body/s4:ResponseGeneraCFDi" I get Null value.
    And I used "S:Body/*[local-name()=" | "ns4:ResponseGeneraCFDi" | "]";
    as mentioned in other post but still no success.
    ==>I Have one more question relating to special characters. I need to use characters such as - ó in my XML to read as well as write. When I try to read i am getting XML parse error and when writing, i cannot open the file properly.
    Your help is much appreciated.
    My code is here:
    Local XmlDoc &inXMLDoc, &reqxmldoc;
    Local XmlNode &RecordNode;
    &inXMLDoc = CreateXmlDoc();
    &ret = &inXMLDoc.ParseXmlFromURL("D:\Agnel\Mexico Debit Memo\REALRESPONSE.xml");
    If &ret Then
    &RecordNode = &inXMLDoc.DocumentElement.FindNode("" );
    If &RecordNode.IsNull Then
    Warning MsgGet(0, 0, "Agnel FindNode not found.");
    rem MessageBox(0, "", 0, 0, "FindNode not found");
    Else
    &qrValue = &RecordNode.GetAttributeValue("asignaFolio ");
    Warning MsgGet(0, 0, "asignaFolio." | &qrValue);
    End-If;
    Else
    Warning MsgGet(0, 0, "Error. ParseXmlString");
    End-If;
    XML File:
    - <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    - <S:Body>
    - <ns4:ResponseGeneraCFDi xmlns="http://www.xxl.com/ns/xsd/bf/rxx/52" xmlns:ns2="http://www.sat.gob.mx/cfd/3" xmlns:ns3="http://www.xx/ns/bf/conector/1&quo t; xmlns:ns4="http://www.xx/ns/xsd/bfxx/xx/32&qu ot; xmlns:ns5="http://www.xxcom/ns/xsd/bf/xxxxx&q uot; xmlns:ns6="http://wwwxx.com/ns/referenceID/v1">
    - <ns3:Result version="1">
    <ns3:Message message="Proceso realizado con exito." code="0" />
    </ns3:Result>
    - <ns4:InfoCFDi noCertificadoSAT="20001000000100003992" refId="STORFAC20121022085611" fechaTimbrado="2012-10-22T08:56:45" qr=" "
    uuid="a37a7d92-a17e-49f4-8e4d-51c983587acb" version="3.2" tipo="XML" archivo="xxx" sello="B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=" fecha="2012-10-22T08:56:44" folio="281" serie="IICC">
    <InfoEspecial valor="Este documento es una representacin impresa de un CFDI." atributo="leyendaImpresion" />
    <InfoEspecial valor="||1.0|a37a7d92-a17e-49f4-8e4d-51c983587acb|2012-10-22T08:56:45|B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=|20001000000100003992||" atributo="cadenaOriginal" />
    <InfoEspecial valor="Doscientos dieciocho mil cuatrocientos setenta y cinco pesos 00/100 M.N." atributo="totalConLetra" />
    </ns4:InfoCFDi>
    </ns4:ResponseGeneraCFDi>
    </S:Body>
    </S:Envelope>
    TIA

    First of all you have to supply a value you want to search for and this has to be the complete path to the value. You're saying you already tried that, but can you paste the code which you used for that? I don't see the path mentioned in the code you posted.
    *FindNode*
    Syntax
    FindNode(Path)
    Description
    Use the FindNode method to return a reference to an XmlNode.
    The path is specified as the list of tag names, to the node that you want to find, each separated by a slash (/).
    Parameters
    Path
    Specify the tag names up to and including the name of the node that you want returned, starting with a slash and each separated by a slash (/). This is known as the XPath query language.>
    Another option would be this snippet of code:
    &InfoCFDiArray = GetElementsByTagName("ns4:InfoCFDi");
    &InfoCFDiNode = &InfoCFDiArray [1];
    &attValue = &InfoCFDiNode.GetAttributeValue("noCertificadoSAT")
    Warning(&attValue);
    It creates an array of XML Nodes which match the name "ns4:InfoCFDi". Since there's only one in the XML it's safe to assume it will be the one and only node in the array. I've assigned that node to the variable &InfoCFDiNode and use that to retrieve the attribute "noCertificadoSAT" value. The warning message should display the value supplied there.
    Concering the special characters; you will have to change the encoding of the XML. Peoplecode sets this to UTF-8 by default, but doesn't include this in the header. There's a little hack for that somewhere on the web, I'll see if I can find it.

  • HelpSet.findHelpSet() returns null, and trapping ID errors

    I was having a problem initializing JavaHelp. HelpSet.findHelpSet() was returning null. I searched the forum, and found it was a common problem, but the answers were unhelpful. The answers pointed to a problem with CLASSPATH, but offered little in the way of advice for a newbie like myself on how to deal with it.
    A second issue concerns HelpBroker.enableHelpOnButton(). If you feed it a bogus ID, it throws an exception, and there's no way to trap it and fail gracefully. JHUG doesn't provide much in the way of alternatives.
    Now, having done a bit of research and testing, I'm willing to share a cookbook formula for what worked for me.
    I'm working in a project directory that contains MyApp.jar and the Help subdirectory, including Help/Help.hs. My first step is to copy jh.jar to the project directory.
    Next, in the manifest file used to generate MyApp.jar, I add the line:
        Class-Path: jh.jar Help/I'm working with Eclipse, so in Eclipse, I use Project - Properties - Java Build Path - Libraries to add JAR file jh.jar, and Class Folder Tony/Help
    I define the following convenience class:
    public class HelpAction extends AbstractAction
        private static HelpBroker helpBroker = null;
        private String label = null;
        public HelpAction( String name, String label )
            super( name );
            this.label = label;
        public void actionPerformed( ActionEvent event )
            displayHelp( label );
        public static boolean displayHelp( String label )
            if ( helpBroker == null )
                Utils.reportError( "Help package not initialized!" );
                return false;
            try
                helpBroker.setCurrentID( label );
                helpBroker.setDisplayed( true );
                return true;
            catch ( Exception e )
                Utils.reportError( e, "Help for " + label + " not found" );
                return false;
        public static boolean initialize( String hsName )
            URL hsURL = HelpSet.findHelpSet( null, hsName );
            if ( hsURL == null )
                Utils.reportError( "Can't find helpset " + hsName );
                return false;
            try
                HelpSet helpSet = new HelpSet( null, hsURL );
                helpBroker = helpSet.createHelpBroker();
            catch ( HelpSetException e )
                Utils.reportError( e, "Can't open helpset " + hsName );
                return false;
            return true;
    }If you use this class in your own code, you'll want to replace Utils.reportError() with something of your own devising.
    Finally, in my GUI class, I use the following:
        JPanel panel = ...
        JMenu menu = ...
        JToolbar toolbar = ...
        HelpAction.initialize( "Help.hs" )
        Action gsAction = new HelpAction( "Getting Started Guide", "gs.top" );
        menu.add( gsAction );
        JButton helpButton = new HelpAction( "Help", "man.top" );
        toolbar.add( helpButton );
        InputMap imap = panel.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
        imap.put( KeyStroke.getKeyStroke( "F1" ), "F1help" );
        ActionMap amap = panel.getActionMap();
        amap.put( "F1help", new HelpAction( null, "man.top" ) );

    Sorry, the sixth-from-last line of my example should read,
        JButton helpButton = new JButton( new HelpAction( "Help", "man.top" ) );

  • Why does getParameter("uri") returns null ???

    Hi !
    JAVA can be rather frustrating and I have run of of dukes. How about IOU ?
    Unfortunately none of the previous questions in the db shed light on my problem.
    I am trying to get at the "uri" and I have the following code fragment :
    package com.developer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.IOException;
    import java.io.PrintWriter;
    public class proptest extends HttpServlet
      public void doGet( HttpServletRequest req,  HttpServletResponse resp)
        throws ServletException, IOException
        PrintWriter out = resp.getWriter();
        out.println("Parameter Name: " + req.getParameter("uri"));
      public void init() throws ServletException
        // initialie the servlet here. Use ServletConfig object to get
        //    initialization parameters...
        ServletConfig config = getServletConfig();
        // ... more stuff ...
      }

    Hi!
    In case anyone stumbles upon this in the database, I worked aroung it by using req.getRequestURI().
    However I still do not know why getParameter() returns null. It would be useful e.g. if you want to display a list of all request params e.g.:
    // stub code follows...
    java.util.Enumeration enum = rea.getParameterNames();
    while (enum.hasMoreElements())
    String name = (String) enum.nextElement();
    System.out.println("Parameter "+name + " " + req.getParameter(name))
    ...For me, nope, all nulls. If it works for you , do tell me.
    Also if you look at the "bugs db" there seems to be a number of issues concerning getParameter().

  • Why ResultSet getDate() method returns null when querying .csv file?

    Here is the full code:
    import java.sql.*;
    import java.sql.Types;
    import java.sql.Date;
    import myjava.support.CachedRowSetMaker;
    import javax.sql.rowset.CachedRowSet;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    class jdbc2{
    final private String s1="SELECT top 10 [DATE], [ADJ CLOSE] FROM [vwo-1.csv]";
    private ResultSet result=null;
    private Connection conn=null;
    public static void main(String[] args) throws SQLException{
    jdbc2 db=new jdbc2();
    try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              db.conn = DriverManager.getConnection("jdbc:odbc:STOCK_DATA");
              PreparedStatement sql=db.conn.prepareStatement(db.s1);
              db.result=sql.executeQuery();
    // check column names and types using the ResultSetMetaData object.
              ResultSetMetaData metaData = db.result.getMetaData();
         System.out.println("Table Name : " + metaData.getTableName(2));
         System.out.println("Field\t\tDataType");
         for (int i = 0; i < metaData.getColumnCount(); i++) {
         System.out.print(metaData.getColumnName(i + 1) + "\t");
         System.out.println(metaData.getColumnTypeName(i+1));
         System.out.print(metaData.getColumnName(1) + "\t"+metaData.getColumnName(2)+"\n");
              while (db.result.next()){
                   System.out.print(db.result.getDate("DATE", Calendar.getInstance()));
                   System.out.format("\t%,.2f\n", db.result.getFloat("Adj Close"));
    catch (Exception e) {
    System.out.println("Error: " + e.getMessage());
         finally {
              db.result.close();
              db.conn.close();
    Everything works well, until getting to the block
              while (db.result.next()){
                   System.out.print(db.result.getDate("DATE", Calendar.getInstance()));
                   System.out.format("\t%,.2f\n", db.result.getFloat("Adj Close"));
    The getDate("DATE", Calendar.getInstance())); always returns null, instead of the date value in the vwo-1.csv.
    Even though I change it to
    java.sql.Date d=db.result.getDate("DATE") and convert to String using .toString(), I still gets nulls. The dollar amount in "Adj Close" field is fine, no problem.
    The .csv fils is downloaded from YahooFinace.
    Can anyone review the code and shed some light as to what I did wrong?
    Thanks alot.

    CREATE TABLE `login` (
    `username` varchar(40) DEFAULT NULL,
    `password` varchar(40) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `amount` (
    `amountid` int(11) NOT NULL,
    `receiptid` int(11) DEFAULT NULL,
    `loanid` int(11) DEFAULT NULL,
    `amount` bigint(11) DEFAULT NULL,
    `latefee` int(11) DEFAULT NULL,
    `paymentid` int(11) DEFAULT NULL,
    `pid` int(11) DEFAULT NULL,
    PRIMARY KEY (`amountid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `applicationfee` (
    `applicationfeeid` int(11) DEFAULT NULL,
    `applicationamount` int(11) DEFAULT NULL,
    `applicationfee` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `category` (
    `categoryid` int(11) DEFAULT NULL,
    `categoryname` varchar(40) DEFAULT NULL,
    `categorydescription` varchar(500) DEFAULT NULL,
    `cattype` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `commission` (
    `commissionid` int(11) DEFAULT NULL,
    `bussiness` int(11) DEFAULT NULL,
    `commission` int(11) DEFAULT NULL,
    `pid` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `customer` (
    `cacno` int(11) NOT NULL DEFAULT '0',
    `name` varchar(40) DEFAULT NULL,
    `age` int(11) DEFAULT NULL,
    `cphone` varchar(40) DEFAULT NULL,
    `cmobile` varchar(40) DEFAULT NULL,
    `caddress` varchar(500) DEFAULT NULL,
    `cstatus` varchar(20) DEFAULT NULL,
    `cphoto` longblob,
    `pid` int(11) DEFAULT NULL,
    PRIMARY KEY (`cacno`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `daybook` (
    `closingbal` varchar(40) DEFAULT NULL,
    `date` date DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `extraincome` (
    `categoryid` int(11) NOT NULL,
    `receiptid` int(11) DEFAULT NULL,
    `date` date DEFAULT NULL,
    `amountid` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `employee` (
    `empno` int(11) DEFAULT NULL,
    `empname` varchar(40) DEFAULT NULL,
    `age` int(11) DEFAULT NULL,
    `sal` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `image` (
    `id` int(11) DEFAULT NULL,
    `image` blob
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `loan` (
    `loanid` int(11) NOT NULL DEFAULT '0',
    `loanamt` varchar(40) DEFAULT NULL,
    `payableamount` double DEFAULT NULL,
    `installment` int(11) DEFAULT NULL,
    `payableinstallments` int(11) DEFAULT NULL,
    `monthlyinstallment` varchar(20) DEFAULT NULL,
    `surityname` varchar(20) DEFAULT NULL,
    `applicationfeeid` int(11) DEFAULT NULL,
    `interestrate` float DEFAULT NULL,
    `issuedate` date DEFAULT NULL,
    `duedate` date DEFAULT NULL,
    `nextduedate` date DEFAULT NULL,
    `cacno` int(11) DEFAULT NULL,
    `cname` varchar(20) DEFAULT NULL,
    `pid` int(11) DEFAULT NULL,
    `interestamt` double DEFAULT NULL,
    `pendingamt` float DEFAULT NULL,
    PRIMARY KEY (`loanid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `md` (
    `mdid` int(11) NOT NULL DEFAULT '0',
    `mdname` varchar(40) DEFAULT NULL,
    `mdphoto` varchar(100) DEFAULT NULL,
    `mdphone` varchar(40) DEFAULT NULL,
    `mdmobile` varchar(40) DEFAULT NULL,
    `mdaddress` varchar(500) DEFAULT NULL,
    PRIMARY KEY (`mdid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `partner` (
    `pid` int(11) NOT NULL DEFAULT '0',
    `pname` varchar(40) DEFAULT NULL,
    `paddress` varchar(500) DEFAULT NULL,
    `pphoto` varchar(100) DEFAULT NULL,
    `pphone` varchar(40) DEFAULT NULL,
    `pmobile` varchar(40) DEFAULT NULL,
    `pstatus` varchar(20) DEFAULT NULL,
    `mdid` int(11) DEFAULT NULL,
    `mdname` varchar(40) DEFAULT NULL,
    `date` date DEFAULT NULL,
    `nextpaydate` date DEFAULT NULL,
    PRIMARY KEY (`pid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `partnerinvested` (
    `pid` int(11) DEFAULT NULL,
    `pname` varchar(20) DEFAULT NULL,
    `receiptid` int(11) DEFAULT NULL,
    `date` date DEFAULT NULL,
    `amountinvested` int(11) DEFAULT NULL,
    `latefee` int(11) DEFAULT NULL,
    `amountid` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `payments` (
    `paymentid` int(11) NOT NULL,
    `categoryid` int(11) DEFAULT NULL,
    `particulars` varchar(100) DEFAULT NULL,
    `amountid` int(11) DEFAULT NULL,
    `paymentdate` date DEFAULT NULL,
    PRIMARY KEY (`paymentid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    CREATE TABLE `receipts` (
    `receiptid` int(11) DEFAULT NULL,
    `paiddate` date DEFAULT NULL,
    `amountid` int(11) DEFAULT NULL,
    `loanid` int(11) DEFAULT NULL,
    `latefee` int(11) DEFAULT NULL,
    `installment` int(11) DEFAULT NULL,
    `cacno` int(11) DEFAULT NULL,
    `cname` varchar(40) DEFAULT NULL,
    `pid` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

  • Naming.lookup() returns null???? Why??

    I read about this in a previous forum but there was no answer given to someones question about it. Sometimes Naming.lookup() returns null and a later call will succeed. Is there a recognised reason for this? Is it a recognised bug or undocumented feature?
    I have seen some sample RMI source on the Internet and sometimes the code checks for null and gives and error. The sample programs from Sun regarding RMI don't check for null.
    Has anyone ever encountered this and found a way around it?
    Thanks for you help,
    Anthony

    hi
    are you using an Activatable object??
    then, it can happens, since you won't have your object until the ActivationSytem is running.
    And it takes little time for the activation system to run.
    If u are using an 'Activatable object, i will suggest to write a loop in which you check if hte ActivationSystem was started.
    something like this
    boolean display = false;
    ActivationGroupID agi = null;
    while(true) {
    try {
    if(!display) {
    System.err.println("Trying to connect to ActivationSystem...");
    display = !display;
    agi = ActivationGroup.getSystem().registerGroup(exampleGroup);
    break;
    } catch(Exception e) {
    continue;
    }

  • GetDocumentBase returns null in Update 40

    The change to make getCodeBase() and getDocumentBase() return null has broken our FindinSite-CD signed applet which is out in the field on many data CDs and similar, ie running locally.  It doesn't provide any more security as our all-permissions applet can still access the same information (once it knows where it is).  The trouble is, the CD may be run from anywhere so I do not know the absolute path in advance. I have found that I can add code so that JavaScript is used to pass the current URL as a PARAM to the APPLET.  However this should not be necessary.
    Can you provide a better fix that does not break all our existing users who update to Update 25 or 40?
    I would be happy for our applet to have access restricted to its own directory or lower.
    Or for an all-permissions applet, make getCodeBase() and getDocumentBase() return the correct values.
    Please see the second link below for a further discussion.
    Bug ID: JDK-8019177 getdocument base should behave the same as getcodebase for file applets
    Oracle's Java Security Clusterfuck
    PS  There is a separate Firefox 23 issue stopping access to local Java applets - this should be fixed this week in version 24.
    Chris Cant
    PHD Computer Consultants Ltd
    http://www.phdcc.com/fiscd/

    Our company uses the above FindinSite-CD software to provide search functionality on our data CDs and we have done so successfully for many years.  These latest changes in Update 40 have now broken this vital component on our product and will cost us considerably in technical support time and replacing the discs when a fix comes out. Just an end user's perspective!

  • GetConnectionURL returns null in Bluetooth Application

    Hi,
    I am trying to make my first steps with the JSR-82 API on mobile phones
    (Nokia 6680 and Sony Ericsson W800i). I have written a simple program
    (see code below), which is supposed to discover near-by devices, search
    for a given service (UUID) on a chosen (previously discovered) device
    (=server) and then to connect to the server and send a byte (n) to it. The
    server should then in turn send n+1 back. All this should be done using
    RFCOMM.
    The code works fine in the emulator as well as on two Nokia phones and
    on two SE phones. It further works, when using a Nokia phone as the
    server and a SE phone as the client. However, when using a SE as the
    client and a Nokia as the server, the call to getConnectionURL() returns
    null instead of a valid URL that can be used to set up the connection
    (you can find this piece of code in the ClientThread class). Can somebody
    explain me what I am doing wrong?
    Thanks,
    Michael
    P.S.:At first I thought it might be a compatibility problem, but in the
    BluetoothDemo program that comes with WTK2.2 the correct URL ist
    returned by getConnectionURL() (have other problems with this example
    though, when it comes to download images, in particular...).
    import java.io.IOException;
    import java.util.Vector;
    import javax.bluetooth.BluetoothStateException;
    import javax.bluetooth.DataElement;
    import javax.bluetooth.DeviceClass;
    import javax.bluetooth.DiscoveryAgent;
    import javax.bluetooth.DiscoveryListener;
    import javax.bluetooth.LocalDevice;
    import javax.bluetooth.RemoteDevice;
    import javax.bluetooth.ServiceRecord;
    import javax.bluetooth.UUID;
    import javax.microedition.io.StreamConnectionNotifier;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.List;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    public class MessageTest2 extends MIDlet
          implements CommandListener, DiscoveryListener {
          private final int START = 0;
          private final int SERVER_IDLE = 1;
          private final int CLIENT_START = 2;
          private final int CLIENT_DEVICES_DISCOVERED = 3;
          private final int CLIENT_SERVICES_DISCOVERED = 4;
          private final String MY_UUID = "F0E0D0C0B0A000908070605040302010";
          private final Command EXIT_CMD = new Command("Exit", Command.EXIT, 1);
          private final Command OK_CMD = new Command("Ok", Command.OK, 1);
          private List startList = new List("Select Type", List.IMPLICIT);
          private List deviceList = null;
          private List serviceList = null;
          private Form mainForm = new Form("Message Test 2");
          private int state;
          private ServerThread serverThread = null;
          private LocalDevice local = null;
          private DiscoveryAgent agent = null;
          StreamConnectionNotifier server = null;
          private Vector devicesFound = null;
          private ServiceRecord[] servicesFound = null;
          public MessageTest2() {
                super();
                mainForm.addCommand(EXIT_CMD);
                mainForm.addCommand(OK_CMD);
                mainForm.setCommandListener(this);
                startList.addCommand(EXIT_CMD);
                startList.addCommand(OK_CMD);
                startList.append("Server", null);
                startList.append("Client", null);
                startList.setCommandListener(this);
          protected void startApp() throws MIDletStateChangeException {
                state = START;
                Display.getDisplay(this).setCurrent(startList);
          protected void pauseApp() {
                // TODO Auto-generated method stub
          protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
                // TODO Auto-generated method stub
          public void commandAction(Command c, Displayable d) {
                if (c == EXIT_CMD) {
                      if (server != null) {
                            try {
                                  server.close();
                            } catch (IOException e) {
                      notifyDestroyed();
                if (c == OK_CMD) {
                      if (state == START) {
                            if (startList.getSelectedIndex() == 0) {
                                  startServer();
                            } else {
                                  startClient();
                      } else if (state == CLIENT_START) {
                            doDeviceDiscovery();
                      } else if (state == CLIENT_DEVICES_DISCOVERED) {
                            doServiceDiscovery();
                      } else if (state == CLIENT_SERVICES_DISCOVERED) {
                            communicate();
          public void deviceDiscovered(RemoteDevice dev, DeviceClass devClass) {
                devicesFound.addElement(dev);
          public void servicesDiscovered(int transID, ServiceRecord[] serviceRecs) {
                servicesFound = serviceRecs;
          public void serviceSearchCompleted(int transID, int respCode) {
                switch(respCode) {
                case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
                      showServices();
                      break;
                case DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
                      System.err.println("Device not reachable");
                      break;
                case DiscoveryListener.SERVICE_SEARCH_ERROR:
                      System.err.println("Service search error");
                      break;
                case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
                      System.err.println("No records");
                      break;
                case DiscoveryListener.SERVICE_SEARCH_TERMINATED:
                      System.err.println("Service search terminated (cancelled)");
                      break;
          public void inquiryCompleted(int param) {
                switch (param) {
                case DiscoveryListener.INQUIRY_COMPLETED:
                      showDevices();
                      break;
                case DiscoveryListener.INQUIRY_ERROR:
                      System.err.println("Inquiry error");
                      Display.getDisplay(this).setCurrent(mainForm);
                      break;
                case DiscoveryListener.INQUIRY_TERMINATED:
                      System.err.println("Inquiry terminated (cancelled)");
                      Display.getDisplay(this).setCurrent(mainForm);
                      break;
          public void setServer(StreamConnectionNotifier server) {
                this.server = server;
          private void startServer() {
                state = SERVER_IDLE;
                mainForm.deleteAll();
                mainForm.append("Server");
                Display.getDisplay(this).setCurrent(mainForm);
                String connectionURL = "btspp://localhost:" + MY_UUID + ";"
                      + "authenticate=false;encrypt=false;name=RFCOMM Server";
                try {
                      local = LocalDevice.getLocalDevice();
                      local.setDiscoverable(DiscoveryAgent.GIAC);
                } catch (BluetoothStateException e) {
                      System.err.println(e);
                serverThread = new ServerThread(this, connectionURL);
                serverThread.start();
                System.out.println("Server thread started");
          private void startClient() {
                state = CLIENT_START;
                mainForm.deleteAll();
                mainForm.append("Discover?");
                Display.getDisplay(this).setCurrent(mainForm);
          private void doDeviceDiscovery() {
                Form discoveringForm = new Form("discovering");
                try {
                      local = LocalDevice.getLocalDevice();
                } catch (BluetoothStateException e) {
                      System.err.println(e);
                agent = local.getDiscoveryAgent();
                devicesFound = new Vector();
                try {
                      if (!agent.startInquiry(DiscoveryAgent.GIAC, this)) {
                            System.err.println("Inquiry not started...");
                } catch (BluetoothStateException e) {
                      System.err.println(e);
                Display.getDisplay(this).setCurrent(discoveringForm);
          private void doServiceDiscovery() {
                if (devicesFound.size() <= 0) return;
                int[] attributes = {0x100, 0x101, 0x102};
                UUID[] uuids = new UUID[1];
                uuids[0] = new UUID(MY_UUID, false);
                int index = deviceList.getSelectedIndex();
                RemoteDevice rd = (RemoteDevice)devicesFound.elementAt(index);
                try {
                      agent.searchServices(attributes, uuids, rd, this);
                } catch (BluetoothStateException e) {
                      System.err.println(e);
          private void showDevices() {
                state = CLIENT_DEVICES_DISCOVERED;
                deviceList = new List("Discovered Devices", List.IMPLICIT);
                deviceList.addCommand(EXIT_CMD);
                deviceList.addCommand(OK_CMD);
                deviceList.setCommandListener(this);
                for (int i = 0; i < devicesFound.size(); i++) {
                      RemoteDevice rd = (RemoteDevice)devicesFound.elementAt(i);
                      String str = rd.getBluetoothAddress();
                      try {
                            str = str + " " + rd.getFriendlyName(false);
                      } catch (IOException e) {
                      deviceList.append(str, null);
                Display.getDisplay(this).setCurrent(deviceList);
          private void showServices() {
                state = CLIENT_SERVICES_DISCOVERED;
                if (servicesFound.length <= 0) {
                      mainForm.deleteAll();
                      mainForm.append("no services found");
                      mainForm.append("discover devices?");
                      state = CLIENT_START;
                      Display.getDisplay(this).setCurrent(mainForm);
                      return;
                serviceList = new List("Services Found", List.IMPLICIT);
                serviceList.addCommand(EXIT_CMD);
                serviceList.addCommand(OK_CMD);
                serviceList.setCommandListener(this);
                for (int i = 0; i < servicesFound.length; i++) {
                      String str;
                      ServiceRecord sr = (ServiceRecord)servicesFound;
    DataElement de = sr.getAttributeValue(0x100);
    str = (String)de.getValue();
    serviceList.append(str, null);
    Display.getDisplay(this).setCurrent(serviceList);
    private void communicate() {
    int index = serviceList.getSelectedIndex();
    ServiceRecord sr = (ServiceRecord)servicesFound[index];
    ClientThread clientThread = new ClientThread(this, sr);
    clientThread.start();
    public void showResult(int n) {
    Form resultForm = new Form("End");
    resultForm.addCommand(EXIT_CMD);
    resultForm.setCommandListener(this);
    resultForm.append("Received: " + n);
    Display.getDisplay(this).setCurrent(resultForm);
    public void showMessage(String msg) {
    Displayable d = Display.getDisplay(this).getCurrent();
    Alert al = new Alert("Info", msg, null, AlertType.INFO);
    al.setTimeout(Alert.FOREVER);
    Display.getDisplay(this).setCurrent(al, d);
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.StreamConnection;
    import javax.microedition.io.StreamConnectionNotifier;
    public class ServerThread extends Thread {
          private MessageTest2 parent;
          private StreamConnectionNotifier server;
          private String connectionURL = null;
          public ServerThread(MessageTest2 parent, String connectionURL) {
                this.parent = parent;
                this.connectionURL = connectionURL;
          public void run() {
                StreamConnection conn = null;
                try {
                      server = (StreamConnectionNotifier) Connector.open(connectionURL);
                } catch (IOException e) {
                      System.err.println(e);
                parent.setServer(server);
                try {
                      conn = server.acceptAndOpen();
                } catch (IOException e) {
                      System.err.println(e);
                InputStream in = null;
                int n = -1;
                try {
                      in = conn.openInputStream();
                      n = in.read();
                } catch (IOException e) {
                      System.err.println(e);
                if (in != null) {
                      try {
                            in.close();
                      } catch (IOException e) {
                            System.err.println(e);
                try {
                      OutputStream out;
                      out = conn.openOutputStream();
                      out.write(n + 1);
                      out.flush();
                } catch (IOException e) {
                      System.err.println(e);
                try {
                      conn.close();
                } catch (IOException e) {
                      System.out.println(e);
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import javax.bluetooth.ServiceRecord;
    import javax.microedition.io.Connector;
    import javax.microedition.io.StreamConnection;
    public class ClientThread extends Thread {
          private MessageTest2 parent;
          private ServiceRecord sr;
          public ClientThread(MessageTest2 parent, ServiceRecord sr) {
                this.parent = parent;
                this.sr = sr;
          public void run() {
            StreamConnection conn = null;
            String url = null;
            int n = 0;
            try {
                url = sr.getConnectionURL(
                        ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
                if (url == null) {
                      parent.showMessage("URL null");
                      return;
                conn = (StreamConnection) Connector.open(url);
            } catch (IOException e) {
                System.err.println("Note: can't connect to: " + url);
            try {
                OutputStream out = conn.openOutputStream();
                out.write(n);
                out.flush();
                out.close();
                InputStream in = conn.openInputStream();
                n = in.read();
            } catch (IOException e) {
                System.err.println("Can't write to server for: " + url);
            try {
                  conn.close();
            } catch (IOException ee) {
                  System.err.println(ee);
            parent.showResult(n);

    Hi:
    How did you compile and build the package using WSDL2JAVA. I tried under UCM 6.1 environment but receiving error message on 2 of the classes that, too large object.
    axisbuild:
    compiling 1007 source files
    /generatedaxisclient/com/cisco/www/AXLAPLService/AXLAPIBindingStub.java:4026:code too large
    public AXLAPIBindingStub(javax.xml.rpc.Service service)throws org.apache.axis.AxisFault {
    Error
    /generatedaxisclient/com/cisco/www/AXLAPLService/AXLAPIBindingStub.java:18:code too large
    public AXLAPIBindingStub(javax.xml.rpc.Service service)throws org.apache.axis.AxisFault {
    static {
    Error
    2 Errors
    Please let me know if you have any thoughts on this.
    Thank You
    Ramesh Vasudevan

  • PDFontDownloadContextCreate returns NULL in PDFL8 and PDFL9

    Hi,
    In PDFL7 we have a module which converts PDF 2 PS using the PDDocPrintPages( &client )
    We have heavy usage of fonts so we try and minimelize font insersion using and manimulating the PDFontDownloadContext
    ACCBPROTO1 ASBool CPDFConverter::PDFToPSEmitFont( ASStm stm, PDFont pdFont, PDPrintClient client, ASUns32 flags )
    bRes = PDFontStreamPS( pdFont, stm, (PDFontDownloadContext)client->fontDownloadContext );
    HOWEVER:
    in PDFL8 and PDFL9
    saveFontContext = PDFontDownloadContextCreate(&client);
    returns NULL
    //////////////// snippit ////////////////////////
    PDPrintClientRec client;
    memset(&client, 0, sizeof(client));
    client.size = sizeof(client);
    PDFontDownloadContext saveFontContext;
    saveFontContext = PDFontDownloadContextCreate(&client);
    OR:
    client.fontDownloadContext = (void *) PDFontDownloadContextCreate(&client);
    return NULL
    //////////////// end snippit ////////////////////////
    Is this a bug?
    Has this feature been disabled?
    If so, how come its open in the include files?
    Please advise.
    Thanks, Erez

    Well I can't speak to PDFL9 yet since it has not yet been released or even publicly announced by Adobe yet, but the reason for 8 should account for 9 as well.
    It is still in the PDFL so as not to break legacy workflows, basically. With the introduction of the AGM print engine in 8, the font download context is no longer used and so this method should always return NULL.
    Probably best to wait for Leonard to confirm but that is the answer I was given when I first came across this issue a few months ago.

  • In Portal, request.getparameter return NULL (Sample Monthcalendar)

    I used the sample monthcalendar. When i used it without integrated in portal, i can change month by month with ">>" button.
    In the JSP File, there is a call to the P_CALDATE parameter
    String l_inputDate = request.getParameter("P_CALDATE"); // Input Date.
    When i put this JSP file as an URL Portlet, i can't navigate month by month. the function request.getParameter("P_CALDATE") return NULL, but in the URL i have the parameter:
    http://hddms220.cg63.fr/servlet/page?_pageid=54,58,56&_dad=portal30&_schema=PORTAL30&P_CALDATE=2002-05-01.
    Someone have an idea
    Thanks in advanced

    I have tested the sample with JSERV, and all works fine.
    But if i wan't use OC4J/ORION to display a portlet how can i do it.
    Thanks in advanced

  • Get attribute name from VO returns null.

    Hello,
    I'm using JDeveloper 11.1.1.3. I have an af:inputfile component in which i set a ValueChangeListener. I'm using the attribute "Filename" from the form view to set the name of the file before saving it to a directory. At first, i had a different layout for my jspx page (very similar in design) and everything was working perfectly. When i redesigned the page, i'm now getting "null" as the filename. I'm not able to get the attribute! Although i didn't change anything in the code! I tried writing a simple method to output the attribute:
          public String justOutput(){
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("Filename");
            if (attr == null)
                return null;
            String filename = (String) attr.getInputValue();
            System.out.print(filename);
            return null;
          }It was able to output the attribute. But in my original method i'm getting "null".
    ******Another important observation*******
    If i pressed upload another time at runtime and uploaded another file it works again!
    Here is my code:
         public void uploadFile(ValueChangeEvent valueChangeEvent)  {
              InputStream in;
              FileOutputStream out;   
              ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
              String fileLoc = context.getInitParameter("DATA_DIR");                 
              UploadedFile file= (UploadedFile)valueChangeEvent.getNewValue();                           
              boolean exists = (new File(fileLoc)).exists();
              if(!exists){
                (new File(fileLoc)).mkdirs();
              if(file != null && file.getLength() > 0){
                FacesContext context2 = FacesContext.getCurrentInstance();
                FacesMessage message = new FacesMessage("File Uploaded" + file.getFilename() +
                                                        "(" + file.getLength() + "bytes)");
                //context2.addMessage(valueChangeEvent.getComponent().getClientId(context2), message);
                BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
                AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("Filename");
                if (attr == null)
                    return;
                String filename = (String) attr.getInputValue();
                try {
                         out = new FileOutputStream("C:\\demos\\" + filename + ".pdf");
                         in = file.getInputStream();
                         for (int bytes=0; bytes < file.getLength(); bytes++) {
                             out.write(in.read());
                         in.close();
                         out.close();
                     } catch (IOException e) {
                     e.printStackTrace();
              else {
                  String filename = file != null ? file.getFilename():null;
                  String byteLength = file != null ? "" + file.getLength():"0";
          }I don't think the code is wrong because it worked before. But why is this happening?
    Can anyone please help!?
    Mohamed.

    Sorry for the late reply Frank,
    Thanks for your reply, no i didn't! But it worked when i set the 'autosubmit' property to true... Like you said:
    the name field hasn't updated the model to the time you try and access itThanks again.
    Mohamed

Maybe you are looking for

  • HT201415 How to unlock my iphone 5s

    How can I unlock my iphone 5s from sprint

  • Whether Non leading ledger will have copy of Leading ledger transactions?

    Hi, I have basic understanding about leading and non leading ledgers. My question to the forum is whether non leading ledger will have copy of leading ledger transactions meaning whether entries posted from other modules like SD,MM,PP will be availab

  • Error on t-code va01, type : or

    I want to create an order, t-code : va01 and order type = OR but i got an error: Order type 'OR' has not been defined in Sales area <'GTSA','GT','GT'> where can i define this order type to sales area ? Thank you.

  • PrintScreen Functionality using Java Print Api(without Robot)

    Hi Guys I have an issue to discuss,can any of you tell me that is it possible to take the screen shot of screen(not printing on paper) in java using Print Api . I have done it with robot but i want to do it without using Robot. Thanks Vipul

  • Can I assign my default settings in Publish?

    Hi, Each time when we publish, we need to assign some parameters again. For example,  I need to change Flash Player Version from "Flash Player 10" (default) to "Flash Player 9" and change eLearning output from "None" to "SCORM 2004" (Enable Quiz/repo