cancel
Showing results for 
Search instead for 
Did you mean: 

Creating and passing a model, outside a controller class.

Former Member
0 Kudos

Hi,

My first steps in bsp with MVC.....

I'm modifying the automatically (via Web Interface Builder) created oninputprocessing event of a bsp page. In this page i have a table available, which i want to pass to my custom page.

Following MVC logic I thought up the following:

- in the event i create an object type ref to a custom model class

- now i pass my event table to this object

- then i pass this object to my custom controller, which then should have availability over the table

.....but i can't seem to get this to work.

Now i have a few questions:

- is it correct to first create the model object and then pass it to the controller? (if so, do you have an example of how to create the model class instance outside a controller class?)

- how do i pass object/instance to a controller?(can this be done with url? e.g. main.do?value=..... ?)

I feel my sollution could work (even if it wouldn't be the right approach), but i lack the knowledge to implement it.

Thanx in advance for your reaction.

Martijn.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Sebastian and Thomas,

I decided to solve my issue without the application class, although it did gave me a different overview on the application. So thnx for that.

Further more, i also didn't use the sollution of passing an object via a cookie, but extracted some tables of it and passed them to the other applications via a deep structure in a cookie. But the weblog cleared a few points i had about the cookies and in the near future i will definately try to pass an object in that way. So also thnx for that.

Thnx for your input!

Kind regards,

Martijn de Jong.

Former Member
0 Kudos

Hi Sebastian,

Does this also work between 2 different bsp applications? I tested your sollution, but it didn't and i do not see how this would work.

I have 2 bsp applications, each with their own application class. If in the second class i cast the application class to my own, it creates an object but with all "illegal references". I am getting a bit desperate, because it doesn't seem hard, but i feel i'm missing something.

Doe you have any more suggestions? Especially regarding the 2 seperated bsp-applications?

Kind regards,

Martijn.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Here is a weblog where I pass a model instance between two different applciations:

/people/thomas.jung3/blog/2005/05/27/custom-bsp-extension-element-for-field-level-help

Perhaps this will help with the solution you are looking for.

I create the model instance in one application. I then serialize it to XML and write it into a server cookie. I pass a GUID key for server cookie via URL parameter to my second application. This application then reads the server cookie, deserializes the object and instaniates it as its own model.

Former Member
0 Kudos

Hi Sebastian,

Thanx for your quick reply. I completely forgot about the application class functionality. Although i searched for a good example on how to implement the logic for using the application class between 2 different applications, i couldn't find the right answer.

Could you please tell me how to get the attributes of the automaticaly created aplication class available in my custom application class? So before calling my "main.do", what do i have to program? (or point me to an example?)

Kind regards,

Martijn.

Former Member
0 Kudos

Hi,

to make your application object available you hav to cast it to the right type.

In controller:

data app type ref to your_application_class.

app ?= application.

app->your_attribute is now available.

Regards,

Sebastian

Former Member
0 Kudos

Hi,

please do not try to put MVC on the head. Of course it would be possible - but I would not suppose to do it your way.

In your case I would you use at first a application class (search on sdn how to use) for saveing your table from oninputprocessing to the it.

Next you call the controller (the controller will know application object at runtime). In controllers do_init() you should instantiate you model and pass the table from application object to it.

In result you have the model correct available in controller for calling any view.

Regards,

Sebastian