Method returns null in main
i have a class and a main inside the main
i call the method getProperties.
but why is this still null???
System.out.println(odprops);
can someone suggest what i am doing wrong?
thanks in advance
annie
public class Launcher
private static Properties odprops;
public static void main(String args[])throws IOException, FileNotFoundException, Exception
getProperties(odprops);
System.out.println(odprops); //how come this is null
public static Properties getProperties(Properties props) throws IOException
FileInputStream fi = new FileInputStream("Loader.properties");
Properties odprops = new Properties();
odprops.load(fi);
System.out.println(odprops); //this is not null - it shows me my properties
return odprops;
}
public static void main(String args[])throws
s IOException, FileNotFoundException, Exception
getProperties(odprops);change to
odprops = getProperties(null);
Similar Messages
-
Looks like some Exceptions' getMessage() methods return null
Looks like some Exceptions' getMessage() methods return null instead of the message.
-Andrewsnidely_whiplash wrote:
Looks like some Exceptions' getMessage() methods return null instead of the message.
-AndrewDoes it return a null object, or does it return "null" as a String? The latter may be a case of using the message from a wrapped exception, which in case of a NullPointerException is frequently null (if the NPE was not constructed intentionally with a message).
BR,
Robert -
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; -
Hello,
The problem is pretty much exactly as specified.
Take this class for example:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package vicsanimation;
* @author
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
import javax.swing.*;
public class VButton extends JLabel {
BufferedImage activeImage;
BufferedImage pressedImage;
BufferedImage deactiveImage;
BufferedImage highlightedImage;
ImageIcon currentImage;
public VButton (String b1, String b2, String b3, String b4, int x, int y){
activeImage = new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
try {
activeImage = ImageIO.read(new File(b1));
pressedImage = ImageIO.read(new File(b2));
deactiveImage = ImageIO.read(new File(b3));
highlightedImage = ImageIO.read(new File(b4));
catch (IOException e) {
System.out.println(e.getMessage());
this.setSize(activeImage.getWidth(), activeImage.getHeight());
this.setLocation(x,y);
this.setVisible(true);
this.render(); // <----------------- ERROR FROM HERE!!!
// This is the method used to render the button. It does not use the paint method
// because the application can use FullScreen mode.
public void render(){
Graphics2D buttonGraphics = (Graphics2D)this.getGraphics();
buttonGraphics.drawImage(activeImage, null, 0, 0);
System.out.println("Image drawn successfully");
}If I run this code, I get a Null-Pointer exception thrown from the last method. This is because the "buttonGraphics" object is null.
I do know a work-around, although I'd really like to know exactly why this is happening.
The work-around is simply to remove the this.render() call at the end of the constructor, create the button in an outside container object, and then call the render() method from the object that contains the button. For example:
private void initScreen(){
..... snip ....
VButton closeButton = getCloseButton();
this.add(closeButton);
closeButton.render();
..... snip .....
}If anyone could explain to me why this happens (in non-Java expert language) I'd be very thankful.Thanks again for your help.
I'm sure the solution to every problem is in the API if one were to look hard enough!
But obviously the API is massive and I suppose you learn these things from experience more than committing that kind of stuff to memory. If I were to scour the API looking for solutions to things which I only barely understand to start with I'd go mad. Let alone be there for several days.
So thanks for helping out, I really appreciate it!
Edited by: wombatvvv on Jul 23, 2008 3:23 PM -
GetImplementation*() methods return null...
I have Implementation-Vendor, Implementation-Version and Implementation-Title clearly defined in my MANIFEST.MF, yet when I try to retrieve them (with e.g. MainClass.class.getPackage().getImplementationVendor()) null is always returned.
Anyone have any idea what the problem might be?
Thanks ahead.I seem to have found what the problem is. I use one-jar to pack couple of libraries with my project. When I don't pack the application it works like it should but it doesn't when it's, hmm..."one-jarred".
As a side not, I absolutely have to do that (or any other way of accessing libraries from within the jar, but this is the only that works so far and I have to be done in less than a week).
I've searched around one-jar's site and forum and no one seemed to have noticed this problem, so if anyone's got any idea it's much appreciated. -
GetContextURL returns null using the default ECM repository
Hello experts,
This is the scenario.
We are using the SAP ECM repositoy for document storage in our BPM proyect. In this case we are using the default configuration and repository location (ecm/default and DefaultUser), but after the upload, when i try to get the document URL with the method getContentURL(), returns null.
The ECM documentarion saids than this condition is expected when using a third party repostiory, but this is not the case.
I appreciate a lot your advices and recomendations,
Best regards!
Julio C. LeyvaHi Vasil,
We didn't resolve this issue by this method, because we are using the default ECM repository witch doesn't support the operation getContextURL() and gets the "null" result. If you are using a different repository maybe works.
Re-checking the API specification, saids:
getContentURL
java.lang.String getContentURL() throws InvalidStateException, RepositoryException Returns a URL that can be used to retrieve the content directly from the respective backend, thus bypassing ECM. Note that this URL might have several restrictions which depend on the connector's backend store, such as a limited lifetime or requiring a user to authenticate with different credentials than the ones used to connect to ECM. Other stores might provide no content URL at all, in which case this method returns null. Applications might want to consider utilizing the ECM WebDAV server to present their users a URL that is located on the same system as ECM.
Finally, you would consider to expose a webservice (EJB Session Bean) witch encapsulates the ECMI implementation and extract your file content as a binary array (encode/decode), sending as the input your path/fileName for lookup in the ECM repository.
Regards! -
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);
} -
A getName method allways returns null, why?
I have an
ArrayList<Animals> array_list = new ArrayList<Animals>();
LinkedList<Animals> linked_list = new LinkedList<Animals>();
I want the getName() method in class NewListener to be accessed from the class NextListener which extends NewListener, and therefor should get access to the method. But when I run the program, it allways returns null. Why?
class NewListener implements ActionListener
public String name;
public void actionPerformed(ActionEvent e)
String str_name = showInputDialog(this,"Animal name: ",null);
if(str_name == null)
return;
for(int i=0; i<array_list.size(); i++)
if(array_list.get(i).getName().equalsIgnoreCase(str_name))
setName(str_name); // set the name with the setName() method
linked_list.add(array_list.get(i));
public void setName(String name)
this.name=name;
public String getName()
return name; // this line returns "null"
// return "Hello"; // this line works and returns "Hello"
class NextListener extends NewListener implements ActionListener
public void actionPerformed(ActionEvent e)
try
linked_list .removeFirst();
}catch(NoSuchElementException er)
System.out.println("Numerical value");
String info = getName()+" is in line"; // Why does the getName() method in the NewListener allways return a null?
showMessageDialog(this, info, "Notice", INFORMATION_MESSAGE);
}{code}Roxxor wrote:
Ok, I changed the name to private and I also tried with
public void setName(String name)
System.out.println("setting name on " + this + " to " + name); // <--- ADD THIS LINE
this.name=name;
}and it works. So this.name SHOULD get the value of name, but it doesn�t.
So the question is: why does getName() return null?Your code is doing exactly what you're telling it to do. One or more of your assumptions is wrong. Keep digging. Add more print statements.
Above all, you must drop the attitude that "it should work." There's a bug in your code. You have to find it. Repeating the mantra "It should work" is simply going to put blinders on and make it almost impossible to find your error. Instead, you have to think, "What did I do wrong?" and "If getName is returning null, then setName was never called or was called with 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 -
iPLANET ISSUE
Why does the Java method ServletContext.getResourceAsStream return null with a know good path to an xsl file?
CODE
ServletContext context = mpiCfg.getServletConfig().getServletContext();
// Debugging
out.print(context.getServerInfo()); // Get server info
out.print(“getRealPath = ” + context.getRealPath("WEB-INF/xsl/RedirectToAcs.xsl"));
String strXslName = "RedirectToAcs.xsl";
InputStream is = context.getResourceAsStream("WEB-INF/xsl/"+ strXslName);
TRACE FROM THE LOG
[26/Jul/2002:08:23:15] info ( 2868): [0][][ClearCommerceCcpaMpi][]getServerInfo() = iPlanet-WebServer-Enterprise/6.0, getRealPath() = C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl\RedirectToAcs.xsl
[26/Jul/2002:08:23:15] info ( 2868): [0][][ClearCommerceCcpaMpi][]strXslName = RedirectToAcs.xsl, is = null
[26/Jul/2002:08:23:15] info ( 2868): [1][][ClearCommerceCcpaMpi][16]ResourceAsStream is null
[26/Jul/2002:08:23:15] info ( 2868): [1][][ClearCommerceCcpaMpi][30]Problem reading XSL file.
DIRECTORY DUMP
C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl>dir
Volume in drive C has no label.
Volume Serial Number is 9457-EBF4
Directory of C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl
07/22/2002 05:54p <DIR> .
07/22/2002 05:54p <DIR> ..
07/22/2002 05:54p 3,086 RedirectToAcs.xsl
07/22/2002 05:54p 3,088 Response.xsl
2 File(s) 6,174 bytes
2 Dir(s) 1,797,405,696 bytes freeI think there's supposed to be a forward slash before WEB-INF.
InputStream is = context.getResourceAsStream("/WEB-INF/xsl/"+ strXslName); -
Can "main" method return values
Hi,
I have a requirement of returning values to the
command prompt from the main method. Is this possible
to do in the first place. Is it valid.
i.e. Can you do the following in Java,
=======================================
import java.io.*;
import java.lang.Object;
import java.util.*;
public class P
public static String main(String args[])
String bye = "BYE";
return(bye);
=========================================
Can "main" method in Java return values at command
prompt.
Can you have something like,
public static String main(String args[])
instead of
public static void main(String args[])
Help urgently needed as I need to pipe data from a
Java program to a C++ program. One method is to
writing to a flat file but this would cause overheads
reading and writing to a file, hence this way.
Any help would be greatly appreciated.
Thanks in advance.
Thank,sHi jchak,
Yes I am trying to pass a Java String to a C++
application. Any insights, any help.
OK the whole thing goes as follows,
=========================================
Theres a C++ application which first starts up.
This app is then supposed to invoke a Java class file
which does some processing. Finally the value of one
variable in Java (actually a huge String) is to be made
available back to C++. This could be done thru flat file
wherein the Java outputs the string to the flat file
and on return the C++ program can be made to read the
same flat file to retrieve that string but this would
surely cause some overheads (time factor) reading and
writing files. So I wish to devise some way by means
of which I can return the string value back to the C++
program. Piping of data from one app to another is what I
want to do.
Is there some way by means of which Java can return
back or communicate or pipe back the string back to
C++. How can it be done without using external flat files
or databases.
Thansk,
JAtin -
EJB P.R.O.narrow method returns a null reference though object is valid
All,
I'm trying to deploy a simple stateless session bean to SUN server. The client code keeps failing because PortableRemoteObject.narrow returns null, even though the reference is located in JNDI tree.
I read somewhere that turning on RMI stub generation might help, but it didn't do it in my case.
This is a local server (SUN App Server, as downloaded from java.sun site).
JNDI tree contains the following entries:
UserTransaction
test.Dummy
jdbc
ejb
test.Server
Neither test.Dummy nor test.Server (the beans I deployed) want to load.
Any help would be appreciated.
Thanks!
MarkNever mind. For some reason changing initial context creation from:
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"whatever factory");
p.put(Context.PROVIDER_URL,"whatever url");
InitialContext context=new InitialContext(p);
to:
InitialContext context=new InitialContext();
fixed the problem. Which is strange, since JNDI tree was listing both objects, and they both could be resolved when using the first code snippet. Only the actual object creation was failing.
If anyone knows why this is so, please explain.
Cheers,
Mark -
GetAttribute() method of a view object is returning NULL
Hi ,
I am trying to implement PPR in one of my OAF page and I have taken the following approach.
I have declared the follwing transient boolean attribute in the VO() apart from the existing attribute "Meaning" .
1.MfgEnttity
2.MfgAcct
3.MfgSubAcct
4.MfgCc
5.MfgProj
In the page I have used these attributes in the rendered property as "${oa.XXR2RMfgproSegVO.MfgSubAcct}" like this.
Now in the CO I have written the following code.
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("initializeXXR2RMfgproSegVO");
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
String event = pageContext.getParameter(EVENT_PARAM);
String source = pageContext.getParameter(SOURCE_PARAM);
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
am.invokeMethod("handleSegmentChangeEvent");
And the AM code is as follows:
public void initializeXXR2RMfgproSegVO()
OAViewObject vo = getXXR2RMfgproSegVO();
if(!vo.isPreparedForExecution())
vo.executeQuery();
Row row = vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
public void handleSegmentChangeEvent()
OAViewObject pVO = (OAViewObject)findViewObject("XXR2RMfgproSegVO");
OARow hdrRow = (OARow)pVO.getCurrentRow();
String status = (String)hdrRow.getAttribute("Meaning");
System.out.println("poRow "+ hdrRow.toString());
System.out.println("value of the status is "+ status);
if("Entity".equals(status))
hdrRow.setAttribute("MfgEnttity", Boolean.TRUE);
hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgCc", Boolean.FALSE);
hdrRow.setAttribute("MfgProj", Boolean.FALSE);
} else
if("Account".equals(status))
hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
hdrRow.setAttribute("MfgAcct", Boolean.TRUE);
hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgCc", Boolean.FALSE);
hdrRow.setAttribute("MfgProj", Boolean.FALSE);
}else
if("Subaccount".equals(status))
hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgSubAcct", Boolean.TRUE);
hdrRow.setAttribute("MfgCc", Boolean.FALSE);
hdrRow.setAttribute("MfgProj", Boolean.FALSE);
}else
if("Cost Center".equals(status))
hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgCc", Boolean.TRUE);
hdrRow.setAttribute("MfgProj", Boolean.FALSE);
} else
if("Project".equals(status))
hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgCc", Boolean.FALSE);
hdrRow.setAttribute("MfgProj", Boolean.TRUE);
else
hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
hdrRow.setAttribute("MfgCc", Boolean.FALSE);
hdrRow.setAttribute("MfgProj", Boolean.FALSE);
Now when in the page I am changing the value of the attribute "Meaning" it is always getting into the else part i.e. where all the attributes are "False".
The two System.out.Println statements are returning the follwing values.
10/03/22 15:41:08 poRow [email protected]3
10/03/22 15:41:08 value of the status is null
Can you please suggest why this "Status" is returning NULL and how I can get the current row selected in the page?
Thanks
SubhabrataHi Pratap,
Thanks a lot for your reply.
Can you please suggest how can I rectify the code.I have tried commenting the AM code as follows
public void initializeXXR2RMfgproSegVO()
OAViewObject vo = getXXR2RMfgproSegVO();
if(!vo.isPreparedForExecution())
vo.executeQuery();
//Row row = vo.createRow();
//vo.insertRow(row);
//row.setNewRowState(Row.STATUS_INITIALIZED);
But in the page when I am selecting any segment its throwing Null pointer Exception.
I am new in OAF and this is an urgent client requirement.Please suggest me Where exactly I need to make change in my code.
Thanks in advance...
Thanks
Subhabrata -
Get textFrame by label returns null and anchored objects
I have the following two functions:
function getByLabel(page, label)
for(var i=0; i < page.allPageItems.length; i++)
if( page.allPageItems[i].label == label )
return page.allPageItems[i];
and
Object.prototype.findItems = function(/*obj*/props)
if( !('everyItem' in this) )
throw new Error("Error: " + this + " is not a collection.");
var ret = this.everyItem().getElements(),
i = ret.length,
e, p;
while( i-- && e=ret[i] )
for( p in props )
if( (p in e) && e[p]===props[p] ) continue;
ret.splice(i,1);
return ret;
In my page structure, I got one main text frame (the content area) and two vertical text fromes on the sides of the page. There is also a small box textframe on top of the page. All these textboxes EXCEPT the main text frame are ALL "ANCHORED objects". I had to make them anchored objects, eitherwise after importing data, the boxes would jump around. (Example, the small box textframe that is on the top would get moved to the content area textframe etc). Not sure if using anchored objects is the proper way to fix this.
When I try to get the small box text frame, it does not work using the findItems (returns null) but it works fine with the getByLabel method. Why is that?
The calling syntax is:
for( i=0 ; i < doc.pages.length ; ++i )
var page = doc.pages.item(i);
var textFrame = getByLabel(page, 'lblSection' ); //This works
// var textFrame = page.textFrames.findItems({ label: 'lblSection' })[0]; This does not work, returns null
if( textFrame != null )
textFrame.parentStory.contents = "";(function () {
// Per the InDesign Scripting Guide, app.activeScript is only
// valid when a script is directly executed from InDesign, not
// from the ESTK, so a try/catch block is recommended to handle
// it.
var d;
try {
d = app.activeScript.parent.parent.fsName;
} catch (e) {
d = Folder.appPackage.parent.fsName+"/Scripts";
return d; -
Graphics returning null in one place, but not another.
If you want to compile and run my program.... you can get all the files here:
http://s94182144.onlinehome.us/randomstuff/files.zip
(The main classes you'll need to look at are DrawingCanvas, Trig and GraphEngine)
Here's a visual just in case:
http://s94182144.onlinehome.us/randomstuff/graph.jpg
When I click the "Graph It" button, I'm sending all those variables in the window to another class. Except the method I need to call is passed Graphics g... and thus, I needed to create a graphics variable. But it's returning null.
Here is my code in GraphEngine, which runs when a button is clicked. You'll notice for Graph It... I created a Graphics variable... this returns null. Except you'll also notice I do the same thing for "Clear"... but this works.
NOTE: I was getting mad so I named some methods not so nicely :p .... you may notice they are different in my files.
public void actionPerformed(ActionEvent e)
userDisplay=e.getActionCommand();
if(userDisplay.equals("Draw"))
String progChoice=grapher.graphType.getSelectedItem();
System.out.println(progChoice);
if(progChoice.equals("Lines"))
grapher.allButtons[0].enable();
draw();
else if(progChoice.equals("Scatter Plot"))
lineOfBestFit();
else if(userDisplay.equals("Graph It"))
Trig.graphThisStuff();
Graphics g = canvas.getGraphics();
canvas.trig(g);
else if(userDisplay.equals("Clear"))
Graphics g = canvas.getGraphics();
System.out.println(g);
canvas.clear(g);
else if(userDisplay.equals("Reset"))
Trig.restartThis();
else if(userDisplay.equals("Credits"))
showInstructionsFrame();
else if(userDisplay.equals("Help"))
showHelpFrame();
else if(userDisplay.equals("Create Sinusodial Graph"))
showTrigFrame();1. Do you expect forum members to download and unzip your code? Good luck...
2. Inside almost every "big" problem is a small one trying to get out. Write a minimal program
demonstrating your problem (say <50 lines) and post that. The shorter code and the easier it
is to copy, paste and run, the more forum members will actually give it a go.
That being said, you problem is that you are using Component's getGraphics at all. Don't use it.
It doesn't work very well -- they rendering you do is temporary, if you iconify and restore your
window your changes will disappear (sometimes even moving another window past yours will do this!).
What should you do instead? Put all your rendering code in paintComponent (or subroutines
it calls). Changes in state of your app should trigger a call to repaint (or you will call it directly).
Repainting will eventually cause your paintComponent to be called.
Maybe you are looking for
-
Tried https://discussions.apple.com/thread/2713232?start=0&tstart=0 and http://www.vistax64.com/vista-general/159940-computer-blocking-anything-no-digit al-signature.html with no avail!!! iTunes opens after I click OK on the above message however I c
-
HP SimpleSave External Hard Drive - Can't Access Files, Says to Re-Format
I have had a SimpleSave External Hard Drive for over a year now, and have never had any problems with it. Recently, I am unable to access my files on the hard drive when it is attached to my computer. It tries to load, and then gives me the error me
-
Issues running Responsive HTML5 project in IE 7 and 8
Hello, I recently published my first help project using the Responsive HTML5 format. Despite some issues with a corrupt screen profile template that led to some initial display problems (font in header not displaying properly), all seemed to be worki
-
Debbugging J2EE using SAP NetWeaver Developer Studio
Hi experts, I need to debug J2EE application in SAP NetWeaver Developer Studio. How can I do it?There is something to set or activate in J2EE Engine?Thanks
-
Turn off iTunes artwork / animation
My apple tv 2 works perfectly... except one thing is driving me mad and I can't find a way around it! Picture the scene, dinner party and iTunes is streaming to ATV2, TV, and surround sound system. Except the iTunes album artwork is fliping and chang