-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
**How should be designed application in proper manner?Should I create separate view model for every page? For example I have pages like 'create-person.zul','list-persons.zul'. So have I create separatly CreatePersonViewModel.java, ListPersonsViewModel.java? At all is it possible to have one view model class for several pages that are connected by business logic? For example several pages for admin functionality have one AdminViewModel.
2 | No.2 Revision |
**How should be designed application in proper manner?Should I create separate view model for every page? For example I have pages like 'create-person.zul','list-persons.zul'. So have I create separatly CreatePersonViewModel.java, ListPersonsViewModel.java? At all is it possible to have one view model class for several pages that are connected by business logic? For example several pages for admin functionality have one AdminViewModel.
I have page1.zul
<window viewmodel="@id('vm') @init('MyViewModel')"> ..... <textbox value="myValue"/> and page2.zull
<window viewmodel="@id('vm') @init('MyViewModel')"> ..... <label value="myValue">** I have MyViewModel
public class MyViewModel
{
@WireVariable("myManager")
private MyManager myManager;
String getMyValue()
{
return myManager.getMyValue();
}
void setMyValue(String val) { myManager.setMyValue(val); }
} I have MyManager class - session scoped inside Spring container
@Component("myManager") @Scope("session") public class MyManager { String myValue; public String getMyValuee(){} public void setMyValue(String val) {...} } Now I can set the value to myValue at page1.zul and the value at page2.zul will be updated. How can I make it with different ViewModel for every page? Moreover I cannot save the state of myValue inside og MyViewModel because it's new for every request for same page.
3 | No.3 Revision |
**How should be designed application in proper manner?Should I create separate view model for every page? For example I have pages like 'create-person.zul','list-persons.zul'. So have I create separatly CreatePersonViewModel.java, ListPersonsViewModel.java? At all is it possible to have one view model class for several pages that are connected by business logic? For example several pages for admin functionality have one AdminViewModel.
I have page1.zul
<window
public class MyViewModel
{
@WireVariable("myManager")
private MyManager myManager;
String getMyValue()
{
return myManager.getMyValue();
@Component("myManager")
@Scope("session")
public class MyManager
{
String myValue;
public String getMyValuee(){}
public void setMyValue(String val) {...}
}
Now I can set the value to myValue at page1.zul and the value at page2.zul will be updated. How can I make it with different ViewModel for every page? Moreover I cannot save the state of myValue inside og MyViewModel because it's new for every request for same page.