How to pass values to a new open(created) window (dialog, panel, page etc) with MVVM in Blazor - mvvm

I have "PageMain" with "PageMainViewModel" binded, there is a "Edit" button in "PageMain", What is the best practice in MVVM for Blazor to pass the values(example:ProductInfo) to the new opened edit form window ("EditFormWindow") when the "Edit" button is clicked?
I used to use the massagers to communicate between each viewmodel, but in this case, the "EditFormWindow" is new opened, Even I added a register of messager in the constructor of "EditFormWindowViewModel", when sending message (passing data) from "PageMainViewModel", the "EditFormWindowViewModel" is not initialized yet so "EditFormWindowViewModel" cannot receive the message(passed data) from "EditFormWindow".
What I am doing now is to pass the values from View (Balzor file) to Viewmodel, but I am wondering if there is a better solution that I don't have to write any codes in View(Blazor file).

Related

How to pass an object while routing to new view in SAPUI5

In my application, I am opening a new page in a new tab when the user clicked on a button. This new page displays the data which it received from the previous page. I am able to retain the object data by setting the JSON model to the UI core or view if I use navTo() and don't load the view in a new tab. But, when I try to open the view in a new tab the model is getting destroyed.
Please, let me know if this can be achieved in UI5 and how.
Thanks in advance.
Venkatesh.

How do I use Binding path/context to build (multi-page app) using a single view / controller?

I'm building a create survey / questionnaire app, where each question has the exact same format bound to a model.
Is it possible to do this with one controller + view and simply manipulate the binding context/path?
I've created a single view for this in SAP WEB IDE. When I go click on the "Add New question" button, (to display the input for Question 2) how exactly do I setup the new binding path/context to accept data for it?

ICommand not binding in Loaded event using MVVMLight framework

I am wondering why binding a button inside the Loaded event in WPF page does not work and will only work after navigating to another page, and going back.
I have an inventory app and on the main page, most of the ViewModel are called because of a Back button which goes back to a specific lists and what causes that is, it will start binding the even if that command is not for that page and it will also load the collections for other pages.
So I used Loaded page event to call the necessary methods to populate the lists and also start binding commands for this specific page. I also used Unloaded page event for clean up like unsubscribing to some CRUD events.
The problem now though is, buttons does not get binding in Loaded page event. I do not know why..
I have made a miniature app to demo the problem. It can be downloaded here
(full source code included)
https://www.dropbox.com/s/qzumzyicuvrktsi/ICommandTest.zip?dl=0
This is because your views are not getting notified about the change of Command_ShowAddWindow and Command_ClickMe. Let me explain:
When your Page constructor is first run the bindings to your commands are initialized and transferred to the view, but by that time your commands are null, so the view binds both buttons' commands to null.
Then when your Loaded event is fired the commands are initialized, but the view is not getting notified about it, so it keeps command bindings to null.
The solutions to the problem are:
You manually call RaisePropertyChanged to notify the view about commands change when you initialize them:
void InitCommands()
{
Command_ShowAddWindow = new RelayCommand(Command_ShowAddWindow_Click);
Command_ClickMe = new RelayCommand(Command_ClickMe_Click);
RaisePropertyChanged("Command_ShowAddWindow");
RaisePropertyChanged("Command_ClickMe");
}
Or you initialize your commands in your ViewModel constructor before DataBindings are initialized:
public ViewModel_Page1()
{
InitCommands();
...
}

in YII2 how to post data using modal dialog?

I'm using modal dialog. I'm working with two modal. User Model and STATE Model where
User is Parent model and state/create is open in modal dialog.
when I'm creating new User, I have select state name from drop-down, if it is not listed in dd then it will create state by clicking add new state and open in modal dialog and create state.
Issue is after create new state parent page is refresh and all the data which I have added are removed.
Kindly guide me. I have created modal dialog by below link
Not sure if I understand your problem correctly because there is no example code. But if you have separate form to add new state then you can submit that form with ajax using beforeSubmitevent of ActiveForm.
An example of beforeSubmitevent implementation you can find in this issue
Also in your controller action you will have to set response type to json like following
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
More info on response types.

Best way to update view from command or filedialog in an eclipse rcp application

In my application I have a menu which open a SelectionDialog, this dialog is used to choose an object.
When this object is selected I have to display it in the view.
What is the best way to update my view?
Currently, I call myview.update(object) after the dialog is closed (in the handler of the menu). But I think this solution is not well design.
I have read about update my model and notify my view but my model does not change (no data are changed, I only display different Data ).
Does anyone has some ideas for a well design solution ?
Define model listener ( dataPopulated(Event e))
Make your view implement model listener and register it with the Model.
Define a Model class that can contain the objects that you want to populate in the view
When Model.setInput(Object input) is invoked fire dataPopulated() event on all registered model listeners.
Above steps works properly when you have view activated. You need to consider cases like when if view is deactivated or not visible ( make sure you refresh view is visible else you will have unnecessary overhead of refreshing view though it is notvisible)
Try adding a selection listener in the view and register this selection in the dialog.
In the listener action, add the code to show the selected object.