Datacontroller init

32 views
Skip to first unread message

sebth

unread,
Mar 19, 2012, 7:26:58 AM3/19/12
to InterSystems: Zen Community
Hello,

does anybody know how to create a new Object of a Datamodel after a
page is created? The scenario is creating a new empty object of my
modelclass if a User Click Create New Customer wich open a Popup to
enter Customer Information. So i guess after opening the popup and
after create the page I need somehow to call
zen('dcCustomer').createNewObject();

How can i do this?

Sebastian

Dawn Wolthuis

unread,
Mar 19, 2012, 7:49:04 AM3/19/12
to intersys...@googlegroups.com
Yes, it should work just as you indicated. What is going wrong with
this approach? I do not work with popups, but whatever event is
triggering the popup could also include this code. --dawn

> --
> You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
> To post to this group, send email to InterSys...@googlegroups.com
> To unsubscribe from this group, send email to InterSystems-Z...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/InterSystems-ZEN?hl=en
> Zen Community Terms and Conditions: http://groups.google.com/group/InterSystems-ZEN/web/community-terms-and-conditions

--
Dawn M. Wolthuis

Take and give some delight today

sebth

unread,
Mar 19, 2012, 9:17:16 AM3/19/12
to InterSystems: Zen Community
Maybe my explanation wasn´t that clear sry for that. I got a page for
customer information. This page hold a link to create a new Customer -
clicking on it, a new popup will be opened. The popup got a
datacontroller which is assigned to modelclass 'CustomerModel' - now
this page offers a form to Input information of the customer someone
want to create. I don´t want to have a button in this popup and call
zen('dcCustomer').createNewObject. I wan´t to call it without clicking
on any buttons. My Idea was to do zen('dcCustomer').createNewObject
just after the page/popup was created. But how to call it? I tried
%OnAfterCreatePage with this js code but a new Object wasn´t created.

On 19 Mrz., 12:49, Dawn Wolthuis <dw...@tincat-group.com> wrote:
> Yes, it should work just as you indicated. What is going wrong with
> this approach? I do not work with popups, but whatever event is
> triggering the popup could also include this code.  --dawn
>
>
>
>
>
>
>
>
>
> On Mon, Mar 19, 2012 at 6:26 AM, sebth <sebastian.thi...@live.de> wrote:
> > Hello,
>
> > does anybody know how to create a new Object of a Datamodel after a
> > page is created? The scenario is creating a new empty object of my
> > modelclass if a User Click Create New Customer wich open a Popup to
> > enter Customer Information. So i guess after opening the popup and
> > after create the page I need somehow to call
> > zen('dcCustomer').createNewObject();
>
> > How can i do this?
>
> > Sebastian
>
> > --
> > You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
> > To post to this group, send email to InterSys...@googlegroups.com
> > To unsubscribe from this group, send email to InterSystems-Z...@googlegroups.com
> > For more options, visit this group athttp://groups.google.com/group/InterSystems-ZEN?hl=en
> > Zen Community Terms and Conditions:http://groups.google.com/group/InterSystems-ZEN/web/community-terms-a...

Dawn Wolthuis

unread,
Mar 19, 2012, 9:28:27 AM3/19/12
to intersys...@googlegroups.com
I have avoided modals, so I might not have a good understanding of the
issue. I do not know how you are initiating the popup, so I was
getting it was with a line of js, such as
onsomething="zenPage.showPopup()" -- is that close?

If so, can you add the controller line before or after that one? If
so, then you can show the popup from a separate js method that does
both. In other words, have the event handler for your first link for
creating a new customer handle both creating a new object and showing
the popup. Maybe someone who knows why the popup would pose a
complexity could better answer.

--dawn

> For more options, visit this group at http://groups.google.com/group/InterSystems-ZEN?hl=en
> Zen Community Terms and Conditions: http://groups.google.com/group/InterSystems-ZEN/web/community-terms-and-conditions

sebth

unread,
Mar 19, 2012, 12:12:32 PM3/19/12
to InterSystems: Zen Community
Dawn,

this is the method wich is invoked by clicking on new customer:

