473,805 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java reflection

10 New Member
I need to check a property in the javax.faces.com ponent.html.Htm lInputText.
If i do it in the following manner,I get things fine:
if(comp.getClas s().getName().e qualsIgnoreCase ("javax.faces.c omponent.html.H tmlInputText")) {
String getter=((javax. faces.component .html.HtmlInput Text)comp).getO nfocus();
if(getter!=null ) {
System.out.prin tln(getter);

}

}

But if i invoke it through reflection,I get nothing.
I am doing the following:
Class reqClass = Class.forName(" javax.faces.com ponent.html.Htm lInputText");
Method[] methodList = reqClass.getDec laredMethods();
int methodIdx = 0;
for (int i = 0; i < methodList.leng th; i++) {
Method reqMethod =methodList[i];
if(reqMethod.ge tName().indexOf ("getOn")== 0) //method starts with getOn
{

// method accepts parameters, define the types in order here as Class[]
Class[] classParams = new Class [] {};
// set the method of the class object
Method method = reqClass.getMet hod( reqMethod.getNa me(), classParams );

// pass values to fill parameters of method
Object[] arguments = new Object [] {};
// invoke method via reflection.Note that class has default constructor
Object retobj=method.i nvoke( reqClass.newIns tance() ,
arguments );

String getterResult = (String)retobj;

if(getterResult !=null)
{
System.out.prin tln(reqMethod.g etName() + " ## " + getterResult);
}
}
}

What am i doing wrong while invoking the method through reflection.
I get no exception either.
Mar 1 '07 #1
0 1464

Sign in to post your reply or Sign up for a free account.

Similar topics

8
10851
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the absolute file name of a .class file eg. C:\myJava\myApp.java, then how do i translate this file name to a java class name the Object.forName method would accept has it's parameter? thanks,
0
2011
by: ws_dev2001 | last post by:
Hello all, I am trying to obtain the size of a java object in C by using JNI. As we do not have a proper implementation of this in java, I decided to see if C could provide me some accurate data. As in java, C does provide accurate sizeof for primtives and can even handle String objects received from java. In java reflection, we cannot find/estimate the length of the string with as much ease as it is in C via JNI. Sizeof impl in C seem...
3
1828
by: Lucia | last post by:
Hello, I'd like store all constants in my java-Application in an XML-file. e.g. <constant> <name>con</name> <type>long</type> <value>10</value> </constant>
13
472
by: Moonraker | last post by:
After working extensively with .Net and Java, these are the differences I see: Java does not have Reflection.Emit But it does have Reflection. That's okay so far, because most programmers are too dumb to use Reflection.Emit. Visual Studio .net is the easiest way to create web services.
21
3011
by: Martin Demberger | last post by:
Hi, I'm working on an article about compiling java-sources to c++. I'm interessted if someone would use this to write a program in java (and the good IDE's available for java) and convert this to C++ to get the advantages and speed of this language. mfg Martin Demberger
2
1887
by: ws_dev2001 | last post by:
Hello all, I am trying to obtain the size of a java object in C by using JNI. As we do not have a proper implementation of this in java, I decided to see if C could provide me some accurate data. As in java, C does provide accurate sizeof for primtives and can even handle String objects received from java. In java reflection, we cannot find/estimate the length of the string with as much ease as it is in C via JNI. Sizeof impl in C seem...
7
3097
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything works fine. So I deploy the webservice on a remote machine (Linux box) and I get an error when calling the service. BUT: I can retrieve the WSDL and make a webreference in my VS.NET project, so obviously I (or more correct: My VS.NET project) am...
2
6971
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
1
1413
by: kenneth6 | last post by:
I read a Java class example on tutorial book. What is the part marked with asterisks doing? What is "create reflection of element" in java? Any analogy in C++? its structure is like the following: public class Element { ............................... .......blabla.......blabla ............................... declare variables
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.