Getting an object's field name

In the snippet of code shown below, 'parent' represents a UI dialog, and 'child' represents one of the components of the dialog. What I would like to know is the field name of 'child'. The variable 'fieldName' would contain the name I am seeking, if I knew how to determine the value of 'ii' that corresponds to the object 'child'.
I hope you can help.
Thanks,
Miguel
String getFieldName(Object parent,Component child) {
Class cl = parent.getClass();
Field [] fields = cl.getDeclaredFields();
String fieldName = fields[ii].getName();
// problem: how to get 'ii' that corresponds to 'child'?
return fieldName;
}

Is there a way to get the
corresponding array of component objects? It depends on the way the "parent" class is defined.
For example (a BAD example, but an example):
I could have the parent keep it's components in a HashMap, with a key of the component type and a value of an ArrayList that contains each component matching the component type.
This would be very annoying to deal with, and hard to find any given component (whether reflectively or with normal code).
If I can get
the value of a field (Object val =
field.get(parent);), there must be a way to get the
reference to the object that correspond to the pair
'field','parent'.
Thanks.Huh?
What do you think field[1].get(parent) returned?
It's the value that the field is referring to (e.g. the actual object refered to by the field).
I think dubwai's questions about "what are you trying to do" are very relevant. Using reflection like this usually means the design is lacking some important functionality

