Re: [ovirt-devel] popup dialog

2014-08-15 Thread Leaboy
which type does result.getReturnValue() got,

And how could I set it in the backend.

在 8/14/14, 21:57, Vojtech Szocs vsz...@redhat.com 写入:



- Original Message -
 From: Leaboy wlblea...@126.com
 To: Vojtech Szocs vsz...@redhat.com
 Cc: devel@ovirt.org
 Sent: Thursday, August 14, 2014 2:12:37 PM
 Subject: Re: [ovirt-devel] popup dialog
 
 Hi:
 you said that ,I have done, and the dialog
 Can display, and I can pass a parameter from dialog
 To the backend executeCommand().
 
 Now the question is, after executeCommand(),
 Hou could I get the return value in the frontend.
 
 For example, when I clicked backup button,
 A dialog is display, now I type some parameters into
 The dialog, click OK button, the backend executeCommand()
 Do something, now, I need some value from executeCommand()
 to frontend.

Sorry, I missed that your question was about executing backend
command (I thought you referred to Model.executeCommand) ...

Backup dialog's OK button is represented by:

  UICommand tempVar = new UICommand(OnBackup, this);

When user clicks OK button, that ^^ UICommand is executed.
Model's executeCommand should route flow to some onBackup()
method, I assume you already did this:

  // inside TemplateListModel#executeCommand
  ...
  else if (OnBackup.equals(command.getName())) {
onBackup();
  }
  ...

  // inside TemplateListModel
  private void onBackup() {
TemplateBackupModel windowModel = (TemplateBackupModel) getWindow();

// do nothing if windowModel is already doing something -or- if
// windowModel validation failed (i.e. bad/missing user input)
if (windowModel.getProgress() != null || !windowModel.validate()) {
  return;
}

// this replaces dialog content UI with progress animated image
// to indicate that a call to backend is about to be initiated
windowModel.startProgress(null);

// on backend, assume you have TemplateBackupCommand that works
// with parameter type TemplateBackupParameters
TemplateBackupParameters params = new TemplateBackupParameters();
// update params according to window model
params.setFoo(windowModel.getFoo().getEntity());

// this is the async callback executed when backend command
// (TemplateBackupCommand in our case) has done its job
IFrontendActionAsyncCallback callback = new
IFrontendActionAsyncCallback() {
  @Override
  public void executed(FrontendActionAsyncResult result) {
TemplateListModel listModel = (TemplateListModel)
result.getState();
listModel.postOnBackup(result.getReturnValue());
  }
};

// call backend
Frontend.getInstance().runAction(
  VdcActionType.TemplateBackup, params, callback, this);
  }

  // still inside TemplateListModel
  private void postOnBackup(VdcReturnValueBase returnValue) {
// at this point, backend has replied with returnValue,
// we can remove progress animated image in dialog
getWindow().stopProgress();

// if the backend operation was successful, close the
// dialog (otherwise the dialog will remain open)
if (returnValue != null  returnValue.getSucceeded()) {
  setWindow(null);
}
  }

Regards,
Vojtech


 
 
 在 8/14/14, 19:48, Vojtech Szocs vsz...@redhat.com 写入:
 
 
 
 - Original Message -
  From: Leaboy wlblea...@126.com
  To: Vojtech Szocs vsz...@redhat.com
  Cc: devel@ovirt.org
  Sent: Thursday, August 14, 2014 6:19:17 AM
  Subject: Re: [ovirt-devel] popup dialog
  
  Hi,Vojtech Szocs:
  Thanks for your help, I have let it work,
  
  The Error I got just because I miss the step 3 you noted.
  
  Another question is how could I got the returnValue after
  executeCommand , and let the returnValue display on the oher
  Popup dialog.
 
 Please add this into MainTabTemplateView:
 
   ...
   getTable().addActionButton(new
 WebAdminButtonDefinitionVmTemplate(constants.templateBackup()) {
 @Override
 protected UICommand resolveCommand() {
   return getMainModel().getTemplateBackupCommand();
 }
   });
   ...
 
 This adds a button under Template main tab. When clicked, it executes
 given command (getTemplateBackupCommand) on model (TemplateListModel).
 
 Model's executeCommand() ensures that backup() method is called. Inside
 backup() method, you call setWindow(model) which triggers an event - UI
 infra handles this event and uses getModelPopup (see TemplateModule)
 to resolve window model to GWTP PresenterWidget which is then
revealed
 as popup. This is how dialogs work in UiCommon / UI (GWTP) infra.
 
  how could I got the returnValue after executeCommand
 
 As  I wrote above, executeCommand() just calls appropriate method (like
 backup) on the list model. That method has no return value (void) since
 it uses setWindow(model) to trigger event to notify UI infra to reveal
 a dialog.
 
 If you need to pass data to dialog, for example:
 
   ...
   TemplateBackupModel model = new TemplateBackupModel();
   setWindow(model);
   ... set window model's 

Re: [ovirt-devel] Management network as a role - design proposal

2014-08-15 Thread Dan Kenigsberg
On Thu, Aug 14, 2014 at 11:52:41AM -0400, Yevgeny Zaspitsky wrote:
 Hi All, 
 
 The proposed feature will allow defining an arbitrary network in the DC as 
 the management network for the cluster, which in its turn will allow 
 assigning different VLANs for the management networks in the same DC. 
 
 Feature page can be found here - 
 http://www.ovirt.org/Features/Management_Network_As_A_Role . 
 
 Please take a look into the page especially into Open issues section. I'd 
 like to have your opinions on that. 

May I ask why you change the default management network from ovirtmgmt
to Management? (And why the upercase M?)

Regarding your open question: Creating new cluster would have to
receive the new parameter (management network) This new parameter
should be kept optional, with a default value of ovirtmgmt. This way, a
user that is unaware of the new feature, would see no change in
functionality.

The feature page should discuss the possibility of chaning the
management role. Is it supported after there are hosts in the cluster?
If we allow that, there's a bit of complexity. The management network's
gateway is used as the default route of each host. If you change the
role, all hosts should be notified (with a new setupNetwork command).

I think that the cleanest solution would be to allow editing, but report
the hosts as out-of-sync. This approach requires a Vdsm-side change - it
would need to report which of its network is the default route.

Dan.
___
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel


Re: [ovirt-devel] popup dialog

2014-08-15 Thread Vojtech Szocs


- Original Message -
 From: Leaboy wlblea...@126.com
 To: Vojtech Szocs vsz...@redhat.com
 Cc: devel@ovirt.org
 Sent: Friday, August 15, 2014 9:31:34 AM
 Subject: Re: [ovirt-devel] popup dialog
 
 which type does result.getReturnValue() got,

public void executed(FrontendActionAsyncResult result) { ... }

result.getReturnValue() returns VdcReturnValueBase

result.getReturnValue().getActionReturnValue() returns
the result of backend command (action) execution

For example, your backend command does this:

  getReturnValue().setActionReturnValue(obj);

