-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I tried to create a new component passing a map but the when i get the arg map it is empty.
Please show us the code.
I have to send to the new modal dialog a parameter ( the username of the logged in user)
Code of the main controller :
public void onClick$bNewTestList(Event event)
throws SuspendNotAllowedException, InterruptedException, ClassNotFoundException, SQLException, NamingException {
HashMap map = new HashMap<String, String>();
String username = ((Label)page.getFellow("lUsername")).getValue();
map.put("username", username);
final Window dialog = (Window) Executions.createComponents( "WindowNewTestList.zul",null , map);
dialog.doModal();
...........................
The controller code of the new component :
....................
public void onClick$bSaveTL (Event event) throws NamingException, SQLException {
String username = (String)execution.getArg().get("username"); <<<----- here the arg map is empty !!!
TestList testList = new TestList();
testList.setTL_CREATOR(username);
testList.setTL_NAME(tTestListName.getValue());
testList.setTL_DESCRIPTION(tTestListDescription.getValue());
TestListDAO testListDAO= new TestListDAO();
testListDAO.addTestList(testList);
self.detach();
}
.....................
catch it in the afterCompose method of the modal window
@Override public void doAfterCompose(Component window) throws Exception { super.doAfterCompose(window); if (arg.containsKey("username ")) { String s = (String) arg.get("username")); . . .
Terry,
Pardon my ignorance, where do you get the args from in the doAfterCompose?
When I call from one of my composer:
Window win = (Window) Executions.createComponents("/adduser.zul", userManagementWindow,
null);
win.setMaximizable(true);
try {
win.doModal();
} catch (SuspendNotAllowedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
And passing some arguments to this new zul page. How would I retrieve the arguments in the doAfterCompose of the new page?
Thanks in advance
Olivier
If you call super.doAfterCompose( comp ) from your doAfterCompose(...) in a GenericForwardComposer, the args variable is autowired for you. So, it will have all the values passed as the 3rd argument to Executions.createComponents(...).
like Cary said you can see the code in the GenericAutowireComposer from which the GenericForwardComposer inherits.
abstract public class GenericAutowireComposer extends GenericComposer implements ComponentCloneListener, ComponentActivationListener { private static final long serialVersionUID = 20091006115726L; private static final String COMPOSER_CLONE = "COMPOSER_CLONE"; . . . protected transient Map arg; /** Implicit Object; the param argument passed from the http request. * @since 3.6.1 */ . . .
.
It's the same as you do it manually like this
public class MyDialogCtrl extends GenericAutowireComposer implements Serializable { . . . public void onCreate$myDialogWindow(Event event) throws Exception { CreateEvent ce = (CreateEvent) ((ForwardEvent) event).getOrigin(); Map<Object, Object> arg = ce.getArg(); . . .
please, i have the same problem. i want to retrieve from a lististem template of "Product" an object "Product" and give it to a modal window to update it but i don't understand the mechanism. please, give an entire code to help me
look here
Please,i've already apply a bind composer and a view model to my first zul page.so I write code java in my first zul page to call modal window.but in the composer of my modal window,how I retrieve map "arg" .in the method after compose of the link you gave me,where does come from "arg". How to instantiate it to retrieve map.
Asked: 2010-09-07 00:53:36 +0800
Seen: 4,872 times
Last updated: Dec 27 '12