Dynamic display of class name

I have already posted this problem in the "New To java" forum but then considered that it might be more complicated than I expected. Problem is I am trying to construct a toString method that displays the class name but I wish to be able to extend the class and override the toString method. Then the overridden method must display the new class name. I have a feeling that I need to make a separate method to do this but I just can�t get my head around how to get the class name without hard coding it.

Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

Similar Messages

  • Dynamic Creation of Class Name

    I just want to create the class name on the fly.
    Look the example below.
    String className = "gui.Header";
    className header = new className;
    Let's assume that there is a Header class somewhere.
    Is this possible? or is there a way to do this?

    From what i understand, u wish to create an instance of a class whose name is known to you at runtime - correct me if i'm wrong - i'll answer based on my assumption. You can basically do that using Reflection in Java. I'm pasting sample code which shows how you do this:
    The following sample program creates an instance of the Rectangle class using the no-argument constructor by calling the newInstance method:
    import java.lang.reflect.*;
    import java.awt.*;
    class SampleNoArg {
    public static void main(String[] args) {
    Rectangle r = (Rectangle) createObject("java.awt.Rectangle");
    System.out.println(r.toString());
    static Object createObject(String className) {
    Object object = null;
    try {
    Class classDefinition = Class.forName(className);
    object = classDefinition.newInstance();
    } catch (InstantiationException e) {
    System.out.println(e);
    } catch (IllegalAccessException e) {
    System.out.println(e);
    } catch (ClassNotFoundException e) {
    System.out.println(e);
    return object;
    Hope the above helps.
    John Morrison

  • Dynamic display of the Company Name based on Org

    Hello All,
    I need to dynamically display the Company name based on the Org_id and the ORG is not being populated in the XML data file. How do i achieve this,please let me know.
    Thanks
    Rakesh

    Rakesh,
    It's like getting something from nothing (data template)... If you do not want to modify your report, then Vetri's option will be fine(your going to add not modify)...
    Or,. define a new Oracle report based on the seeded one then do modify...
    regards,
    Rownald

  • Dynamiclally retreiving the main class name

    Hi Folks,
    I would like to dynamically retrieve the class name of the main class which was invoked. Lets say my class name is HelloWorld. I run it using
    java HelloWorld
    Now I need to dynamically retrieve the Classname (HelloWorld) using a java program. Can any please let me know how to achieve it.
    Regards,
    PA

    georgemc wrote:
    Someone else asked this very recently, but I'm bugggered if I can remember the answer. Well, the most common answer was "Why d'you need to do this?" but someone actually knew how to do it. I think it involved the instrumentation API, but I might be wrong. Pretty sure it wasn't anything to do with reflection, thoughYou are just soooooooooooooo sarcastic, George! I am gonna get one of the moderators out after you ... so watch your step! Regards,
    ~Bill

  • AS3 - dynamic class names with *new* operator

    I'm using AcrtionScript 3 and Adobe Flash 9 Public Alpha.
    I have 50 movie clips in the Library that use Linkage to set
    the Class name to: Img1, Img2, Img3, ..., Img50.
    I have a parent class named RandImg. I want the constructor
    for RandImg to randomly select one of the 50 movie clips from the
    Library and display it. I could get this working by generating a
    random number, and then writing a really huge switch statement to
    associate each possible random number with its respective Library
    Movie Clip Class name, but I would much rather do this with a
    dynamic/variable class name based on the random number, such as:
    var nImgChoice:Number = Math.floor( Math.random( ) * 50 ) +
    1;
    var mcImg:MovieClip = new [ "Img"+String(nImgChoice) ] ( );
    addChild( mcImg );
    Note that this used to be possible in AS 2 by doing the
    following:
    this.attachMovie( "Img"+String(nImgChoice) , "mcImg",
    this.getNextHighestDepth());
    Suggestions?
    Thanks,
    ~JC

    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.utils.getDefinitionByName;
    var nImgChoice:Number = Math.floor( Math.random( ) * 50 ) +
    1;
    var ClassReference:Class =
    getDefinitionByName("Img"+String(nImgChoice) ) as
    Class;
    var instance:Object = new ClassReference();
    addChild(DisplayObject(instance));

  • Dynamic display name of the sender

    I have requirement like below:
    After creating and executing any Agent/iBOt in OBIEE 11g, the Display Name of the Sender in the From address of email delivered to recipients is showing as "Administrator".
    The user who is authenticated and authorized into the OBIEE also created an agent, he is asking that email should show his name in the From Address when it is delivered to the recipients.
    I know why this is happening, I have provided the Display Name of Sender as "Administrator" while configuring the Agents at the Enterprise Manager Level.
    What I am currently looking is, if there is any alternate solution to Dynamically display the name of the user who creates the Agent in the From address of the email when it is delivered to the recipients.
    Thanks in advance
    -Bharath

    Any body there with the answers !!

  • HOW TO GIVE CLASS NAME DYNAMICALLY???

    Hi all!
    I want to give class name dynamically to my statment
    <jsp:useBean id="myBean" scope="session" class="myPackage.myClass"/>
    now here i want to pass a String as class name how can i do it?
    Jiaa:):):)

    Hi,
    You can't assign dynamically a classname in the instruction jsp:useBean
    S�b

  • Need class name to display ALV list (not Grid) in objects..

    hi,
    i need to display ALV list ( not ALV Grid ) in objects.. i dont the class name for tat.. so plz can anyone help me out for the same..
    thanks in advance..

    With cl_salv_table you can have both grid or list, depending what you want.
          cl_salv_table=>factory(
             EXPORTING
               list_display   = 'X'  "when space then GRID, when 'X' then LIST
             IMPORTING
               r_salv_table  = ref_table
             CHANGING
               t_table       = gt_sflight ).
    Regards
    Marcin

  • How to get the class name and field name dynamically

    Hi
    I have a class (ex: Contract) the fields (ex : a,b,c) .i need to get the class name and field name dynamically
    ex
    if( validation file for the field Contract.a){
    return contract.a;
    }else if(validation file for the field Contract.b){
    return contract.b;
    how to pass the field name and object dynamically
    Please help me .............
    Thanks in Advance..
    Edited by: 849614 on Aug 11, 2011 6:49 AM

    YoungWinston wrote:
    maheshguruswamy wrote:
    Agreed, but IMO, i still feel its best if there is no tie in between consumer class level details and the database it talks to. A service layer is needed in between them.Sounds like you've done a bit of this before. Me, I've either been a modeller/DBA, doling out data, or a nuts and bolts programmer (and actually more toolmaker than apps, but did a bit of that too).
    Do you know of a good book about the "middle ground" (ie, these service layers)? I understand it empirically, but haven't had a lot of exposure to it.
    Winston
    Edited by: YoungWinston on Aug 11, 2011 10:34 PM
    PS: Apologies. Edited my previous post, presumably while you were composing your reply, when I finally realized what '.filed' meant.Most of my work is in web development, never been a DBA :) . The biggest 'concern' in my shop is 'separation of concerns'. The UI group reports up to a different IT head, the DB group reports up to a different IT head and so on. The looser the coupling between these systems, the lesser the project costs (Integration, QA etc) are. Martin Fowler's books contain good information about separation of concerns in an enterprise environment. The two books which i recommend are
    [url http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420]Enterprise Application Architecture and
    [url http://www.amazon.com/Enterprise-Integration-Patterns-Designing-Deploying/dp/0321200683/ref=pd_sim_b_1]Enterprise Integration Patterns

  • Class.forName() doesn't take dynamic class name

    String name="";
    String country="";
    String className = name + "_" + language + "_" + country;
    Class thisClass = Dynamicclassload.classLoad(className);
    System.out.println(className);
    Class class1 = Class.forName(className);
    child = (ResourceBundle) class1.newInstance();
    child.setParent( bundle );
    bundle = child;
    System.out.println("I am here");
    As i am passing classname as variable it throws an exception class not found exception.but if we write class name as the parameter of class.forName().it works.i am implementing in j2me
    why this happen? give me solution.

    The following classpackage test;
    public class TestLoad {
        String aString = "This is a Test";
        Integer anInteger = new Integer(42);
        public TestLoad() {
            System.out.println("aString = " + aString + ", anInteger = " + anInteger);
    }works correctly when loaded and instantiated by this class:package test;
    import java.util.logging.Logger;
    public class ExecuteTest {
        public static final Logger log = Logger.getAnonymousLogger();
        public static void main(String[] args) {
            try {
                Class clazz = Class.forName("test.TestLoad");
                TestLoad test = (TestLoad) clazz.newInstance();
            } catch (Exception ex) {
                log.severe(ex.toString());
    }and produces the string "aString = This is a Test, anInteger = 42"
    I used the following version of Java on Windows 2000
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

  • Help - Class name and descriptions for a function location.

    Hi Guys
    i have to write a report that displays the class and class descriptions for a function location. the user passes in either the function location(TPLNR) or the class name and  the report should display the the class characteristics and resp. values. Is there a FM that i coud use?
    please help.
    many thanks.
    seelan.

    sadiepu1 wrote:
    When I set up Words with Friends on my Fire it asked for my username and password which from a previous reply to my inquiry above stated that the S 3 doesn't store due to privacy issues. I have tried all my usual combinations of usernames and passwords and my Fire won't let me access the game as it keeps telling me that one or the other is not correct. I have deleted the app from my Fire and re-downloaded it but have the same error comes up. I have accessed the Words with Friends support both on my phone and their website but there is no live chat. I might have to take both to a Verizon store. Also, my Fire won't let me access the game without a correct username and password. To say that I am frustrated would be an understatement as well I have tried everything I can think of with no luck! Thanks for any help you can give!
    Did you use facebook to log in? 
    Verizon will not be able to help you retrieve any of the information you need.  You will have to contact Zynga.

  • Class name of  stub for EJBHome Impl

    Hi,
    I am doing a context.lookup to find the EJBHome stub and I print the class name
    of the object that is looked up, every time a diffrent name comes up.
    Object obj = ic.lookup("ejb/test");
    System.out.println(hh.getClass().getName());
    I get $Proxy1
    and when I add the two more lines
    Object obj1 = ic.lookup("javax/jms/QueueConnectionFactory");
    System.out.println(obj1.getClass().getName());
    Object obj = ic.lookup("ejb/test");
    System.out.println(obj.getClass().getName());
    and re-run only my client I get:
    weblogic.jms.client.JMSConnectionFactory
    $Proxy2
    I understand that weblogic generates the stub dynamically, but how come (class name
    of) a object bound to JNDI tree keeps changing?
    and why does that happen for the connection factory(is that not a RMI stub too)?
    viswa

    viswa <[email protected]> wrote:
    Hi,
    I am doing a context.lookup to find the EJBHome stub and I print the class name
    of the object that is looked up, every time a diffrent name comes up.
    Object obj = ic.lookup("ejb/test");
    System.out.println(hh.getClass().getName());
    I get $Proxy1
    and when I add the two more lines
    Object obj1 = ic.lookup("javax/jms/QueueConnectionFactory");
    System.out.println(obj1.getClass().getName());
    Object obj = ic.lookup("ejb/test");
    System.out.println(obj.getClass().getName());
    and re-run only my client I get:
    weblogic.jms.client.JMSConnectionFactory
    $Proxy2
    I understand that weblogic generates the stub dynamically, but how come (class name
    of) a object bound to JNDI tree keeps changing?You can look at java/lang/reflect/Proxy.java to see how proxy class names are generated.
    BTW, it looks like WebLogic 7.0 doesn't use JDK dynamic proxies anymore and generates
    stub/skeleton bytecode by itself, so Stub class names are no longer $Proxy123 but xxx_WLStub.
    and why does that happen for the connection factory(is that not a RMI stub too)?My guess is that the actual stub reference is buried somewhere else.
    viswa--
    Dimitri

  • How to display the field name in the tabulated view for a content query web part

    I have added a content query web part changed the web part file to include custom columns imported and reffered itemstyle.xsl
    to include the tabulated view for the content query.
    However the way it is displayed is such that only the content is displayed.
    As i am using a tabular view wto display the data, i want to display their field names as well.

    Hi  ,
    According to your description, my understanding is that you need to display the field in the tabulated view for a content query web part.
    For your issue, please refer to the code as below:
    <xsl:template name="VendorCustomStyle" match="Row[@Style='VendorCustomStyle']" mode="itemstyle">
    <html>
    <table width="100%">
    <xsl:if test="count(preceding-sibling::*)=0">
    <tr>
    <td width="8%" valign="top"><div class="item"><b>Vendor ID</b></div></td>
    <td width="12%" valign="top"><div class="item"><b>Vendor Name</b></div></td>
    <td width="50%" valign="top"><div class="item"><b>Vendor Description</b></div></td>
    <td width="10%" valign="top"><div class="item"><b>Vendor Country</b></div></td>
    <td width="10%" valign="top"><div class="item"><b>Vendor Date</b></div></td>
    <td width="10%" valign="top"><div class="item"><b>Created By</b></div></td>
    </tr>
    </xsl:if>
    <tr>
    <td width="8%" valign="top"><div class="item"><xsl:value-of select="@VendorID" /></div></td>
    <td width="12%" valign="top"><div class="item"><xsl:value-of select="@Title" /></div></td>
    <td width="50%" valign="top"><div class="item"><xsl:value-of select="@Vendor_x005F_x0020_Description" disable-output-escaping="yes" /></div></td>
    <td width="10%" valign="top"><div class="item"><xsl:value-of select="@Vendor_x005F_x0020_Country" /></div></td>
    <td width="10%" valign="top"><div class="item"><xsl:value-of select="@Vendor_x005F_x0020_Date" /></div></td>
    <td width="10%" valign="top"><div class="item"><xsl:value-of select="@Author" /></div></td>
    </tr>
    </table>
    </html>
    </xsl:template>
    For more information, please have a look at the blog:
    http://www.codeproject.com/Articles/756834/Customizing-the-Content-Query-Web-Part-and-Item-St
    http://msdn.microsoft.com/en-us/library/ms497457.aspx
    http://clarksteveb.hubpages.com/hub/Customized-Content-Query-Web-Part-CQWP-in-SharePoint-2007-with-results-Tabbed-Grouped-and-in-an-HTML-Table
    http://blog.sharepointexperience.com/customitemstyle/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • "Bad Applet class name" error while recording on Oracle Forms 11g through OpenScript (JRE 1.7.0_17)

    Hi,
    I am trying to record automation functional test script on Oracle Forms 11g using OpenScript.
    Able to open the browser, but after accessing application URL, getting application error as "Bad Applet class name"
    Java Plug-in 10.17.2.02
    Using JRE version 1.7.0_17-b02 Java HotSpot(TM) Client VM
    c:   clear console window
    f:   finalize objects on finalization queue
    g:   garbage collect
    h:   display this help message
    l:   dump classloader list
    m:   print memory usage
    o:   trigger logging
    q:   hide console
    r:   reload policy configuration
    s:   dump system and deployment properties
    t:   dump thread list
    v:   dump thread stack
    x:   clear classloader cache
    0-5: set trace level to <n>
    SSV dialog is suppressed........
    cracked oracle.forms.engine.Main
    Loading cached Forms Jars ...
    Is this version (Oracle forms 11g, JRE 1.7.0_17) supported by OATS-OpenScript ?
    Please advise if there is any work around here.
    Thanks.

    From the last OATS release notes available in the C:\OracleATS\docs directory:
    4.1 Oracle Functional Testing/OpenScript
    Oracle Functional Testing’s OpenScript scripting platform has the following system
    requirements:
    ■ Operating System (32-bit and 64-bit versions): Windows XP, Windows Vista,
    Windows 2003, Windows 7, Windows 2008, Windows 2008 R2.
    ■ Memory: Minimum 1 GB
    ■ System: x86, 32-bit or 64-bit processor, 2.6 GHz or faster
    ■ Disk Space: 4 GB minimum
    ■ Browser: Internet Explorer 7.x, 8.x., 9.x; Firefox 3.5/3.6, 6.x, 10; Chrome 27+
    (playback only).
    ■ Java Runtime Environment: JRE 1.6 minimum (up to build 38), JRE 1.7 (up to build
    11) .
    So basically, it's not supported... Can you try with another JRE version?
    As always don't forget to run OpenScript as administrator on W7/8 or equivalent
    JB

  • Dynamically displaying a new region (row?) based on immediate user input

    Whew, figuring out a title was almost as hard as trying to explain what I want to do!
    Okay, a little background first.
    My app has 178 main data fields, spread across about 35 tables. The users want to be able to search any and all data fields. So, I wrote a PL/SQL package that for each master record, loops through all of the child tables and creates (more or less) an XML file for each master record (which I store in a CLOB field). When any data in any table is changed, a trigger fires to re-update that CLOB field as well. I then used Oracle Text to create an index on the CLOB field, and now the users can search across all of the available information for each master record and get a list of which records contained what they were looking for.
    So here's the first part of the problem. The app is a Mineral Occurence database for all mineral information world-wide. Say they enter "Brazil" as what they want to search for, they not only retreive all of the mineral sites in Brazil, but also all of the sites where one of the mining companies may be based in Brazil, or Brazil is one of the comments, etc. While this is the expected behaviour, it's still not quite what they expected (but they also don't want to get rid of this behaviour either).
    So, since the CLOB field is already formatted with XML-type tags, what I want to do is to have an Advanced Search page, where the user can specify the table name to search, or the field name, or both. What I'd like to do is at the end of each line, have a select list with an "AND" or "OR' box, and if that gets a value, then dynamically create another 'row' underneath the first row, with the same three 'boxes' (actually select lists), and continue on until the user has specified exactly what they want to search for.
    I would rather not have to create a whole bunch of regions or rows, and then determine at runtime whether or not to display them.
    So i would have (using underscores as the boxes/fields):
    Table to Search        Field to Search          And/Or
    ______________          _____________          _______Each of the above would be a select list.
    Anybody have ideas on how I can accomplish this? Any Javascript or AJAX-type solutions that a dummy like me can easily implement? I've seen something almost similar on Carl's example pages to Hide/Show a region(?), but understanding the underlying code and then modifying it for what I want to do is extremely complicated (for me) at best.
    Thanks.
    Bill Ferguson

    Well, after searching through the QBE results (even some of mine), the only thing that comes close is Earl's (http://htmldb.oracle.com/pls/otn/f?p=36337:14). Actually his layout is almost perfect and pretty identical to what I want/need. Vikas' example seems like what I've toyed with on some other pages in my app, using a simple UNION ALL with nulled fields in the select statement, which won't work for what I need, at least I can't seem to visualize how I could incorporate that same code logic.
    However, unlike Earl's, when/if the last column (which I'd have as the 'AND/OR' select list) is populated, I'd like to dynamically display another new row.
    Now I know I could do it by making the last column a 'Select List With Submit', but that would neccessitate my creating about 25 regions (to hopefully cover the max any of the users would ever need), and then conditionally display the region based on whether or not the previous 'AND/OR' condition field was populated. It would also require a whole slew of page refreshes, which is clunky.
    It seems like there should probably be a way with AJAX to accomplish something similar. I think I remember seeing something along these lines in the last year or so on here, but I can't find it.
    Something like a cross-breed of Earl's example page above mixed with Carl's example at http://htmldb.oracle.com/pls/otn/f?p=11933:39:4740898821262791902::NO:RP:: which would automatically fire on the poplulation of the last select list is probably the best I can accomplish, unless somebody has some better ideas on how to do this. Using Carl's htmldb_remix code, I can avoid all the submits and the resulting page refreshes, but the code itself will take an old dummy like me a while to figure out.
    Thanks for the ideas though.
    Bill Ferguson

Maybe you are looking for

  • XSLT transformation not working in 1.5 (but was in 1.4)

    Gentlemen, I have a problem with some code that worked fine under 1.4 (at least up to 1.4.2_06), but now no longer works under 1.5.0 (I know this isn't the most recent, but I have yet to update). I use the following XSL template in order to take a st

  • Tecra A11 - No Video via mini DisplayPor​t

    Hi There, I've recently aquired a Tecra A11 through my company that has two external video ports: VGA and mini DisplayPort.  With my previous laptop I ran two External displays while the laptop was closed and I would like to achieve this with my new

  • SM Portal display issue while creating incident classification with child items

    Hii,, We need to create some incident classification with child items. After creating classification with child items, portal is not showing the classification properly and the page display not showing properly. i.e. showing a block with drop down in

  • US W2 OFX Question

    I have a requirement to allow ESS users to download their previous year's W2 in OFX format. I will appreciate any ideas about how best this can be achieved. My thoughts: Solution 1: Step 1: Create a web dynpro application and deply it on the Portal E

  • Changing Oracle Lisetener default port

    Dear All Please advice steps for changing default Oracle LISETENER from 1521 to another port. Thank you