ClientMethod jsOnNewCustomerClick() [ Language = javascript ]
{
zenPage.launchPopupWindow(zenLink('nwP.ZEN.Admin.NewCustomer.cls'),
'Benutzer
anlegen','status,scrollbars=no,resizable=no,width=620,height=470');
}

A popup WIndow open. Which has the following datacontroller defined:

<dataController id="dcCustomer"
modelClass="nwP.ZEN.Model.CustomerModel" /> ; as you can see with no
modelId

Now i need to call the zen('dcCustomer').createNewObject(); JS Method
without any user Interaction. Once again the controller is on another
page - so fire createNewObject() would cause an error in Class A
because the controller is defined in Class B.

Sebastian

Dawn Wolthuis

unread,
Mar 19, 2012, 12:33:40 PM3/19/12
to intersys...@googlegroups.com
The code that would be helpful is the code that refers to
jsOnNewCustomerClick(). Is it an onclick= on a button? If so, then
have the button execute a different method that does both showing the
popup and creating a new controller object. To test that out, in the
onclick you can write
onclick="zenPage.jsOnNewCustomerClick();zen('dcCustomer').createNewObject();"

Does that help? Again, I might be out to lunch on this. --dawn

> For more options, visit this group at http://groups.google.com/group/InterSystems-ZEN?hl=en
> Zen Community Terms and Conditions: http://groups.google.com/group/InterSystems-ZEN/web/community-terms-and-conditions

sebth

unread,
Mar 19, 2012, 2:57:58 PM3/19/12
to InterSystems: Zen Community
This is the code which invoke the Popup:

<image id="imgPlusContact" src="/csp/nwpapp/images/nwp_Plus.png"
height="32px" width="32px" onclick="zenPage.jsOnNewCustomerClick();" /
>

since the controller is on another Page (the CreateNewCustomerPage) it
can´t be invoked by the above onclick method.

Sebastian

Dawn Wolthuis

unread,
Mar 19, 2012, 3:06:57 PM3/19/12
to intersys...@googlegroups.com
Ah, I can see that I do not understand the interactions of the pages
well-enough. If I want a new instance of a controller object in page
A, I also have a <dataController> element in page A. I suppose you
could pass the object around but I have not done anything of the
sort. Sorry I'm not more help on this. --dawn

> For more options, visit this group at http://groups.google.com/group/InterSystems-ZEN?hl=en
> Zen Community Terms and Conditions: http://groups.google.com/group/InterSystems-ZEN/web/community-terms-and-conditions

Vlado

unread,
Mar 19, 2012, 7:43:05 PM3/19/12
to intersys...@googlegroups.com
Seb,
It should be in:
ClientMethod onloadHandler() [ Language = javascript ]
{
zen('dcCustomer').createNewObject(); 
}
Although you can omit it if you use modelId=""

<dataController id="dcCustomer" 
modelClass="nwP.ZEN.Model.CustomerModel"  modelId=""/> 

and with direct save:
ClientMethod saveItem() [ Language = javascript ]
{
zen('myForm').save();
}
it will create new object.
**Владо
> >> >> > To post to this group, send email to InterSystems-ZEN@googlegroups.com
> >> >> > To unsubscribe from this group, send email to InterSystems-ZEN-unsubscribe@googlegroups.com
> >> >> > For more options, visit this group athttp://groups.google.com/group/InterSystems-ZEN?hl=en
> >> >> > Zen Community Terms and Conditions:http://groups.google.com/group/InterSystems-ZEN/web/community-terms-a...
>
> >> >> --
> >> >> Dawn M. Wolthuis
>
> >> >> Take and give some delight today
>
> >> > --
> >> > You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
> >> > To post to this group, send email to InterSystems-ZEN@googlegroups.com
> >> > To unsubscribe from this group, send email to InterSystems-ZEN-unsubscribe@googlegroups.com
> >> > For more options, visit this group athttp://groups.google.com/group/InterSystems-ZEN?hl=en
> >> > Zen Community Terms and Conditions:http://groups.google.com/group/InterSystems-ZEN/web/community-terms-a...
>
> >> --
> >> Dawn M. Wolthuis
>
> >> Take and give some delight today
>
> > --
> > You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
> > To post to this group, send email to InterSystems-ZEN@googlegroups.com
> > To unsubscribe from this group, send email to InterSystems-ZEN-unsubscribe@googlegroups.com

sebth

unread,
Mar 22, 2012, 5:45:11 AM3/22/12
to InterSystems: Zen Community
Thanks Vlado, sometimes it is that simple :)
> > InterSys...@googlegroups.com
> > > >> >> > To unsubscribe from this group, send email to
> > InterSystems-Z...@googlegroups.com
> > > >> >> > For more options, visit this group athttp://
> > groups.google.com/group/InterSystems-ZEN?hl=en
> > > >> >> > Zen Community Terms and Conditions:
> >http://groups.google.com/group/InterSystems-ZEN/web/community-terms-a...
>
> > > >> >> --
> > > >> >> Dawn M. Wolthuis
>
> > > >> >> Take and give some delight today
>
> > > >> > --
> > > >> > You received this message because you are subscribed to the Google
> > Groups "InterSystems: Zen Community" group.
> > > >> > To post to this group, send email to
> > InterSys...@googlegroups.com
> > > >> > To unsubscribe from this group, send email to
> > InterSystems-Z...@googlegroups.com
> > > >> > For more options, visit this group athttp://
> > groups.google.com/group/InterSystems-ZEN?hl=en
> > > >> > Zen Community Terms and Conditions:
> >http://groups.google.com/group/InterSystems-ZEN/web/community-terms-a...
>
> > > >> --
> > > >> Dawn M. Wolthuis
>
> > > >> Take and give some delight today
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups "InterSystems: Zen Community" group.
> > > > To post to this group, send email to InterSys...@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > InterSystems-Z...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages