keith,
It sovled my problem! Thanks so much.
The only little annoying thing is, I can't find a proper abstract class to extend from -- which implements both Wizard interface and GuardedActionCommandExecutor interface. So, I choose made my wizard continueing extends from "AbstractWizard", and have to copy code from "AbstractActionCommandExecutor"( which implements GuardedActionCommandExecutor ) and paste to my wizard. Is this you are thinking about?
I paste my code here, hope could help others who could run into the same problem as me:
In application-context:
<bean id="exportTabletWizard"
class="com.sjv.iptools.export.vtablet.ui.ExportTab letWizard" lazy-init="true">
<constructor-arg index="0">
<ref local="exportConfig"/>
</constructor-arg>
<property name="enabled"><value>false</value></property>
</bean>
<bean id="connectDBWizard"
class="com.sjv.iptools.export.vtablet.ui.ConnectDB Wizard" lazy-init="true">
<constructor-arg index="0">
<ref local="dbConfig"/>
</constructor-arg>
</bean>
In commands-context:
<bean id="exportTabletCommand"
class="org.springframework.richclient.command.Targ etableActionCommand">
<property name="commandExecutor">
<ref bean="exportTabletWizard"/>
</property>
</bean>
<bean id="connectDBCommand"
class="org.springframework.richclient.command.Targ etableActionCommand">
<property name="commandExecutor">
<ref bean="connectDBWizard"/>
</property>
</bean>
ConnectDBWizard:
Code:
public class ConnectDBWizard extends AbstractWizard implements
ActionCommandExecutor {
protected boolean onFinish(){
wizardForm.commit();
System.out.println(dbConfig);
try{
//Connect to DB here...
DatabaseConnectionEvent evt = new DatabaseConnectionEvent(this);
evt.setType(DatabaseConnectionEvent.IPDB_CONNECTION_EVENT);
evt.setIpDbConnected(true);
getApplicationContext().publishEvent(evt);
}catch (Throwable e){
e.printStackTrace(System.err);
}
return true;
}
............................
ExportTabletWizard:
Code:
public class ExportTabletWizard extends AbstractWizard implements
GuardedActionCommandExecutor, ApplicationListener {
///////////////////////////////
/*
* Implements GuardedActionCommandExecutor
*/
private ValueModel enabled = new ValueHolder(Boolean.FALSE);
public boolean isEnabled() {
return ((Boolean)enabled.getValue()).booleanValue();
}
public void setEnabled(boolean enabled) {
this.enabled.setValue(Boolean.valueOf(enabled));
}
public void addEnabledListener(ValueChangeListener listener) {
enabled.addValueChangeListener(listener);
}
public void removeEnabledListener(ValueChangeListener listener) {
enabled.removeValueChangeListener(listener);
}
/////////////////////////////////
/*
* Implements ApplicationListener
*/
public void onApplicationEvent(ApplicationEvent event) {
if( event instanceof DatabaseConnectionEvent){
DatabaseConnectionEvent dbevent = (DatabaseConnectionEvent)event;
if( dbevent.isIpDbConnected() == true ){
this.setEnabled(true);
}
}
}
.............................
}
..........................