Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: beginner questions

  1. #11

    Default

    hmm after all the time i tried to get rid of it i somehow started to like the header, so after removing it using jwrays hint it felt like there is something missing
    so maybe i will keep it this time, but nice to know for future projekts!!

    anyway: thanks a lot for your help guys!

  2. #12
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    That's funny, probably a reflection of the process the original developers went through.

    But, you should have a better understanding of one way a Spring RCP application can be customized now, by the injection of none default implementations of various services.

    Jonny

  3. #13

    Default

    sorry to bother you again, but i have another problem:
    i got 2views, and i want the view to change when i hit a specific button

    i tried to do this by just excecuting a viewTest command defined in my commands-context.xml

    commands-context.xml
    Code:
    	<bean id="windowCommandManager"
    		class="org.springframework.richclient.application.support.ApplicationWindowCommandManager">
    		<property name="sharedCommandIds">
    			<list>
    				...
    				<value>testCommand</value>
    				...
    			</list>
    		</property>
    	</bean>
    and
    Code:
    <bean id="testCommand" class="org.springframework.richclient.command.support.ShowViewCommand">
    		<property name="viewDescriptor" ref="testView" />
    	</bean>

    following the pdf-documentation i found in this forum i tried to get this command in the application with
    Code:
    ActionCommand test =(ActionCommand)Application.instance().getActiveWindow().getCommandManager().getCommand("testCommand");
    and tried test.execute() to trigger the change view command


    but it doesnt work, test.getActionCommand() returns null, why is that?

  4. #14
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    Not exactly sure as I've never used a command like that before (getting it explicitly from the command manager) but my guess is that since you haven't added the command to anything visual (menu bar etc) the action command does not exist,

    Let's revisit. You are trying to have one command that toggles between two views, or two commands each responsible for activating its own view?

    Let's assume the second. First off, you don't need shared commands. That's a more advanced concept in which a global command (eg save) can have its behavior changed depending on which view is active by defining an executor for that command.

    Here's an example from one of my applications that sets up a menu of show view commands and adds it to the menuBar of an application, along with a couple of other menus.

    Code:
    <bean id="menuBar" 
    		class="org.springframework.richclient.command.CommandGroupFactoryBean" >
    	<property name="members">
    		<list>
    			<ref bean="fileMenu"/>
    			<ref bean="viewMenu" />
    			<ref bean="helpMenu"/>
    		</list>
    	</property>
    </bean>
    
    <bean id="viewMenu" 
            class="org.springframework.richclient.command.CommandGroupFactoryBean">
            <property name="members">
                <list>
                    <bean class="org.springframework.richclient.command.support.ShowViewCommand" >
                        <property name="viewDescriptor" ref="testView" />
                    </bean>
                    <bean class="org.springframework.richclient.command.support.ShowViewCommand" >
                        <property name="viewDescriptor" ref="testView" />
                    </bean>
                    <bean class="org.springframework.richclient.command.support.ShowViewCommand" >
                        <property name="viewDescriptor" ref="testView" />
                    </bean>
                </list>
         </property>
    </bean>
    The best place to look for this stuff is the example applications. They all have examples of how to configure commands and menus.

    Jonny

  5. #15

    Default

    hi

    thank you for your advice, but i already tried that: changing the view via menuBar works fine, but it doesnt solve my problem, i am still unable to do it in my class

    i got a jtable in my first view, and if the user presses the "ok" button i check if there is really something selected in the table, and if so i execute the testView command.
    i even tested xxx.execute(), it works perfectly for all commands defined in that class, so the real problem seems to be:

    why does the commandManager return null instead of the command?

  6. #16
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    As I said, I've never used the commands the way you mentioned. I have only ever used them as attached and triggered to a user input.

    So why isn't the command attached to the OK button? Or am I missing something?

    Guess I'm still not sure what you are trying to do functionally.

    Quote Originally Posted by Matrium View Post
    hi

    thank you for your advice, but i already tried that: changing the view via menuBar works fine, but it doesnt solve my problem, i am still unable to do it in my class

    i got a jtable in my first view, and if the user presses the "ok" button i check if there is really something selected in the table, and if so i execute the testView command.
    i even tested xxx.execute(), it works perfectly for all commands defined in that class, so the real problem seems to be:

    why does the commandManager return null instead of the command?

  7. #17

    Default

    *edit again*

    Code:
    ActionCommand x = (ActionCommand) getActiveWindow().getCommandManager().getCommand("testView");
    x.execute();
    i really dont know what i did wrong before, anyway, it works fine now

    thanks for your help!
    Last edited by Matrium; May 18th, 2009 at 02:01 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •