A question about a method with generic bounded type parameter

Hello everybody,
Sorry, if I ask a question which seems basic, but
I'm new to generic types. My problem is about a method
with a bounded type parameter. Consider the following
situation:
abstract class A{     }
class B extends A{     }
abstract class C
     public abstract <T extends A>  T  someMethod();
public class Test extends C
     public <T extends A>  T  someMethod()
          return new B();
}What I want to do inside the method someMethod in the class Test, is to
return an instance of the class B.
Normally, I'm supposed to be able to do that, because an instance of
B is also an instance of A (because B extends A).
However I cannot compile this program, and here is the error message:
Test.java:16: incompatible types
found   : B
required: T
                return new B();
                       ^
1 errorany idea?
many thanks,

Hello again,
First of all, thank you very much for all the answers. After I posted the comment, I worked on the program
and I understood that in fact, as spoon_ says the only returned value can be null.
I'm agree that I asked you a very strange (and a bit stupid) question. Actually, during recent months,
I have been working with cryptography API Core in Java. I understood that there are classes and
interfaces for defining keys and key factories specification, such as KeySpec (interface) and
KeyFactorySpi (abstract class). I wanted to have some experience with these classes in order to
understand them better. So I created a class implementing the interface KeySpec, following by a
corresponding Key subclass (with some XOR algorithm that I defined myself) and everything was
compiled (JDK 1.6) and worked perfectly. Except that, when I wanted to implement a factory spi
for my classes, I saw for the first time this strange method header:
protected abstract <T extends KeySpec> T engineGetKeySpec
(Key key, Class<T> keySpec) throws InvalidKeySpecExceptionThat's why yesterday, I gave you a similar example with the classes A, B, ...
in order to not to open a complicated security discussion but just to explain the ambiguous
part for me, that is, the use of T generic parameter.
The abstract class KeyFactorySpi was defined by Sun Microsystem, in order to give to security
providers, the possibility to implement cryptography services and algorithms according to a given
RFC (or whatever technical document). The methods in this class are invoked inside the
KeyFactory class (If you have installed the JDK sources provided by Sun, You can
verify this, by looking the source code of the KeyFactory class.) So here the T parameter is a
key specification, that is, a class that implements the interface KeySpec and this class is often
defined by the provider and not Sun.
stefan.schulz wrote:
>
If you define the method to return some bound T that extends A, you cannot
return a B, because T would be declared externally at invocation time.
The definition of T as is does not make sense at all.>
He is absolutely right about that, but the problem is, as I said, here we are
talking about the implementation and not the invocation. The implementation is done
by the provider whereas the invocation is done by Sun in the class KeyFactory.
So there are completely separated.
Therefore I wonder, how a provider can finally impelment this method??
Besides, dannyyates wrote
>
Find whoever wrote the signature and shoot them. Then rewrite their code.
Actually, before you shoot them, ask them what they were trying to achieve that
is different from my first suggestion!
>
As I said, I didn't choose this method header and I'm completely agree
with your suggestion, the following method header will do the job very well
protected abstract KeySpec engineGetKeySpec (Key key, KeySpec key_spec)
throws InvalidKeySpecException and personally I don't see any interest in using a generic bounded parameter T
in this method header definition.
Once agin, thanks a lot for the answers.