Then obj is what you get on frontend with:

  result.getReturnValue().getActionReturnValue();

 
 And how could I set it in the backend.
 
 在 8/14/14, 21:57, Vojtech Szocs vsz...@redhat.com 写入:
 
 
 
 - Original Message -
  From: Leaboy wlblea...@126.com
  To: Vojtech Szocs vsz...@redhat.com
  Cc: devel@ovirt.org
  Sent: Thursday, August 14, 2014 2:12:37 PM
  Subject: Re: [ovirt-devel] popup dialog
  
  Hi:
  you said that ,I have done, and the dialog
  Can display, and I can pass a parameter from dialog
  To the backend executeCommand().
  
  Now the question is, after executeCommand(),
  Hou could I get the return value in the frontend.
  
  For example, when I clicked backup button,
  A dialog is display, now I type some parameters into
  The dialog, click OK button, the backend executeCommand()
  Do something, now, I need some value from executeCommand()
  to frontend.
 
 Sorry, I missed that your question was about executing backend
 command (I thought you referred to Model.executeCommand) ...
 
 Backup dialog's OK button is represented by:
 
   UICommand tempVar = new UICommand(OnBackup, this);
 
 When user clicks OK button, that ^^ UICommand is executed.
 Model's executeCommand should route flow to some onBackup()
 method, I assume you already did this:
 
   // inside TemplateListModel#executeCommand
   ...
   else if (OnBackup.equals(command.getName())) {
 onBackup();
   }
   ...
 
   // inside TemplateListModel
   private void onBackup() {
 TemplateBackupModel windowModel = (TemplateBackupModel) getWindow();
 
 // do nothing if windowModel is already doing something -or- if
 // windowModel validation failed (i.e. bad/missing user input)
 if (windowModel.getProgress() != null || !windowModel.validate()) {
   return;
 }
 
 // this replaces dialog content UI with progress animated image
 // to indicate that a call to backend is about to be initiated
 windowModel.startProgress(null);
 
 // on backend, assume you have TemplateBackupCommand that works
 // with parameter type TemplateBackupParameters
 TemplateBackupParameters params = new TemplateBackupParameters();
 // update params according to window model
 params.setFoo(windowModel.getFoo().getEntity());
 
 // this is the async callback executed when backend command
 // (TemplateBackupCommand in our case) has done its job
 IFrontendActionAsyncCallback callback = new
 IFrontendActionAsyncCallback() {
   @Override
   public void executed(FrontendActionAsyncResult result) {
 TemplateListModel listModel = (TemplateListModel)
 result.getState();
 listModel.postOnBackup(result.getReturnValue());
   }
 };
 
 // call backend
 Frontend.getInstance().runAction(
   VdcActionType.TemplateBackup, params, callback, this);
   }
 
   // still inside TemplateListModel
   private void postOnBackup(VdcReturnValueBase returnValue) {
 // at this point, backend has replied with returnValue,
 // we can remove progress animated image in dialog
 getWindow().stopProgress();
 
 // if the backend operation was successful, close the
 // dialog (otherwise the dialog will remain open)
 if (returnValue != null  returnValue.getSucceeded()) {
   setWindow(null);
 }
   }
 
 Regards,
 Vojtech
 
 
  
  
  在 8/14/14, 19:48, Vojtech Szocs vsz...@redhat.com 写入:
  
  
  
  - Original Message -
   From: Leaboy wlblea...@126.com
   To: Vojtech Szocs vsz...@redhat.com
   Cc: devel@ovirt.org
   Sent: Thursday, August 14, 2014 6:19:17 AM
   Subject: Re: [ovirt-devel] popup dialog
   
   Hi,Vojtech Szocs:
   Thanks for your help, I have let it work,
   
   The Error I got just because I miss the step 3 you noted.
   
   Another question is how could I got the returnValue after
   executeCommand , and let the returnValue display on the oher
   Popup dialog.
  
  Please add this into MainTabTemplateView:
  
...
getTable().addActionButton(new
  WebAdminButtonDefinitionVmTemplate(constants.templateBackup()) {
  @Override
  protected UICommand resolveCommand() {
return getMainModel().getTemplateBackupCommand();
  }
});
...
  
  This adds a button under Template main tab. When clicked, it executes
  given command (getTemplateBackupCommand) on model (TemplateListModel).
  
  Model's executeCommand() ensures that backup() method is 

[ovirt-devel] What does your oVirt development environment look like?

2014-08-15 Thread Adam Litke

Ever since starting to work on oVirt around 3 years ago I've been
striving for the perfect development and test environment.  I was
inspired by Yaniv's recent deep dive on Foreman integration and
thought I'd ask people to share their setups and any tips and tricks
so we can all become better, more efficient developers.

My setup consists of my main work laptop and two mini-Dell servers.  I
run the engine on my laptop and I serve NFS and iSCSI (using
targetcli) from this system as well.  I use the ethernet port on the
laptop to connect it to a subnet with the two Dell systems.

Some goals for my setup are:
- Easy provisioning of the virt-hosts so I can quickly test on Fedora
  and CentOS without spending lots of time reinstalling
- Ability to test block and nfs storage
- Automation of test scenarios involving engine and hosts

To help me reach these goals I've deployed cobbler on my laptop and it
does a pretty good job at managing PXE boot configurations for my
hosts (and VMs) so they can be automatically intalled as needed.
After viewing Yaniv's presentation, it seems that Forman/Puppet are
the way of the future but it does seem a bit more involved to set up.
I am definitely curious if others are using Foreman in their personal
dev/test environment and can offer some insight on how that is working
out.

Thanks, and I look forward to reading about more of your setups!  If
we get enough of these, maybe this could make a good section of the
wiki.

--
Adam Litke
___
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel


Re: [ovirt-devel] What does your oVirt development environment look like?

2014-08-15 Thread ybronhei

On 08/15/2014 09:32 AM, Adam Litke wrote:

Ever since starting to work on oVirt around 3 years ago I've been
striving for the perfect development and test environment.  I was
inspired by Yaniv's recent deep dive on Foreman integration and
thought I'd ask people to share their setups and any tips and tricks
so we can all become better, more efficient developers.

My setup consists of my main work laptop and two mini-Dell servers.  I
run the engine on my laptop and I serve NFS and iSCSI (using
targetcli) from this system as well.  I use the ethernet port on the
laptop to connect it to a subnet with the two Dell systems.

Some goals for my setup are:
- Easy provisioning of the virt-hosts so I can quickly test on Fedora
   and CentOS without spending lots of time reinstalling
- Ability to test block and nfs storage
- Automation of test scenarios involving engine and hosts

To help me reach these goals I've deployed cobbler on my laptop and it
does a pretty good job at managing PXE boot configurations for my
hosts (and VMs) so they can be automatically intalled as needed.
After viewing Yaniv's presentation, it seems that Forman/Puppet are
the way of the future but it does seem a bit more involved to set up.
I am definitely curious if others are using Foreman in their personal
dev/test environment and can offer some insight on how that is working
out.

Thanks, and I look forward to reading about more of your setups!  If
we get enough of these, maybe this could make a good section of the
wiki.

Heppy to hear :) for those who missed - 
https://www.youtube.com/watch?v=gozX891kYAY


each one has its own needs and goals I guess, but if you say it might 
help, I'll never say no for sharing :P
I have 3 dells under my desk, I compile the engine a lot and its heavy 
for my laptop. So I clone my local working directory and build it on the 
strongest mini-dell using local jenkins server 
(http://www.ovirt.org/Local_Jenkins_For_The_People). The other 2 I use 
as hypervisor when needed. provision them is done by me manually :/.. 
cobbler pxe boot could help with already defined image..  Other then 
that, I have nfs mount for storage and few vms for compilation and small 
tests


sorry I can't help with your curiosity .. my env quite simple

Regards,
Yaniv Bronhaim.

___
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel


Re: [ovirt-devel] What does your oVirt development environment look like?

2014-08-15 Thread Yair Zaslavsky


- Original Message -
 From: ybronhei ybron...@redhat.com
 To: Adam Litke ali...@redhat.com, devel@ovirt.org
 Sent: Friday, August 15, 2014 7:36:23 PM
 Subject: Re: [ovirt-devel] What does your oVirt development environment look  
 like?
 
 On 08/15/2014 09:32 AM, Adam Litke wrote:
  Ever since starting to work on oVirt around 3 years ago I've been
  striving for the perfect development and test environment.  I was
  inspired by Yaniv's recent deep dive on Foreman integration and
  thought I'd ask people to share their setups and any tips and tricks
  so we can all become better, more efficient developers.
 
  My setup consists of my main work laptop and two mini-Dell servers.  I
  run the engine on my laptop and I serve NFS and iSCSI (using
  targetcli) from this system as well.  I use the ethernet port on the
  laptop to connect it to a subnet with the two Dell systems.
 
  Some goals for my setup are:
  - Easy provisioning of the virt-hosts so I can quickly test on Fedora
 and CentOS without spending lots of time reinstalling
  - Ability to test block and nfs storage
  - Automation of test scenarios involving engine and hosts
 
  To help me reach these goals I've deployed cobbler on my laptop and it
  does a pretty good job at managing PXE boot configurations for my
  hosts (and VMs) so they can be automatically intalled as needed.
  After viewing Yaniv's presentation, it seems that Forman/Puppet are
  the way of the future but it does seem a bit more involved to set up.
  I am definitely curious if others are using Foreman in their personal
  dev/test environment and can offer some insight on how that is working
  out.
 
  Thanks, and I look forward to reading about more of your setups!  If
  we get enough of these, maybe this could make a good section of the
  wiki.
 
 Heppy to hear :) for those who missed -
 https://www.youtube.com/watch?v=gozX891kYAY
 
 each one has its own needs and goals I guess, but if you say it might
 help, I'll never say no for sharing :P
 I have 3 dells under my desk, I compile the engine a lot and its heavy
 for my laptop. So I clone my local working directory and build it on the
 strongest mini-dell using local jenkins server
 (http://www.ovirt.org/Local_Jenkins_For_The_People). The other 2 I use
 as hypervisor when needed. provision them is done by me manually :/..
 cobbler pxe boot could help with already defined image..  Other then
 that, I have nfs mount for storage and few vms for compilation and small
 tests

Haven't used Jenkins for the people for quite some time, it's awesome though.
Yaniv, does your Jenkins build all your local branches? 
I don't have much to share, my environment is even simpler.
I am sure it's a common knowledge but still a reminder (even if a new developer 
can benefit from it, it will be good) -
you can create a database schema per each branch you work on, and if needed to 
switch between branches, you don't have to destroy your current database.
Quite helpful, I must say , for someone who works 100% on engine related stuff.

