Overriding executeQuery Method in VOImpl in oaf
Hi All,
I am trying to override executeQuery method in my extended VOImpl method.
The VO that I extended is JobsWithGradeLovVO.
This is what I am writing in my method:
public void executeQuery(){
writeLog("In the executeQuery");
OADBTransaction tx = ((OAApplicationModuleImpl)getApplicationModule()).getOADBTransaction();
String where_grade = getCustomWhereClause(tx);
this.setBindingStyle(1);
writeLog("The binding style is: "+this.getBindingStyle());
writeLog("The where clause is: "+where_grade);
this.setWhereClause(null);
this.setWhereClauseParams(null);
this.setWhereClauseParam(0, where_grade);
//this.setWhereClause(where_grade);
String query = this.getQuery();
writeLog("The query is: "+query);
super.executeQuery();
I modified the where clause of the Query in the xml as (I added and vg.grade_id not in : 0 at the end of the where clause. The rest of it is the seeded one.):
job.job_group_id = jgr.job_group_id and jgr.internal_name = 'HR_'||:4 and (jgr.business_group_id = :5 or jgr.business_group_id is null) and job.business_group_id = :6 and :7 between job.date_from and nvl(job.date_to ,:8) and job.job_id=vg.job_id(+) and :9=:9 and :10 between nvl(vg.date_from(+),:11) and nvl(vg.date_to(+),:12) and hl.lookup_type(+)='YES_NO' and hl.lookup_code(+)=nvl2(vg.valid_grade_id,'Y',(decode(:13, -1,'', 'N'))) and pos.position_id(+)=:14 and job.job_id=pos.job_id(+) and :15 between nvl(pos.effective_start_date(+),:16) and nvl(pos.effective_end_date(+),:17) and vg.grade_id not in : 0
I could observe that there is another "and" condition that is getting appended at the run time which is AND (( UPPER(job.NAME) like UPPER( :2) ).
When I try to run the page, I am getting Missing IN OR OUT PARAMETER at index 3.
Could anyone please help me by letting me know the solution to this.
Thanks,
Srikanth
doSelect() is not related to view object functionality.
View Object's perform their own query, but coordinate via attribute mapping metadata, with underlying EO's.
doSelect() is invoked on an Entity instance when:
[list]
[*]The entity instance needs to lock its row in the database (the lock boolean flag will be true if this is the case)
[*]The entity instance needs to be faulted into memory either because of a findByPrimaryKey() in progress, or because business logic has referenced an attribute of the entity that was not already in the cache due to some view object's querying it.
[list]
Similar Messages
-
ExecuteQuery method of view object taking much time to execute
Hi All,
I am using a view object and execute the VO query using executeQuery method in VOImpl java.
But, problem is, it is taking long time to bring the results after executing the query after setting the parameters. Same query in TOAD gives 4 seconds. While executing using executeQuery method, it is taking 5 mins.
It is urgent issue. Please help me. Thanks.
Regards, SooryaHi Kali,
Thanks for your prompt response.
Yes. It has bind parameters. I have printed the statement before and after the executeQuery method
++VOImpl Code snippet++
setWhereClauseParams(params);
System.out.println("before executing query:Time:"+System.currentTimeMillis());
executeQuery();
System.out.println( "after executing query:Time:"+System.currentTimeMillis());
+++
I have removed some conditions in the query as it is business confidential. Please find the jdev log.
++++++++
before executing query:Time:1322071711046
[724] Column count: 41
[725] ViewObject close prepared statements...
[726] ViewObject : Created new QUERY statement
[727] ViewObject: VO1
[728] UserDefined Query: SELECT DISTINCT
ai.invoice_num invoice_num
FROM ap_invoices_all ai
, ap_checks_all ac
WHERE ...
ai.org_id = :p_orgid
AND ac.id = :p_id
[729] Binding param 1: ,468,
[730] Binding param 2: 247
[731] The resource pool monitor thread invoked cleanup on the application module pool, AM, at 2011-11-23 23:41:32.781
after executing query:Time:1322072052875
+++++++
Regards,
Soorya -
How to Override executeQuery() in VOImpl.java for simple search
Hi,
When I am going thorugh the dev guide I read that we can override the execute query to add more where conditions for a simple search with queryBean.
As per dev guide ,
If your view object's definition requires bind values, or you must manually append an unrelated WHERE clause every time the query is executed, you can proceed in one of two ways. In either scenario, OAFramework appends the user's search criteria to the WHERE clause immediately before executing the query,so any WHERE clause characteristics that you define are preserved.
1. Override the executeQuery() method in your *VOImpl to modify your WHERE clause and then call super.executeQuery(). This is recommended if you exercise the same logic every time the view object is queried.
2. Handle the generated Go button's press and call an initQuery() method on your view object where you can modify the WHERE clause and/or set bind values.
I didnt see the executeQuery() in my *VOImpl , am I missing anything here ? can you please help me to code the above ways of handling the execution.
I saw another exactly post in this forums and it didnt help much . (https://forums.oracle.com/thread/541807) .Shobhit,
Thank you so much for your help .
I tried like you said and its working . Below is the code I used please correct me if I am wrong or if there is a better way to do it.
In controller added the following code
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OADBTransaction oadbtransaction = am.getOADBTransaction();
oadbtransaction.putTransientValue("vnumber", "000016161");
In VOImpl added the following code
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
public void executeQuery()
OAApplicationModuleImpl oaapplicationmoduleimpl = (OAApplicationModuleImpl)getApplicationModule();
OADBTransaction oadbtransaction = oaapplicationmoduleimpl.getOADBTransaction();
String vnumber1 = (String)oadbtransaction.getTransientValue("vnumber");
setWhereClause("segment1 = nvl(:1,segment1)");
setWhereClauseParam(0, vnumber1);
super.executeQuery();
And ran the page everything working fine .
I have couple of questions
1. Is "oadbtransaction.putTransientValue " places the value is transaction cache ? If so is that value available across multiple pages ?
2. I see there is another option for the above using pageContext.putSessionValue and pageContext.getSessionValue, I am able to use the pageContext.putSessionValue in controller,
but I dont know how to use the pageContext.getSessionValue as I didnt see the pageContext in VOImpl and I tried to "import oracle.apps.fnd.framework.webui.OAPageContext" but still no use. -
Is not abstract and does not override abstract method actionPerformed
I dont how to corr. Please help!! and thank you very much!!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test extends JFrame implements ActionListener, ItemListener
private CenterPanel centerPanel;
private QuestionPanel questionPanel;
private ButtonPanel buttonPanel;
private ResponsePanel responsePanel;
private JButton b1,b2,b3,b4,b5; //Create five references to Jbutton instances
private JTextField t1,t2,t3,t4,t5; //Create five references to JTextField instances
private JLabel label1; //Create one references to JLabel instances
private JRadioButton q1,q2,q3; //Create three references to JRadioButton instances
private ButtonGroup radioGroup; //Create one references to Button Group instances
private int que1[] = new int[5]; //Create int[4] Array
private int que2[] = new int[5];
private int que3[] = new int[5];
private String temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10,
temp11, temp12, temp13, temp14, temp15;
public test (String header)
super(header);
Container container = getContentPane();
label1 = new JLabel ("PLease click on your response to ");
q1 = new JRadioButton("I understand most of the content of this subject",true);
add(q1);
q2 = new JRadioButton("I see the relevance of the subject to my degree",false);
add(q2);
q3 = new JRadioButton("The workload in this subject is appropriate",false);
add(q3);
radioGroup = new ButtonGroup(); //JRadioButton belong to ButtonGroup
radioGroup.add(q1);
radioGroup.add(q2);
radioGroup.add(q3);
JPanel buttonPanel = new JPanel();
JPanel responsePanel = new JPanel();
JPanel questionPanel = new JPanel();
JPanel centerPanel = new JPanel();
b1 = new JButton ("Strongly DISAGREE"); //Instantiate JButton with text
b1.addActionListener (this); //Register JButtons to receive events
b2 = new JButton ("DISAGREE");
b2.addActionListener (this);
b3 = new JButton ("Neither AGREE or DISAGREE");
b3.addActionListener (this);
b4 = new JButton ("AGREE");
b4.addActionListener (this);
b5 = new JButton ("Strongly AGREE");
b5.addActionListener (this);
buttonPanel.setLayout(new GridLayout(5,1));
buttonPanel.add(b1);
buttonPanel.add(b2);
buttonPanel.add(b3);
buttonPanel.add(b4);
buttonPanel.add(b5);
t1 = new JTextField ("0",3); //JTextField contains empty string
t2 = new JTextField ("0",3);
t3 = new JTextField ("0",3);
t4 = new JTextField ("0",3);
t5 = new JTextField ("0",3);
t1.setEditable( false );
t2.setEditable( false );
t3.setEditable( false );
t4.setEditable( false );
t5.setEditable( false );
responsePanel.setLayout(new GridLayout(5,1));
responsePanel.add(t1);
responsePanel.add(t2);
responsePanel.add(t3);
responsePanel.add(t4);
responsePanel.add(t5);
questionPanel.setLayout(new GridLayout(4,1));
questionPanel.add(label1);
questionPanel.add(q1);
questionPanel.add(q2);
questionPanel.add(q3);
centerPanel.add(buttonPanel,BorderLayout.CENTER);
centerPanel.add(responsePanel,BorderLayout.EAST);
container.add(centerPanel,BorderLayout.WEST);
container.add(questionPanel,BorderLayout.NORTH);
q1.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent e )
{ //actionPerformed of all registered listeners
if (e.getSource() == b1) {
que1[0] = Integer.parseInt(t1.getText()) + 1;
String temp1 = String.valueOf(que1[0]);
t1.setText(temp1);
else if (e.getSource() == b2) {
que1[1] = Integer.parseInt(t2.getText()) + 1;
String temp2 = String.valueOf(que1[1]);
t2.setText(temp2);
else if (e.getSource() == b3) {
que1[2] = Integer.parseInt(t3.getText()) + 1;
String temp3 = String.valueOf(que1[2]);
t3.setText(temp3);
else if (e.getSource() == b4) {
que1[3] = Integer.parseInt(t4.getText()) + 1;
String temp4 = String.valueOf(que1[3]);
t4.setText(temp4);
else if (e.getSource() == b5) {
que1[4] = Integer.parseInt(t5.getText()) + 1;
String temp5 = String.valueOf(que1[4]);
t5.setText(temp5);
} //end action performed
q2.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent e )
{ //actionPerformed of all registered listeners
if (e.getSource() == b1) {
que2[0] = Integer.parseInt(t1.getText()) + 1;
String temp6 = String.valueOf(que2[0]);
t1.setText(temp1);
else if (e.getSource() == b2) {
que2[1] = Integer.parseInt(t2.getText()) + 1;
String temp7 = String.valueOf(que2[1]);
t2.setText(temp7);
else if (e.getSource() == b3) {
que2[2] = Integer.parseInt(t3.getText()) + 1;
String temp8 = String.valueOf(que2[2]);
t3.setText(temp8);
else if (e.getSource() == b4) {
que2[3] = Integer.parseInt(t4.getText()) + 1;
String temp9 = String.valueOf(que2[3]);
t4.setText(temp9);
else if (e.getSource() == b5) {
que2[4] = Integer.parseInt(t5.getText()) + 1;
String temp10 = String.valueOf(que2[4]);
t5.setText(temp10);
} //end action performed
q3.addActionListener(
new ActionListener(){
public void actionPerformed( ActionEvent e )
{ //actionPerformed of all registered listeners
if (e.getSource() == b1) {
que3[0] = Integer.parseInt(t1.getText()) + 1;
String temp11 = String.valueOf(que3[0]);
t1.setText(temp11);
else if (e.getSource() == b2) {
que3[1] = Integer.parseInt(t2.getText()) + 1;
String temp12 = String.valueOf(que3[1]);
t2.setText(temp12);
else if (e.getSource() == b3) {
que3[2] = Integer.parseInt(t3.getText()) + 1;
String temp13 = String.valueOf(que3[2]);
t3.setText(temp13);
else if (e.getSource() == b4) {
que3[3] = Integer.parseInt(t4.getText()) + 1;
String temp14 = String.valueOf(que3[3]);
t4.setText(temp14);
else if (e.getSource() == b5) {
que3[4] = Integer.parseInt(t5.getText()) + 1;
String temp15 = String.valueOf(que3[4]);
t5.setText(temp15);
} //end action performed
}//end constructor test
public void itemStateChanged(ItemEvent item) {
//int state = item.getStateChange();
//if (q1 == item.SELECTED)
public class ButtonPanel extends JPanel
public ButtonPanel()
public class CenterPanel extends JPanel
public CenterPanel()
public class QuestionPanel extends JPanel
public QuestionPanel()
public class ResponsePanel extends JPanel
public ResponsePanel()
public static void main(String [] args)
test surveyFrame = new test("Student Survey") ;
surveyFrame.setSize( 500,300 );
surveyFrame.setVisible(true);
surveyFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
}//end main
}//end class testis not abstract and does not override abstract method actionPerformed
Oh, I see that the title of your post is an error message? Ok. Well, the test class is declared as implementing an ActionListener. That means the test class must have an actionPerformed() method. Your test class apparently does not.
It does not appear that the test class needs to implement ActionListener. You are using annonymous classes as listeners. -
Is not abstract and does not override abstract method tablechanged
I will remove all the gui code to make it shorter, but my problem lies with my InteractiveTableModelListener.
public class Meet extends JPanel{
private static void createAndShowGUI() {
JFrame frame = new JFrame("MEET_dataTable");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new Meet(), BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
public class InteractiveTableModelListener implements TableModelListener {
public void TableChanged(TableModelEvent evt) {
if (evt.getType() == TableModelEvent.UPDATE) {
int column = evt.getColumn();
int row = evt.getFirstRow();
dataTable.setColumnSelectionInterval(column + 1, column + 1);
dataTable.setRowSelectionInterval(row, row);
class InteractiveRenderer extends DefaultTableCellRenderer {
protected int interactiveColumn;
public InteractiveRenderer(int interactiveColumn) {
this.interactiveColumn = interactiveColumn;
public Component getTableCellRendererComponent(JTable dataTable,
Object value, boolean isSelected, boolean hasFocus, int row,
int column)
Component c = super.getTableCellRendererComponent(dataTable, value, isSelected, hasFocus, row, column);
if (column == interactiveColumn && hasFocus) {
if ((Meet.this.tableModel.getRowCount() - 1) == row &&
!Meet.this.tableModel.hasEmptyRow())
Meet.this.tableModel.addEmptyRow();
highlightLastRow(row);
return c;
public void highlightLastRow(int row) {
int lastrow = tableModel.getRowCount();
if (row == lastrow - 1) {
dataTable.setRowSelectionInterval(lastrow - 1, lastrow - 1);
else {
dataTable.setRowSelectionInterval(row + 1, row + 1);
dataTable.setColumnSelectionInterval(0, 0);
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
UIManager.put("swing.boldMetal", Boolean.FALSE);
createAndShowGUI();
}As i say, i have removed all the gui code to make it shorter, but in this code i create the table and add all the model to it. I am being returned with the error
Meet.InteractiveTableModelListener is not abstract and does not override abstract method tableChanged(javax.swing.event.TableModelEvent)in javax.swing.event.TableModelListener
what would be causing this error?
CheersSorry, just figured out my silly error, the method is tableChanged not TableChanged.
cheers
TOPIC CLOSED
Edited by: nick2price on Sep 11, 2008 7:08 AM -
Is not abstract and does not override abstract method ERROR
Hello. I'm new at all this, and am attempting to recreate a sample code out of my book (Teach Yourself XML in 24 Hours), and I keep getting an error. I appriciate any help.
This is the Error that I get:
DocumentPrinter is not abstract and does not override abstract method skippedEntity(java.lang.String) in org.xml.sax.ContentHandler
public class DocumentPrinter implements ContentHandler, ErrorHandler
^This is the sourcecode:
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
public class DocumentPrinter implements ContentHandler, ErrorHandler
// A Constant containing the name of the SAX parser to use.
private static final String PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
public static void main(String[] args)
// Check to see whether the user supplied any command line arguments. If not, print an error and exit.
if (args.length == 0)
System.out.println("No XML document path specified.");
System.exit(1);
// Create a new instance of the DocumentPrinter class.
DocumentPrinter dp = new DocumentPrinter();
try
// Create a new instance of the XML Parser.
XMLReader parser = (XMLReader)Class.forName(PARSER_NAME).newInstance();
// Set the parser's content handler
// parser.setContentHandler(dp);
// Set the parsers error handler
parser.setErrorHandler(dp);
// Parse the file named in the argument
parser.parse(args[0]);
catch (Exception ex)
System.out.println(ex.getMessage());
ex.printStackTrace();
public void characters(char[] ch, int start, int length)
String chars ="";
for (int i = start; i < start + length; i++)
chars = chars + ch;
System.out.println("Recieved characters: " + chars);
public void startDocument()
System.out.println("Start Document.");
public void endDocument()
System.out.println("End of Document.");
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
System.out.println("Start element: " + localName);
for (int i = 0; i < atts.getLength(); i++)
System.out.println(" Attribute: " + atts.getLocalName(i));
System.out.println(" Value: " + atts.getValue(i));
public void endElement(String namespaceURI, String localName, String qName)
System.out.println("End of element: " + localName);
public void startPrefixMapping(String prefix, String uri)
System.out.println("Prefix mapping: " + prefix);
System.out.println("URI: " + uri);
public void endPrefixMapping(String prefix)
System.out.println("End of prefix mapping: " + prefix);
public void ignorableWhitespace(char[] ch, int start, int length)
System.out.println("Recieved whitespace.");
public void processingInstruction(String target, String data)
System.out.println("Recieved processing instruction:");
System.out.println("Target: " + target);
System.out.println("Data: " + data);
public void setDocumentLocation(Locator locator)
// Nada
public void error(SAXParseException exception)
System.out.println("Parsing error on line " + exception.getLineNumber());
public void fatalError(SAXParseException exception)
System.out.println("Fatal parsing error on line " + exception.getLineNumber());
public void warning(SAXParseException exception)
System.out.println("Warning on line " + exception.getLineNumber());Check to make sure that the arguments are consistent with your ContentHandler class. Probably the wrong type.
I think you forgot to include the skippedEntity method, it seems to be missing. Even if an implemented class has a method that you are not using, you still have to include the method in your code even if it doesn't do anything.
Message was edited by:
ChargersTule1 -
...is not abstract and does not override abstract method compare
Why am I getting the above compile error when I am very clearly overriding abstract method compare (ditto abstract method compareTo)? Here is my code -- which was presented 1.5 code and I'm trying to retrofit to 1.4 -- followed by the complete compile time error. Thanks in advance for your help (even though I'm sure this is an easy question for you experts):
import java.util.*;
This program sorts a set of item by comparing
their descriptions.
public class TreeSetTest
public static void main(String[] args)
SortedSet parts = new TreeSet();
parts.add(new Item("Toaster", 1234));
parts.add(new Item("Widget", 4562));
parts.add(new Item("Modem", 9912));
System.out.println(parts);
SortedSet sortByDescription = new TreeSet(new
Comparator()
public int compare(Item a, Item b) // LINE CAUSING THE ERROR
String descrA = a.getDescription();
String descrB = b.getDescription();
return descrA.compareTo(descrB);
sortByDescription.addAll(parts);
System.out.println(sortByDescription);
An item with a description and a part number.
class Item implements Comparable
Constructs an item.
@param aDescription the item's description
@param aPartNumber the item's part number
public Item(String aDescription, int aPartNumber)
description = aDescription;
partNumber = aPartNumber;
Gets the description of this item.
@return the description
public String getDescription()
return description;
public String toString()
return "[descripion=" + description
+ ", partNumber=" + partNumber + "]";
public boolean equals(Object otherObject)
if (this == otherObject) return true;
if (otherObject == null) return false;
if (getClass() != otherObject.getClass()) return false;
Item other = (Item) otherObject;
return description.equals(other.description)
&& partNumber == other.partNumber;
public int hashCode()
return 13 * description.hashCode() + 17 * partNumber;
public int compareTo(Item other) // OTHER LINE CAUSING THE ERROR
return partNumber - other.partNumber;
private String description;
private int partNumber;
}Compiler error:
TreeSetTest.java:25: <anonymous TreeSetTest$1> is not abstract and does not over
ride abstract method compare(java.lang.Object,java.lang.Object) in java.util.Com
parator
public int compare(Item a, Item b)
^
TreeSetTest.java:41: Item is not abstract and does not override abstract method
compareTo(java.lang.Object) in java.lang.Comparable
class Item implements Comparable
^
2 errorsAccording to the book I'm reading, if you merely take
out the generic from the code, it should compile and
run in v1.4 (assuming, of course, that the class
exists in 1.4). I don't know what book you are reading but that's certainly incorrect or incomplete at least. I've manually retrofitted code to 1.4, and you'll be inserting casts as well as replacing type references with Object (or the erased type, to be more precise).
These interfaces do exist in 1.4, and
without the generics.Exactly. Which means compareTo takes an Object, and you should change your overriding method accordingly.
But this raises a new question: how does my 1.4
compiler know anything about generics? It doesn't and it can't. As the compiler is telling you, those interfaces expect Object. Think about it, you want to implement one interface which declares a method argument type of Object, in several classes, each with a different type. Obviously all of those are not valid overrides. -
Product is not abstract and does not override abstract method
Received the following errors.
Product.java:3: Product is not abstract and does not override abstract method ge
tDisplayText() in Displayable
public class Product implements Displayable
^
Product.java:16: getDisplayText() in Product cannot implement getDisplayText() i
n Displayable; attempting to use incompatible return type
found : void
required: java.lang.String
public void getDisplayText()
^
2 errors
Code reads as follows
import java.text.NumberFormat;
public class Product implements Displayable
private String code;
private String description;
private double price;
public Product()
this.code = "";
this.description = "";
this.price = 0;
public void getDisplayText()
String message =
"Code: " + code + "\n" +
"Description: " + description + "\n" +
"Price: " + this.getFormattedPrice() + "\n";
public Product(String code, String description, double price)
this.code = code;
this.description = description;
this.price = price;
public void setCode(String code)
this.code = code;
public String getCode(){
return code;
public void setDescription(String description)
this.description = description;
public String getDescription()
return description;
public void setPrice(double price)
this.price = price;
public double getPrice()
return price;
public String getFormattedPrice()
NumberFormat currency = NumberFormat.getCurrencyInstance();
return currency.format(price);
Please help!Received the following errors.
Product.java:3: Product is not abstract and does not
override abstract method ge
tDisplayText() in Displayable
public class Product implements Displayable
^
Product.java:16: getDisplayText() in Product cannot
implement getDisplayText() i
n Displayable; attempting to use incompatible return
type
found : void
required: java.lang.String
public void getDisplayText()
^
2 errors
Code reads as follows
Please use the code tags when posting code. There is a code button right above the text box where you enter your post. Click on it and put the code between the code tags.
These error messages are quite clear in telling what is wrong. You have an Interface called Displayable that specifies a method something like thispublic String getDisplayText() {But in your Product source code, you created thismethodpublic void getDisplayText() {The compiler is complaining because the methods are not the same.
You also need to return a String in the method probalby like thisreturn message; -
In Java it is simple to extend a class and override a method - the whole idea of polymorphism. In abap, I'm attempting to do the same, but don't know quite how. I've created as a demo a zclass and made a sap standard class its superclass in properties. How do I override a protected method from here?
Marcin says:
Unfortunatelly overriding is not possible in ABAP, only redefinition is allowed. The method singature must stay the same in all subsequent classes.
I guess,
Overriding - Redefinition of the implementation of inherited method. This is possible by addition REDEFINITION to the method.
Overloading - Changing the method parameters of inherited method
Regards,
Naimesh Patel -
How to override a method in an inner class of the super class
I have a rather horribly written class, which I need to adapt. I could simply do this if I could override a method in one of it's inner classes. My plan then was to extend the original class, and override the method in question. But here I am struggling.
The code below is representative of my situation.
public class ClassA
ValueChecks vc = null;
/** Creates a new instance of Main */
public ClassA()
System.out.println("ClassA Constructor");
vc = new ValueChecks();
vc.checkMaximum();
// I want this to call the overridden method, but it does not, it seems to call
// the method in this class. probably because vc belongs to this class
this.vc.checkMinimum();
this.myMethod();
protected void myMethod()
System.out.println("myMethod(SUPER)");
protected class ValueChecks
protected boolean checkMinimum()
System.out.println("ValueChecks.checkMinimum (SUPER)");
return true;
protected boolean checkMaximum()
return false;
}I have extended ClassA, call it ClassASub, and it is this Class which I instantiate. The constructor in ClassASub obviously calls the constructor in ClassA. I want to override the checkMinimum() method in ValueChecks, but the above code always calls the method in ClassA. The ClassASub code looks like this
public class ClassASub extends ClassA
public ClassAInner cias;
/** Creates a new instance of Main */
public ClassASub()
System.out.println("ClassASub Constructor");
protected void myMethod()
System.out.println("myMethod(SUB)");
protected class ValueChecks extends ClassA.ValueChecks
protected boolean checkMinimum()
System.out.println("ValueChecks.checkMinimum (SUB)");
return true;
}The method myMethod seems to be suitably overridden, but I cannot override the checkMinimum() method.
I think this is a stupid problem to do with how the ValueChecks class is instantiated. I think I need to create an instance of ValueChecks in ClassASub, and pass a reference to it into ClassA. But this will upset the way ClassA works. Could somebody enlighten me please.vc = new ValueChecks();vc is a ValueChecks object. No matter whether you subclass ValueChecks or not, vc is always of this type, per this line of code.
// I want this to call the overridden method, but it does not, it seems to > call
// the method in this class. probably because vc belongs to this class
this.vc.checkMinimum();No, it's because again vc references a ValueChecks object, because it was created as such.
And when I say ValueChecks, I mean the original class, not the one you tried to create by the same name, attempting to override the original. -
The equals method accepts Object as the parameter. When overriding this method we need to downcast the parameter object to the specific. The downcast is not the good idea as it is not the OO. So can anyone please tell me how can we override the equals method without downcasting the parameter object. Thank you.
For comparing the objects by value overriding the equals method what I did is like this
public boolean equals(Object o){
if( o instanceof Book){
Book b = (Book)o;
if(this.id == b.id)
return true;
return false;
}But in the above code I have to downcast the object o to the class Book. This downcasting is not a good as it is not Object-Oriented. So what I want to do is avoid the downcasting. So any idea how to do it? -
How to override ExecuteWithParms method?
How I can override ExecuteWithParms method?
as when click on execute button there are many parameters should return result from another table
as select query from different table, can i do this? and how??thanks Timo. this is more detail
I have two table Fundemental and Emails and I have many search parameters
so I need to make custom adf search when click on execute search, get result from all search parameters
so i need to override executeWithParms to change return value when search in pEmail parameter
to return "ID_NO IN (SELECT PERSON_CODE FROM EMAILS WHERE EMAIL LIKE '%" + getpEmail() + "%')"; -
How to override toString() method ?
class Test
String x[];
int c;
Test(int size)
x=new String[size];
c=-1;
public void addString(String str)
x=new String
x[++c]=str;
public void String toString()
// i want to override toString method to view the strings existing in the x[]...
// how do i view the strings ?
// probabily i should NOT use println() here (..as it is inside tostring() method ..right? )
// so i should RETURN x[] as an array...but the toString() method return type is String not the String array!.
// so i am in trouble.
so in a simple way my question is how do i override toString() method to view the Strings stored in the array ?
i am avoiding println() bcoz of bad design.
}AS you said, the toString method returns a String - this String is supposed to be a representation of the current instance of your class's state. In your case, your class's state is a String array, so you just pick a format for that and make a String that fits that format. Maybe you want it to spit out something like:
Test[1] = "some string"
Test[2] = "some other String"If so, code something like:public String toString() {
StringBuffer returnValue = new StringBuffer();
for (int i = 0; i < x.length; i++) {
returnValue.append("Test[" + i + "] = \"" + x[i] + "\"";
return returnValue.toString();
} If you don't mind the formatting of the toString method that Lists get, you could just do something like:public String toString() {
return java.util.Arrays.asList(this).toString();
} and call it good. That will print out something like:
[Some String, another String, null]Depending on what's in your array.
Good Luck
Lee -
How to override truncateToFit method for SuperTabNavigator
Hi All,
How to override truncateToFit method for SuperTabNavigator.
we have editableLabel method for changing the tab name.
it is dispalying the ... elipse when entered characters grater than the tab width. it is ok.
but if the entered characters less than the tab width it is also appending the ... elipse.
i dont want that . how to remove those. i dont want completely truncateToFit option.
how to override .
Can any help me regarding this?
Thanks in Advance
Raghu.Give me a sample codeNo. Read the links provided by Yannix, try it out for yourself, and if you still have a question, post the code you tried.
db -
Overriding Interface methods via JNI
Hello,
How we can override Interface methods via JNI?
For example:
At HelloWorldSwing example:
http://download.oracle.com/javase/tutorial/uiswing/examples/start/HelloWorldSwingProject/src/start/HelloWorldSwing.java
I've written anonymous Interface as:
import javax.swing.*;
public class HelloWorldSwing1 {
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
//Display the window.
frame.pack();
frame.setVisible(true);
static Runnable runnableObject = new Runnable() {
public void run() {
createAndShowGUI();
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
SwingUtilities.invokeLater(runnableObject);
}via JNI functions(http://download.oracle.com/javase/1.4.2/docs/guide/jni/spec/functions.html) we cannot override Runnable Interface's run method? Can we?
Only:
RunnableClass's value isn't null with given example at below. FindClass finds the Runnable Interface.
jclass RunnableClass;
RunnableClass = (*env)->FindClass(env,"java/lang/Runnable");
if( RunnableClass == NULL ) {
printf("can't find class Runnable\n");
exit (-1);
}But How can we override Runnable class's run method?
Thanks in AdvanceThe only way you can override a method in Java is by defining a class that does so, either statically or as an anonymous inner class. You can't do either of those things in JNI. Ergo you cannot do what you are asking about.
Maybe you are looking for
-
My computer died and I have a new one. How do i Authorize my new computer to synch the content of my iPod?
-
GUI_UPLOAD - Problem in uploading xml file
Hi, I have problem in uploading xml file into itab. Here is the code begin of GS_STRING, STR(72) type C, end of GS_STRING, GT_STRING like standard table of GS_STRING, call function 'GUI_UPLOAD' EXPORTING FILENAME
-
How to check particular error in alert log file
Hi all, How to check particular error in alert log file,for supose if i get error in batabase yesterday 4 pm & today i want to check alert log file to get basic idea..it might be a big file so how to check that particular error.. Thanks & regards, Es
-
I am trying to download the 30 day free trial of lightroom
I'm trying to download the 30 day free trail of lightroom & photoshop before I purchase it. I can't seem to get it to download. I am not using Mac or Windows, I am using a Samsung Chromebook. Any help for downloading these to my Chromebook will b
-
I want to download the CD music that i already have on the computer to my ipod, but I don't know how to do that with or without itunes. Can someone please help me figure this out cause it will drive me nuts if I will have to rebuy through itunes. I d