Similar Messages

  • Generic forwarding methods with recursive bounds.

    Hello all,
    I'm attempting to create a forwarding class assoicated with an interface. The interface has a generic method with recursive bounds. The problem relates to ambiguous method calls as the following code segment should demonstrate:
    interface TestInterface
        //generic method with recursive bounds. (use of Comparable<T> is
        // not relevant, any generic class/interface could have been used.)
        <T extends Comparable<T>> T testMethod(T bob);
    //Concrete implementation of the TestInterface.
    class TestClass implements TestInterface
        public <T extends Comparable<T>> T testMethod(T bob)
           return bob;
        public static void main(String[] args)
            TestInterface bob = new TestClass();
            bob.testMethod("blah"); //Works fine.
    class ForwardingClass implements TestInterface
        //Forwarding class composed of a TestClass object. All methods forward calls to this object.
        private final TestClass test;
        public ForwardingClass(TestClass test)
            this.test = test;
        //forwarding method.
        public <T extends Comparable<T>> T testMethod(T bob)
            return test.testMethod(bob);   //Ambiguous testMethod call. Both testMethod (T) in TestClass
                                           //and testMethod (T) in TestInterface match. Very annoying...
        }Therefore, if you could assist with the following issues, it would be greatly appreciated.
    Firstly, I don't think I fully understand why this error is given, so any explanation would be greatly appreciated.
    Secondly, is there any way to get around the problem?
    Thanks in advance,
    Matt.

    My bad. This appears to be an issue with Intellij 8.0M1. I'll create post on the Intellij forums. It compiles absolutely fine from the command line, and using Intellij 7.04. (Probably should have checked that before my initial post...)
    Apologies for wasting your time. Cheers for the replies.
    Matt.

  • Question about Logon ticket with user mapping at BI-JAVA environment

    We're implementing BI 7.0 including BI Java and SAP EP for end user
    access.
    I have two question about SSO method when we're using BI Java.
    I know we can simply configure SSO logon ticket with BI-Java(EP
    included) and BI-ABAP through BI template installer and we already
    succeeded in that case.
    But the problem is we want to change it to user mapping SSO method for
    some our internal reason.
    After we configure user mapping SSO, we've got SSO failed error when we
    call BI-Java stuff like BEx Web Application iView.
    After many testing implemented, we found SSO Logon ticket with user
    mapping (using SAP reference system). It seems working now.
    But our question is "Is it no problem when we use SSO logon ticket with
    user mapping?" Is there any restriction or issue?
    One more question is we can ONLY use user base mapping when reference
    system used. How can we assign BI-ABAP users to EP Group?

    Using an SAP Reference system is allright. But if the reason u r going for this is because of different usernames in EP and BI, why dont you go for user mapping.
    Anyways, on restriction of reference syetms is that you can have ONLY ONE reference system defined in portal. In you case you can only have the BI system defined.
    Hope this helps!!

  • Generics bounded type problem

    I am using a bounded type parameter in my class GenericBoundedTypes as shown below.
    The code is compiling but obviously throws run time error.
    My question is why is there no compiler error in the line that I have noted below when I have explicitly declared my GenericBoundedTypes class as <T extends Number>. Is this how generics is supposed to work/
    import static java.lang.System.out;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Iterator;
    public class GenericBoundedTypeTest {
      public static void main(String[] args) {
        List<String> ln1 = new ArrayList<String>();
        List<Integer> ln2 = new ArrayList<Integer>();
        GenericBoundedTypes gbt = new GenericBoundedTypes(); // Why is compiler not blocking this
        ln1.add("Amit1");
        ln1.add("Amit2");
        ln1.add("Amit3");
        ln1.add("Amit4");
        ln1.add("Amit5");
        ln2.add(10);
        ln2.add(10);
        ln2.add(10);
        ln2.add(10);
        ln2.add(10);
        gbt.getAverage(ln1);
        gbt.getAverage(ln2);
    class GenericBoundedTypes<T extends Number> {
      GenericBoundedTypes() {
        out.print("Constructor created");
      Double getAverage(List<T> ln) {
        Iterator<T> itr = ln.iterator();
        Double avg = 0.0;
        double sum = 0.0;
        while(itr.hasNext()) {
          sum = sum + itr.next().doubleValue();
        avg = sum/ln.size();
        return avg;
    }

    Thanks for the info. It seems like a bad idea that compiler allows raw types. I modified my code but on compiling I am getting the following warning
    warning: [unchecked] unchecked call to <S>getAverage(java.util.List<S>) as a member of the raw type scjp.chap10.GenericBoundedTypesI have declared my getAverage method as <S extends Number> double getAverage(List<S> ln) and the list I am passing as parameter is also of type Integer. So why am I getting compiler warnings.
    import static java.lang.System.out;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Iterator;
    public class GenericBoundedTypeTest {
      public static void main(String[] args) {
        List<String> ln1 = new ArrayList<String>();
        List<Integer> ln2 = new ArrayList<Integer>();
        GenericBoundedTypes gbt = new GenericBoundedTypes();//Allowed by the compiler for backward compatibility. But not a good idea to use the raw type.
        GenericBoundedTypes<Integer> gbt2 = new GenericBoundedTypes<Integer>();
        //GenericBoundedTypes<String> gbt2 = new GenericBoundedTypes<String>(); //compiler error String is not subtype of number
        ln2.add(10);
        ln2.add(10);
        ln2.add(10);
        ln2.add(10);
        ln2.add(10);
        //gbt.getAverage(ln1); //will throw run time error
        out.println(gbt.getAverage(ln2));
    class GenericBoundedTypes<T extends Number> {
      GenericBoundedTypes() {
        out.println("Constructor created");
      <S extends Number> double getAverage(List<S> ln) {
        Iterator<S> itr = ln.iterator();
        Double avg = 0.0;
        double sum = 0.0;
        while(itr.hasNext()) {
          sum = sum + itr.next().doubleValue();
        avg = sum/ln.size();
        return avg;
    }

  • Call a method with complex data type from a DLL file

    Hi,
    I have a win32 API with a dll file, and I am trying to call some methods from it in the labview. To do this, I used the import library wizard, and everything is working as expected. The only problem which I have is with a method with complex data type as return type (a vector). According to this link, import library wizard can not import methods with complex data type.
    The name of this method is this:   const std::vector< BlackfinInterfaces::Count > Counts ()
    where Count is a structure defined as below:
    struct Count
       Count() : countTime(0) {}
       std::vector<unsigned long> countLines;
       time_t countTime;
    It seems that I should manually use the Call Library Function Node. How can I configure parameters for the above method?

    You cannot configure Call Library Function Node to call this function.  LabVIEW has no way to pass a C++ class such as vector to a DLL.

  • Non-varargs call of varargs method with inexact argument type for last para

    i have no idea what the error:
    non-varargs call of varargs method with inexact argument type for last parameter
    means.
    return (Component)sceneClass.getConstructor(
    new Class[]{int.class, int.class}).newInstance(
         new Integer[]{new Integer((int)sceneDimension.getWidth()),
                new Integer((int)sceneDimension.getHeight())});
    this is the problem area but i'm not sure how to get around it..
    any help would be appreciated

    I am a Java learner and I got the same warning. My code runs like this:
    import java.lang.reflect.*;
    class Reflec
         public static void main(String[] args)
              if(args.length!=1)
                   return;
              try
                   Class c=Class.forName(args[0]);
                   Constructor[] cons=c.getDeclaredConstructors();
                   Class[] params=cons[0].getParameterTypes();
                   Object[] paramValues=new Object[params.length];
                   for(int i=0; i<params.length; i++)
                        if(params.isPrimitive())
                             paramValues[i]=new Integer(i+3);
                   Object o=cons[0].newInstance(paramValues);
                   Method[] ms=c.getDeclaredMethods();
                   ms[0].invoke(o, null);
              catch(Exception e)
                   e.printStackTrace();
    class Point
         static
              System.out.println("Point class file loaded and an object Point generated£¡");     
         int x, y;
         void output()
              System.out.println("x="+x+"\ny="+y);
         Point(int x, int y)
              this.x=x;
              this.y=y;
    When I compiled the file I got the following:
    Reflec.java:26: warning: non-varargs call of varargs method with inexact argument type for last parameter;
    cast to java.lang.Object for a varargs call
    cast to java.lang.Object[] for a non-varargs call and to suppress this warning
    ms[0].invoke(o, null);
    ^
    1 warning
    Since the problem was with this line "ms[0].invoke(o, null);" and the specific point falls on the last argument as the warning mentioned that " ... method with inexact argument type for last parameter", I simply deleted the argument "null" and the line becomes "ms[0].invoke(o);" and it works, no warning anymore!
    DJ Guo from Xanadu
    Edited by: Forget_Me_Not on Jan 8, 2009 10:39 AM

  • Native method with String return type

    Hi
    i am implementing a Native method with String Return type.
    i am able call the respective C++ method and my C++ method is printing the String (jstring in c++ code ) correctly
    i but i am getting nullpointerexcepti while loading the string in to my Java String .
    i am sure my java code calling the C++ code beacause my C++ code is printing the value and one more wonder is after the NPE my c++ code able to print the value
    the code follows
    HelloWorld.java
    public class HelloWorld {
         private native String print();
         static {
             System.loadLibrary("HelloWorld");
         public static void main(String[] args) throws InterruptedException,NullPointerException{
              HelloWorld hW= new HelloWorld();
              for(int i=0;;i++){
                   String str= new HelloWorld().print();
                   System.out.println(str);
                   Thread.sleep(10000);
    }and HelloWorld.cpp
    // HelloWorld.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    #include "jni.h"
    #include <stdio.h>
    #include "HelloWorld.h"
    #include <windows.h>
    #include "tchar.h"
    #include "string.h"
    #ifdef _MANAGED
    #pragma managed(push, off)
    #endif
    CHAR cpuusage(void);
    typedef BOOL ( __stdcall * pfnGetSystemTimes)( LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
    static pfnGetSystemTimes s_pfnGetSystemTimes = NULL;
    static HMODULE s_hKernel = NULL;
    void GetSystemTimesAddress()
         if( s_hKernel == NULL )
              s_hKernel = LoadLibrary(_T("Kernel32.dll"));
              if( s_hKernel != NULL )
                   s_pfnGetSystemTimes = (pfnGetSystemTimes)GetProcAddress( s_hKernel, "GetSystemTimes" );
                   if( s_pfnGetSystemTimes == NULL )
                        FreeLibrary( s_hKernel ); s_hKernel = NULL;
    // cpuusage(void)
    // ==============
    // Return a CHAR value in the range 0 - 100 representing actual CPU usage in percent.
    CHAR cpuusage()
         FILETIME               ft_sys_idle;
         FILETIME               ft_sys_kernel;
         FILETIME               ft_sys_user;
         ULARGE_INTEGER         ul_sys_idle;
         ULARGE_INTEGER         ul_sys_kernel;
         ULARGE_INTEGER         ul_sys_user;
         static ULARGE_INTEGER      ul_sys_idle_old;
         static ULARGE_INTEGER  ul_sys_kernel_old;
         static ULARGE_INTEGER  ul_sys_user_old;
         CHAR  usage = 0;
         // we cannot directly use GetSystemTimes on C language
         /* add this line :: pfnGetSystemTimes */
         s_pfnGetSystemTimes(&ft_sys_idle,    /* System idle time */
              &ft_sys_kernel,  /* system kernel time */
              &ft_sys_user);   /* System user time */
         CopyMemory(&ul_sys_idle  , &ft_sys_idle  , sizeof(FILETIME)); // Could been optimized away...
         CopyMemory(&ul_sys_kernel, &ft_sys_kernel, sizeof(FILETIME)); // Could been optimized away...
         CopyMemory(&ul_sys_user  , &ft_sys_user  , sizeof(FILETIME)); // Could been optimized away...
         usage  =
              (ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
              (ul_sys_user.QuadPart   - ul_sys_user_old.QuadPart)
              (ul_sys_idle.QuadPart-ul_sys_idle_old.QuadPart)
              (100)
              (ul_sys_kernel.QuadPart - ul_sys_kernel_old.QuadPart)+
              (ul_sys_user.QuadPart   - ul_sys_user_old.QuadPart)
         ul_sys_idle_old.QuadPart   = ul_sys_idle.QuadPart;
         ul_sys_user_old.QuadPart   = ul_sys_user.QuadPart;
         ul_sys_kernel_old.QuadPart = ul_sys_kernel.QuadPart;
         return usage;
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
        return TRUE;
    #ifdef _MANAGED
    #pragma managed(pop)
    #endif
    JNIEXPORT jstring JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
           int n;
         GetSystemTimesAddress();
         jstring s=(jstring)cpuusage();
         printf("CPU Usage from C++: %3d%%\r",s);
         return s;
    }actually in the above code below part does that all, in the below code the printf statement printing correctly
    JNIEXPORT jstring JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
           int n;
         GetSystemTimesAddress();
         jstring s=(jstring)cpuusage();
         printf("CPU Usage from C++: %3d%%\r",s);
         return s;
    }and the NPE i get is
    Exception in thread "main" java.lang.NullPointerException
         at HelloWorld.print(Native Method)
         at HelloWorld.main(HelloWorld.java:10)
    CPU Usage from C++:   6%any solution?
    Thanks
    R
    Edited by: LoveOpensource on Apr 28, 2008 12:38 AM

    See the function you wrote:
    JNIEXPORT jstring JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj)
           int n;
         GetSystemTimesAddress();
         _jstring s=(jstring)cpuusage();_
         printf("CPU Usage from C++: %3d%%\r",s);
         return s;
    }Here you try to cast from char to jstring, this is your problem, jstring Object should be created:
    char str[20];
    sprintf(str, "%3d", (int)cpuusage());
    printf("CPU Usage from C++: %s%%\r",str);
    jstring s=env->NewStringUTF(str);
    return s;

  • Questions about PDF exporting with InDe CS5.5

    Hey all,
    A couple questions about exporting to PDF from the latest version of InDe.
    First, I have noticed that it seems to take a lot longer to get to a PDF. Any suggestions for how to speed up the process? It took 8 minutes or so to generate a low-res PDF (for print) of a 24pp document with a few placed images and vector graphics. Wow, that's a long time to wait, especially for a proof.
    Second, the background task... if I get it going on making that 8-minute PDF and then work some more on the document, what exactly is in the PDF? Usually I save before making a PDF or printing. So, is the last version saved what will be in the PDF?
    (As an aside, this ability to work on the doc while generating a PDF seems kind of weird. Generally one makes a PDF for proofing, or even for printing, when all the changes have been made and everything is "final". So, I see no benefit to being able to work on my document while it's making a PDF, as I'm probably finished making revisions for the time being. I have to say that I kind of like the progress bar you get when you make an interactive PDF, as you know you can't work on the document when that's on the screen... )
    Thanks as always.

    First, I have noticed that it seems to take a lot longer to get to a PDF. Any suggestions for how to speed up the process? It took 8 minutes or so to generate a low-res PDF (for print) of a 24pp document with a few placed images and vector graphics. Wow, that's a long time to wait, especially for a proof.
    Yes, this is abnormally long (and too long), something is wrong. What's the full version of InDesign you are running, as reported by holding down Cmd or Control and selecting About InDesign?
    Second, the background task... if I get it going on making that 8-minute PDF and then work some more on the document, what exactly is in the PDF? Usually I save before making a PDF or printing. So, is the last version saved what will be in the PDF?
    Saving is not related. InDesign makes a database snapshot of your document the moment you begin the PDF export, and makes the export relative to that snapshot, regardless of edits you continue to make during the export process, and regardless of saving. Of course saving first is a good idea, for several reasons, not the least of which it sounds like something's fairly seriously wrong with your document or your InDesign installation.
    We recommend you trash your preferences and export your document to IDML and see if either of those things changes this 8-minute behavior...err, assuming you're running 7.5.2.318.
    (As an aside, this ability to work on the doc while generating a PDF seems kind of weird. Generally one makes a PDF for proofing, or even for printing, when all the changes have been made and everything is "final". So, I see no benefit to being able to work on my document while it's making a PDF, as I'm probably finished making revisions for the time being. I have to say that I kind of like the progress bar you get when you make an interactive PDF, as you know you can't work on the document when that's on the screen... )
    Yeah, I think the primary benefit is if you are likely to work on 2 or more files in parallel, so you can finish A and export A and then switch to B. If you'd like a dialog box to pop up when export is done, check out my exportPop script from this post: ANN: automatic dialog after background export (exportPop.jsx.

  • Questions about supporting TLF with Halo components in Flex 4.1

    We recently decided to upgrade to the Flex 4.1 SDK after a year or so at 3.2.  We have been asked to not use the new SPARK components yet because our products would then have a mistmatch of Halo and Spark components in the UI.  We have built support for our Halo components to display html through the ".htmlText" property for the Text components.  For example, we can display strings such as "<p>Choose <b>one</b> option:</p>".  With the upgrade to Flex 4.1 a couple of questions about supporting bi-directional text have come up.  My understanding is that in order to support bi-directional text we need to use the Text Layout Framework.  Does anyone have a suggestion on how we can utilize the TLF with the Halo components in Flex 4.1?    Can we still use the ".htmlText" property somehow or is there a new property that understands the TextFormat markup?  We would love to still be able to use the limited html tags that are supported for the "htmlText" property.  Is there an option where that syntax is still understood?
    Thanks in advance!
    David

    The halo components use TextField, and the spark components use TLF. Both sets have support for some html markup to import and export text. To use bidi text, you have to use TLF; TextField won't work properly.
    It is possible to use TLF to build your own components, and this can work well particularly for applications with specialized needs. But if you need bidi support for advanced components like DataGrid and List, then you should use the spark components.
    Thanks!
    - robin

  • A few questions about using PS3 with 27" iMac display...

    Hey people, I had a few questions about how I could possibly get my ps3 connected to the iMac's 27" screen. First of all, could you guys list some adapters that would be able to convert the HDMI to Mini displayport? That would be great. The only one I know of is that Dr. Bott Digital Video link.
    Okay secondly, I was wondering if I do get the the ps3 connected with the iMac's display with an adapter to convert HDMI to mini DisplayPort, would it be in HD? Would I be able to play ps3 games or watch blu-ray movies in 1080p HD format?
    Thanks!

    Welcome to the Apple Discussions!
    This has been asked a number of times here since the intro of the 27" iMac. The answer is very expensive US$149 or more converters and sometimes even more expensive to maintain the resolutions that you seek.
    http://lowendmac.com/ed/bashur/09db/dvi-to-mini-displayport.html
    Dah•veed

  • About calling method with arguments

    Hi,
    I have a problem about calling method using reflection. my method is like follows:
    public myMethod(Integer var1, MyObject mobj) {
    I've tried to call the method using the following code,
    Class[] parameterTypes = new Class[] {Integer.class, MyObject.class};
    Object[] arguments = new Object[] {new Integer(2), mobj};
    Method met=cl.getMethod("myMethod", parameterTypes);
    But the in the last line NoSuchMethodException is thrown.
    How can I send the reference of MyObject to myMethod()?
    Thanx
    rony

    Should work ok:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class Test {
         static class MyObject {}
         public static void main(String[] args) throws Exception {
              Class c = Test.class;
              Class[] parameterTypes = new Class[] {Integer.class, MyObject.class};                              
              try {
                   Object[] arguments = new Object[] {new Integer(2), new MyObject()};
                   Method met = c.getMethod("myMethod", parameterTypes);
                   met.invoke(new Test(), arguments);
              } catch (NoSuchMethodException e) {
                   System.out.println(e);
              } catch (IllegalAccessException e) {
                     System.out.println(e);
              } catch (InvocationTargetException e) {
                   System.out.println(e);
         public void myMethod(Integer var1, MyObject mobj) {
              System.out.println("myMethod");
    }

  • Question about changing method signature

    Hello. I've inherited some code which contains a method with the following signature:
    foo(int x, MyObject myObject)
    Okay, so that's not really the exact signature :) In any case, I need to modify the signature to:
    foo(int x, Object myObject)
    I believe that I can do this without affecting any existing client code because Obect is a superclass of MyObject. Is that right or must I deprecate the first version and add the second separately? Whatever, happens I can't break code which was compiled against the old version. Thanks in advance.
    -jason

    That's a good point. It's probably not an issue
    however as we don't provide (supported) access to our
    implementation classes. Thanks for the input.
    -JasonThen I don't see another issue with it, as long as no other internally-written class has already overridden it and doesn't get changed at the same time. In a sense you're saying it's a "private" (not necessarily in the same sense of the private keyword) method, so you can change the implementation, including method signatures, at your whim.

  • Question about 360 movieclip with cursor action

    Hello Flash Forum
    We have a question about a 360 flash / movieclip which comes
    to a halt or jumps to whereever the cursor is moved horizontally
    while any vertical movements is ignored. We are having difficulties
    to implement this and would like to ask whether someone can point
    us into the right direction in Flash 8 - read somewhere that this
    is extremely easy in Flash 8 but we cannot find out how!?
    An example would be:
    http://www.kswiss.com/cgi-bin/kswiss/store/product_detail.html?mv_arg=x&pid=01190:177
    and then chosing 'Go 360'
    Thank you for any assistance and/or direction.
    Alex

    Alex, took a look at your sample - looks to me like
    start_drag and stop_drag on mouse_over. Hope this helps. ash

  • Java call stored procedure with nested table type parameter?

    Hi experts!
    I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
    The following is my pl/sql code:
    create or replace package test_package as
    type row_abc is record(
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    type matrix_abc is table of row_abc index by binary_integer;
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    END test_package;
    create or replace package body test_package as
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    IS
    v_sn NUMBER(8):=0 ;
    BEGIN
    LOOP
    EXIT WHEN v_sn>5 ;
    v_sn := v_sn + 1;
    p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
    p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
    p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
    END LOOP ;
    END ;
    END test_package ;
    My java code is following, it doesn't work:
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection
    ("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
    con.setAutoCommit(false);
    CallableStatement ps = null;
    String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
    ps = con.prepareCall(sql);
    ps.setString(1,"p1");
    ps.setString(2,"p2");
    ps.setString(3,"p3");
    ps.registerOutParameter(4,OracleTypes.CURSOR);
    ps.execute();
    ResultSet rset = (ResultSet) ps.getObject(1);
    error message :
    PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Regards
    Louis

    Louis,
    If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
    create or replace type ROW_ABC as object (
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    create or replace type MATRIX_ABC as table of ROW_ABC
    /Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
    For your information, there are also code samples of how to do this on the OTN Web site.
    Good Luck,
    Avi.

  • Question about app design with JSF

    I'm new to JSF and have been using MyFaces in combination with Tomcat and Hibernate to write a web application for my institution. We have a fairly clean model implemented and our hibernate persistence layer is also looking good. I'm running into trouble making a clean view layer with JSF. Namely, I can't seem to avoid creating lots of classes to get a given job done.
    As a for instance: I have quite a few enumerations representing various units of measure, conventions, etc. To persist them in the db with hibernate, I needed to make a converter class to convert the Enums to strings. I wrote a class using generics that could convert any enum to strings appropriately given a class object you pass into the constructor. Well, hibernate needs a no arg constructor so it can instantiate one automatically, so I had to make a subclass of this converter for each enumeration I have in my model. Couldn't see a way around it.
    Now, using JSF, I'm needing to implement another converter for enumerations in order convert back and forth from strings. Same deal. I could use a single class to get the job done. The problem is, in the faces-config.xml where you define your converter classes, it doesn't look like I can have 2 converters defined with the same converter class.
    i.e.:
    <converter>
    <converter-for-class>commons.astronomy.Epoch</converter-for-class>
    <converter-class>tools.webapp.EnumConverter</converter-class>
    <property>
         <property-name>enumClass</property-name>
         <property-class>java.lang.Class</property-class>
           <default-value>commons.astronomy.Epoch</default-value>
    </property>
    </converter>
    <converter>
    <converter-for-class>commons.astronomy.VelocityConvention</converter-for-class>
    <converter-class>tools.webapp.EnumConverter</converter-class>
    <property>
         <property-name>enumClass</property-name>
         <property-class>java.lang.Class</property-class>
            <default-value>commons.astronomy.VelocityConvention</default-value>
    </property>
    </converter>MyFaces seems to associate both Epoch and VelocityConvention with the second configuration of the EnumConverter class. So, the long and short of it is, here I am again having to write yet another class PER enumeration.
    I could go on with another example, but this post is getting lengthy, so I'll make it short. Some of my model classes are not java beans because it would create inconsistencies to only set some of the properties one at a time. I.E. I need to call a method obj.set(a, b) not obj.setA(a); obj.setB(b). My first thought was to create a custom component for obj so that I can turn 2 (or more) input fields into 1 set call. There are other advantages in reusability, etc.
    Unfortunately, I have several of those situations and am finding myself leaning toward implementing yet MORE classes to make a separate component for each such instance of a non-java bean set of properties.
    What it all comes down to is I seem to be having a class explosion and I'm wondering if there's a better approach to this whole thing. How do you organize a view layer that talks to a model having enumerations and not quite javaBean pattern properties without a class explosion? That's the question I guess.
    Thanks for your patience in reading all of that and any help you can provide!
    brian

    No, I don't have tables of values. I have a java 1.5 enumeration, like for instance:
    public enum VelocityConvention {
       RELATIVISTIC,
       REDSHIFT;
    }and a class Velocity that contains a convention and a value like so:
    public class Velocity {
       public VelocityConvention getConvention() {...}
       public double getValue() {...}
       public void set(VelocityConvention conv, double value) {...}
    }When I persist the Velocity class to the database, I want a field called convention that holds the appropriate value of the enumeration. That much is done how I explained before.
    I want to have a selectOneMenu for setting the convention. Via trial and error, I found that MyFaces wasn't able to automatically convert from a string back to a proper VelocityConvention enum constant. It can, of course, convert from the enum to a string because it just calls toString(). But I need both directions for any UIInput element I use, be it a selectOne, or just a straight inputText.

Maybe you are looking for

  • Having some major issues with track numbers in the newest iTunes

    I just recently went out and bought some new albums today for my birthday which was over the weekend and I ripped them to my computer, but when I go to put them into iTunes their track numbers are wrong. So as normal I went to change them, but found

  • Logic pro 9 wont save automation data on multi license verrsion

    I use Logic Pro 9, installed as an image on an Apple xserve for which we have purchased a multi license agreement. Logic will not let the user save automation data.

  • How to remove directories under Loops Search Setup?

    Hi, I want to move my sound effects loops to an external firewire drive to free up 20+ GB. In Soundtrack Pro when I go into Loops Search Setup, where the list of Directories being indexed is displayed, the "-" icon at the top for "remove directory" i

  • Nano 'Contacts' - Surname, First Name

    Hi, I've managed to export my Windows Contacts to my Nano, using "iPodSync" after problems using the itunes prog, but they've come through as 'Bill Smith' when the way I want them displayed (and the way I have them in Outlook) is 'Smith, Bill' (the i

  • Image opened via OLE - missing colour profiles

    Hello I'm using OLE via MFC/C++ to edit an image in PhotoShop in Windows XP. To edit an image I first write it into a temporary psd file and then open this file in Photoshop using something like mpItem->CreateFromFile(fileName, clsid)- where mpItem i