Yair

 
 sorry I can't help with your curiosity .. my env quite simple
 
 Regards,
 Yaniv Bronhaim.
 
 ___
 Devel mailing list
 Devel@ovirt.org
 http://lists.ovirt.org/mailman/listinfo/devel
 
___
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel


Re: [ovirt-devel] What does your oVirt development environment look like?

2014-08-15 Thread Adam Litke

On 15/08/14 15:57 -0400, Yair Zaslavsky wrote:



- Original Message -

From: ybronhei ybron...@redhat.com
To: Adam Litke ali...@redhat.com, devel@ovirt.org
Sent: Friday, August 15, 2014 7:36:23 PM
Subject: Re: [ovirt-devel] What does your oVirt development environment look
like?

On 08/15/2014 09:32 AM, Adam Litke wrote:
 Ever since starting to work on oVirt around 3 years ago I've been
 striving for the perfect development and test environment.  I was
 inspired by Yaniv's recent deep dive on Foreman integration and
 thought I'd ask people to share their setups and any tips and tricks
 so we can all become better, more efficient developers.

 My setup consists of my main work laptop and two mini-Dell servers.  I
 run the engine on my laptop and I serve NFS and iSCSI (using
 targetcli) from this system as well.  I use the ethernet port on the
 laptop to connect it to a subnet with the two Dell systems.

 Some goals for my setup are:
 - Easy provisioning of the virt-hosts so I can quickly test on Fedora
and CentOS without spending lots of time reinstalling
 - Ability to test block and nfs storage
 - Automation of test scenarios involving engine and hosts

 To help me reach these goals I've deployed cobbler on my laptop and it
 does a pretty good job at managing PXE boot configurations for my
 hosts (and VMs) so they can be automatically intalled as needed.
 After viewing Yaniv's presentation, it seems that Forman/Puppet are
 the way of the future but it does seem a bit more involved to set up.
 I am definitely curious if others are using Foreman in their personal
 dev/test environment and can offer some insight on how that is working
 out.

 Thanks, and I look forward to reading about more of your setups!  If
 we get enough of these, maybe this could make a good section of the
 wiki.

Heppy to hear :) for those who missed -
https://www.youtube.com/watch?v=gozX891kYAY