Similar Messages

  • How to get the object class field value in CDHDR table for vendor

    hi
    how to get the object class field value in CDHDR table for vendor

    Try KRED/KRED_N as object class in CDHDR for Vendor.

  • How to get POF object's field value from query result

    hi,all:
    I want to get field value from the query result, my code is below
    Set setResults = cache.entrySet(createFilter("homeAddress.state = 'MA'"));
    for (Iterator iter = setResults.iterator(); iter.hasNext(); )
    Contact c=(Contact)iter.next();
    System.out.println ("firstame####=" + c.getFirstName());
    * but I get error*
    Exception in thread "main" java.lang.ClassCastException: com.tangosol.util.ConverterCollec
    tions$ConverterEntrySet$ConverterEntry cannot be cast to com.oracle.handson.Contact
    at com.oracle.handson.QueryExample.printResults(QueryExample.java:159)
    at com.oracle.handson.QueryExample.query(QueryExample.java:86)
    at com.oracle.handson.QueryExample.main(QueryExample.java:43)
    who can tell me how to get POF object's field value from query result

    Hi,
    If you look at the Java Doc for the entrySet method here http://download.oracle.com/docs/cd/E15357_01/coh.360/e15725/com/tangosol/util/QueryMap.html#entrySet_com_tangosol_util_Filter_ you will see that it returns a Set of Map.Entry instances so you need to do this...
    Set setResults = cache.entrySet(createFilter("homeAddress.state = 'MA'"));
    for (Iterator iter = setResults.iterator(); iter.hasNext(); )
        Map.Entry entry = iter.next();
        Contact c=(Contact)entry.getValue();
        System.out.println ("firstame####=" + c.getFirstName());
    }JK

  • How can i get value when the field name is user's defined

    Hi,
    I have a one java method:
    public ResultSet countUserDb(String id) {
    ResultSet rs = null;
    con = dbcon.connect();
    String queryString = ("select count as count from
    db_allocation where user_id='"+id+"'");
    Statement stmt = con.createStatement();
    rs = stmt.executeQuery(queryString);
    When i call it in a jsp file.
    ResultSet counter =db.countUserDb(request.getParameter("id"));
    if(counter.next())
    int x=rs.getInt("count");
    Tomcat said incorrect column name.How can i get the result set when the field name is user's defined.
    Best regards
    Ricky

    You should give the user defined name in the ResultSet.getXXX method to retrieve the column value.
    Example
    SQL:
    Select ename as employeename from emp;
    You should say :
    ResultSet.getString("employeename"); to get the value.
    Alternatively you can retrieve it using column number:
    ResultSet.getString(1);
    Chandar

  • How to get description from the field name

    Hello fellow SAP Fanatics,
    I am trying to find an easy way to get the description of a field if I know the technical name. I know I can view them in tables but is there one place where I can just look up the field and get the description?
    Thanks.

    Hello
    For all the tables, descriptions and fields you can refer to these tables:
    DD02L : ALL SAP TABLE NAMES
    DD02T : DESCRIPTION OF TABLE NAMES
    DD03L : FIELDS IN A TABLE.
    Moreover you can always goto the menu on the selection screen of the table and goto Settings > User Parameters > Key word > Field name / label
    Hope this helps

  • How to get the database table field names from program

    Hi,
    Can any one tell me,whether any function module is there which can get the table field name and its details ,when we pass database table name to it.
    Thanks in Advance
    <REMOVED BY MODERATOR>
    Regards
    Shibin
    Edited by: Alvaro Tejada Galindo on Feb 14, 2008 12:41 PM

    Hi,
    DD02L Table contains the SAP Tables.
    DD02T Table contains the SAP Table Texts.
    DD01L Table contains the Domains
    DD01T Table contains the Domain Texts.
    DD03L Table contains the Table Fields.
    DD03T Table contains the Table Field Texts. (Language Dependent)
    DD04L Table contains the Data Elements.
    DD04T Table contains the Data Element Texts.
    DD05s Table contains the Foreign Key Fields
    last words with L and T only. L->Database Fetch T-> Text
    For ur question use table DD03L or DD03T.
    Regards,
    Chandru

  • How to get extended object id (field OBJEC-REALO)

    Hi,
    anybody knows  where extended object id are stored, or how can I get this value? I have object id but i also need extended objetc value. I suppose that a function module exists to get this value, but I didn't find it.
    My program doesn't use PCH logical database, so it isn't an option for me
    Any idea, thanks in advance

    I answer to myself, FM HR_MACO provides the information I need.
    Anyway thanks for the interest

  • How to get error's field name when execute sql error

    I want to get the error's field name when execute sql error,but SQLException is not provide corresponding function to get it.
    How can I do for it?

    user523110,
    I believe the "unique constraint" error message displays the name of the constraint, not the column name, as you have posted.
    As far as I know, the only way to extract the column(s) would be to query the data dictionary using the constraint name provided in the error message.
    Also, as far as I know, there is nothing in the JDBC API that can return the names of the columns associated with a given unique constraint.
    Good Luck,
    Avi.

  • Object Indicator field in Report painter

    we are looking for some field details in RWCOOM table like object indicator. There is object indicator field name in CCSS table. We want to ignore planned cost of service orders from the project planned cost as there is already planing of cost at project level. The same cost element is used for cost planning in Project builder and service order
    Please provide us some option where we can restrict planned cost of the
    orders other than network to show in project reports.
    Thanks & Regards,
    Ranjan

    In general data selection, i have already cost center, but it is not apprearing at selection screen. Only three field are appearing (Year + Period + Forecast),  and i want to add cost center at the selection screen. How to make cost center field at selection field from General data selection option. Please guide me
    Thank in stack
    Nilesh Shete

  • Field name DUMMY is reserved (Do not use structure as include in DB table)

    We are trying to add a custom field, e.g., called ZZZ in LIS Communication structure MCEKKO (Purchasing Document Header) by creating a new custom append structure and add the field ZZZ into it, then activate the new append structure, but get warning msg like "Field name DUMMY is reserved (Do not use structure as include in DB table)".
    We do find a field called DUMMY in the structure MCEKKO. How to get rid of the warning msg and successfully activate the new custom append structure with the new field ZZZ?
    We will give you reward points for correct solutions for the above problem!
    Thanks

    hi Dinesh,
    But we wonder why this new custom field appended can not be seen from the right frame of the extraction structure in LBWE?
    Any idea?
    Thanks

  • Crystal 8.5 - now 9 - report in VB6 gives "This field name is not known"

    Hi,
    I've got to do some maintenance on an old VB 6.0 project that had some Crystal 8.5 reports in it (DSR files).
    I only had Crystal 9.0 (developer edition) available, so am using that.
    Running one report I now get the error "This field name is not known".
    Q1. How can I find out what field - and where in the report it is?
    Q2. Is there anything special I should have done to "upgrade" the DSR/DCA and DSX files?
    Thanks,
    Details:
    The reports are not "visual", they are created within a DLL that saves them as PDF's and/or prints them directly.
    The reports are bound at run-time to recordsets; at design time they use field definition files (TTX). I believe I've made sure the field definitions match the recordsets that they represent.

    Hi,
    Thanks for your replies.
    Falk:
    Nothing in particular was done to upgrade the files, other than to upgrade the VB project to reference the Crystal 9 dll's and such instead of Crystal 8.5.
    The Crystal reports designer does not seem to want to open a DSR file. I did find some RPT files in the project; but while the Crystal reports designer will load them it does not seem to want to save as DSR files.
    The "Field name is not known" message is returned in the error raised when VB tries to run the report, and it stops the report from being built.
    Ludek:
    That's a good kbase article. I had actually guessed that was an issue and had fixed two of the three reports in this project, by dumping (to text files) the recordsets being bound to them and comparing real field names with the TTX files. (I also updated some of the custom formulas in the reports to match the proper names).
    ...but in the third report, I just couldn't find the mis-match; checking the recordsets, TTX files and any customisable formulas I could locate.
    As for the patch - after installing it the report designer no longer works at all in VB6 - not for the reports that I had got working, nor even for a new report!
    (added: actually I can't get any designer up, even the VB forms designer won't load, in a project with no Crystal in it...)
    At this point I "give up".
    VB Express 2008 was used to "upgrade" the VB project to .Net and then convert the DSR's to new format RPT's. They were then loaded into a fresh VS 2008 (C#) project.
    I'm now at the point of trying to figure out how to put in the report events that were in the old DSR files in the original VB project (there is code in them to assign the recordsets as sources, at run time, and calculate and make available information from the report).
    Thanks again,
    Edited by: pzkpfw on Aug 14, 2008 12:19 AM clarify
    Edited by: pzkpfw on Aug 14, 2008 12:21 AM
    Edited by: pzkpfw on Aug 14, 2008 5:16 AM

  • Which table stored  description for field name

    hi,
    for example,
    field name is  LIFNR , description (vendor number),
    which table stored this description (vendor number)  for that field name(LIFNR) ?

    1. From table DD03L, give your tablename and get all of its field names and corresponding data element names. 
    2. From table DD03T, get the description of each data element you have got in step 1. 
    3. Then Use Function Module DDIF_FIELDINFO_GET 
    DD02L : ALL SAP TABLE NAMES
    DD02T : DESCRIPTION OF TABLE NAMES
    DD03L : FIELDS IN A TABLE.
    Check the below link for more information.
    http://www.sap-img.com/abap/how-to-get-the-field-descriptions-of-a-table.htm
    Thanks,
    Balaji

  • The field name is not known error

    Hi,
    I have a report that is pointing to database(db1).
    Can i change the database name to database(db2) in my c# application?when i am changing to new database name in my application i am getting error as "field name is not known".
    Please give some suggestions.
    Thanks in advance

    I'm having the same problem.
    I've upgraded from Crystal 8.5 to Crystal XI.
    I've converted all my reports from Crystal 8.5 to Crystal XI.
    When I try to run the report I get the error:
    The Field Name is not known and nothing else.
    I did upgrade the report and verified the database.
    Does anyone have any ideas ?
    If I delete the formula, and after I create it (by handle) the report will good.
    But I have about 1000 reports !

  • This Field Name is not Known

    Hi,
    I have created 4 individual crystal report connecting 4 individual excel sheets.
    I tried to build a single crystal report embedding all the 4 individual CR.
    I am getting error as "The field name is not known"
    I searched forum , however i didnt got appropriate solution.
    Appreciate your feedback to fix the issue

    I have made connection to 4 excel sheets and linked the common fields.
    However still i am getting same error.
    When i connect it was asking to prevent server side grouping. I m confused how to rectify the error
    Appreciate your inputs

  • CRVS2010 Beta - Sporadic "This field name is not known. Details: errorKind"

    I am running CRVS2010 Beta 2 on the VS2010 trial version. I have been converting reports to this new version, but sometimes I get the error:
    This field name is not known. Details: errorKind Error in File XX11X1 {1X1111X1-1XX1-1X1X-111X-11111111X11X}.rpt: Error in formula tot-appr: '{@commited0}+{XX11X.AMT1} + {XX11X.AMT2} + {XX11X.AMT3} + {XX11X.AMT4} + {XX11X.AMT_FUT} ' This field name is not known. Details: errorKind
    I have done a lot of searching on this forum, Google, and Bing, but it seems everyone who receives this error message has just created the report or moved it to a new database, and the error is caused by a mis-pointed formula. I don't have that problem: in my case, the report usually works.
    I have tried querying the Oracle database immediately after receiving this error, and all the fields mentioned do exist, exactly where they ought to. The problem never exists when logging on with my own account, and sometimes works when logging on with other accounts, but I have not figured out a way to predict whether it will work or not.
    I have four reports I am running: one always works, two get this sort of error sometimes, and one (which is formatted differently) always shows up without errors, but is sometimes inexplicably blank. I cannot figure out in what way the report that always works is different from the two with this error (aside from obvious issues of layout and querying different tables, I mean).
    I'm at a loss for where to look next. I know this information won't be enough as-is, but I hope that your clarifying questions can help me find the error.
    Thank you for your consideration.
    EDIT: changed database names in case I get in trouble for revealing proprietary information, even though I don't think it's likely
    Edited by: sschaffer on Oct 25, 2010 9:57 PM

    Hello,
    Are you using a data Set? I believe the System.Data.OracleClient is the .NET Oracle client but not sure and not sure how reliable it is or what it's based on.
    What happens if you create a new report using the DataDirect OLE DB provide or Oracles OLE DB provide or use CR Oracle native driver?
    In the Connection Wizard select Oracle, that's the native driver, then when set log on info you just specify the Server name, User and PW, leave the database blank.
    Then what API's are you using to connect/set the log on info?
    I'm guessing that the error you are getting is likely an indexing problem in the table names etc. but not sure. if you search in this forum on "crlogger.dll" you could enable our database logging component and it may give you more info on what the cause is.
    Thank you
    Don

Maybe you are looking for

  • HT1368 Wish list for iTunes app on iPhone 4s?

    Movies are too large to download through 3G, so I love to browse iTunes. It would be great to add movies, I want to buy later at home from my iMac, to a wish list. But where is it on the iPhone 4s? If it's not there, I hope Apple could please add it?

  • Iphone died, need to retreive contacts data from itunes ? any advice welcome.

    hello, so the story goes that my iphone just stopped working last weekend. my contacts are in my itunes i hope, as it often sync'd. so how do i retrieve my contacts into a format that i could use on another phone ? i currently have an android as a re

  • Sending e-mail alerts in Microsoft Project 2010

    I'm using Microsoft Project 2010 in creating my project. While adding my tasks I want to be able to send an e-mail alert to my resources indicating a task is coming up or the task is overdue. What do I have to do?

  • Airport Express Ethernet for TV ?

    Will this work ? Got a Time Capsule as my router linked to an Airport Express in another room to boost the signal - this works great. My new TV has an ethernet input and is positioned next to the airport express. Could I plug an ethernet cable into t

  • Lost my HD icon in Finder

    I have anew iMac and i dragged my HD icon to the desktop (since there was no icon there) and I lost it in finder. Also, it is not there on the desktop. How do I get it back?