each one has its own needs and goals I guess, but if you say it might
help, I'll never say no for sharing :P
I have 3 dells under my desk, I compile the engine a lot and its heavy
for my laptop. So I clone my local working directory and build it on the
strongest mini-dell using local jenkins server
(http://www.ovirt.org/Local_Jenkins_For_The_People). The other 2 I use
as hypervisor when needed. provision them is done by me manually :/..
cobbler pxe boot could help with already defined image..  Other then
that, I have nfs mount for storage and few vms for compilation and small
tests


Haven't used Jenkins for the people for quite some time, it's
awesome though.  Yaniv, does your Jenkins build all your local
branches?  I don't have much to share, my environment is even
simpler.  I am sure it's a common knowledge but still a reminder
(even if a new developer can benefit from it, it will be good) - you
can create a database schema per each branch you work on, and if
needed to switch between branches, you don't have to destroy your
current database.  Quite helpful, I must say , for someone who works
100% on engine related stuff.


Thanks for sharing... How do you manage your multiple db schemas?
Just with the engine-backup and engine-restore commands?


--
Adam Litke
___
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel


Re: [ovirt-devel] What does your oVirt development environment look like?

2014-08-15 Thread Adam Litke

On 15/08/14 16:20 -0400, Alon Bar-Lev wrote:



- Original Message -

From: Adam Litke ali...@redhat.com
To: Yair Zaslavsky yzasl...@redhat.com
Cc: devel@ovirt.org
Sent: Friday, August 15, 2014 11:17:05 PM
Subject: Re: [ovirt-devel] What does your oVirt development environment look 
like?

On 15/08/14 15:57 -0400, Yair Zaslavsky wrote:


- Original Message -
 From: ybronhei ybron...@redhat.com
 To: Adam Litke ali...@redhat.com, devel@ovirt.org
 Sent: Friday, August 15, 2014 7:36:23 PM
 Subject: Re: [ovirt-devel] What does your oVirt development environment
 look   like?

 On 08/15/2014 09:32 AM, Adam Litke wrote:
  Ever since starting to work on oVirt around 3 years ago I've been
  striving for the perfect development and test environment.  I was
  inspired by Yaniv's recent deep dive on Foreman integration and
  thought I'd ask people to share their setups and any tips and tricks
  so we can all become better, more efficient developers.
 
  My setup consists of my main work laptop and two mini-Dell servers.  I
  run the engine on my laptop and I serve NFS and iSCSI (using
  targetcli) from this system as well.  I use the ethernet port on the
  laptop to connect it to a subnet with the two Dell systems.
 
  Some goals for my setup are:
  - Easy provisioning of the virt-hosts so I can quickly test on Fedora
 and CentOS without spending lots of time reinstalling
  - Ability to test block and nfs storage
  - Automation of test scenarios involving engine and hosts
 
  To help me reach these goals I've deployed cobbler on my laptop and it
  does a pretty good job at managing PXE boot configurations for my
  hosts (and VMs) so they can be automatically intalled as needed.
  After viewing Yaniv's presentation, it seems that Forman/Puppet are
  the way of the future but it does seem a bit more involved to set up.
  I am definitely curious if others are using Foreman in their personal
  dev/test environment and can offer some insight on how that is working
  out.
 
  Thanks, and I look forward to reading about more of your setups!  If
  we get enough of these, maybe this could make a good section of the
  wiki.
 
 Heppy to hear :) for those who missed -
 https://www.youtube.com/watch?v=gozX891kYAY

 each one has its own needs and goals I guess, but if you say it might
 help, I'll never say no for sharing :P
 I have 3 dells under my desk, I compile the engine a lot and its heavy
 for my laptop. So I clone my local working directory and build it on the
 strongest mini-dell using local jenkins server
 (http://www.ovirt.org/Local_Jenkins_For_The_People). The other 2 I use
 as hypervisor when needed. provision them is done by me manually :/..
 cobbler pxe boot could help with already defined image..  Other then
 that, I have nfs mount for storage and few vms for compilation and small
 tests

Haven't used Jenkins for the people for quite some time, it's
awesome though.  Yaniv, does your Jenkins build all your local
branches?  I don't have much to share, my environment is even
simpler.  I am sure it's a common knowledge but still a reminder
(even if a new developer can benefit from it, it will be good) - you
can create a database schema per each branch you work on, and if
needed to switch between branches, you don't have to destroy your
current database.  Quite helpful, I must say , for someone who works
100% on engine related stuff.

Thanks for sharing... How do you manage your multiple db schemas?
Just with the engine-backup and engine-restore commands?


just create N empty databases, install each environment to different PREFIX and 
when running engine-setup select one for each environment.


Even better.  Thank you!


refer to README.developer at engine repo.

BTW: with proper listen ports customization, you can even have N engine 
instances running at same machine at same time.

Alon


--
Adam Litke
___
Devel mailing list
Devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel


Re: [ovirt-devel] popup dialog

2014-08-15 Thread Leaboy
Yes, I have done that, thanks.

在 8/15/14, 20:13, Vojtech Szocs vsz...@redhat.com 写入:



- Original Message -
 From: Leaboy wlblea...@126.com
 To: Vojtech Szocs vsz...@redhat.com
 Cc: devel@ovirt.org
 Sent: Friday, August 15, 2014 9:31:34 AM
 Subject: Re: [ovirt-devel] popup dialog
 
 which type does result.getReturnValue() got,

public void executed(FrontendActionAsyncResult result) { ... }

result.getReturnValue() returns VdcReturnValueBase

result.getReturnValue().getActionReturnValue() returns
the result of backend command (action) execution

For example, your backend command does this:

  getReturnValue().setActionReturnValue(obj);

Then obj is what you get on frontend with:

  result.getReturnValue().getActionReturnValue();

 
 And how could I set it in the backend.
 
 在 8/14/14, 21:57, Vojtech Szocs vsz...@redhat.com 写入:
 
 
 
 - Original Message -
  From: Leaboy wlblea...@126.com
  To: Vojtech Szocs vsz...@redhat.com
  Cc: devel@ovirt.org
  Sent: Thursday, August 14, 2014 2:12:37 PM
  Subject: Re: [ovirt-devel] popup dialog
  
  Hi:
  you said that ,I have done, and the dialog
  Can display, and I can pass a parameter from dialog
  To the backend executeCommand().
  
  Now the question is, after executeCommand(),
  Hou could I get the return value in the frontend.
  
  For example, when I clicked backup button,
  A dialog is display, now I type some parameters into
  The dialog, click OK button, the backend executeCommand()
  Do something, now, I need some value from executeCommand()
  to frontend.
 
 Sorry, I missed that your question was about executing backend
 command (I thought you referred to Model.executeCommand) ...
 
 Backup dialog's OK button is represented by:
 
   UICommand tempVar = new UICommand(OnBackup, this);
 
 When user clicks OK button, that ^^ UICommand is executed.
 Model's executeCommand should route flow to some onBackup()
 method, I assume you already did this:
 
   // inside TemplateListModel#executeCommand
   ...
   else if (OnBackup.equals(command.getName())) {
 onBackup();
   }
   ...
 
   // inside TemplateListModel
   private void onBackup() {
 TemplateBackupModel windowModel = (TemplateBackupModel)
getWindow();
 
 // do nothing if windowModel is already doing something -or- if
 // windowModel validation failed (i.e. bad/missing user input)
 if (windowModel.getProgress() != null || !windowModel.validate()) {
   return;
 }
 
 // this replaces dialog content UI with progress animated image
 // to indicate that a call to backend is about to be initiated
 windowModel.startProgress(null);
 
 // on backend, assume you have TemplateBackupCommand that works
 // with parameter type TemplateBackupParameters
 TemplateBackupParameters params = new TemplateBackupParameters();
 // update params according to window model
 params.setFoo(windowModel.getFoo().getEntity());
 
 // this is the async callback executed when backend command
 // (TemplateBackupCommand in our case) has done its job
 IFrontendActionAsyncCallback callback = new
 IFrontendActionAsyncCallback() {
   @Override
   public void executed(FrontendActionAsyncResult result) {
 TemplateListModel listModel = (TemplateListModel)
 result.getState();
 listModel.postOnBackup(result.getReturnValue());
   }
 };
 
 // call backend
 Frontend.getInstance().runAction(
   VdcActionType.TemplateBackup, params, callback, this);
   }
 
   // still inside TemplateListModel
   private void postOnBackup(VdcReturnValueBase returnValue) {
 // at this point, backend has replied with returnValue,
 // we can remove progress animated image in dialog
 getWindow().stopProgress();
 
 // if the backend operation was successful, close the
 // dialog (otherwise the dialog will remain open)
 if (returnValue != null  returnValue.getSucceeded()) {
   setWindow(null);
 }
   }
 
 Regards,
 Vojtech
 
 
  
  
  在 8/14/14, 19:48, Vojtech Szocs vsz...@redhat.com 写入:
  
  
  
  - Original Message -
   From: Leaboy wlblea...@126.com
   To: Vojtech Szocs vsz...@redhat.com
   Cc: devel@ovirt.org
   Sent: Thursday, August 14, 2014 6:19:17 AM
   Subject: Re: [ovirt-devel] popup dialog
   
   Hi,Vojtech Szocs:
   Thanks for your help, I have let it work,
   
   The Error I got just because I miss the step 3 you noted.
   
   Another question is how could I got the returnValue after
   executeCommand , and let the returnValue display on the oher
   Popup dialog.
  
  Please add this into MainTabTemplateView:
  
...
getTable().addActionButton(new
  WebAdminButtonDefinitionVmTemplate(constants.templateBackup()) {
  @Override
  protected UICommand resolveCommand() {
return getMainModel().getTemplateBackupCommand();
  }
});
...
  
  This adds a button under Template main tab. When clicked, it
executes
  given command (getTemplateBackupCommand) on