override WebElement to remove <html> and <head>

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

override WebElement to remove <html> and <head>

Chris Dawson
I'm trying to build a widget with Aida and am not sure where I override in the framework to remove the <html> and <head>.  I just need to generate some Javascript code.  I also want to know how I override the content-type.  Thanks in advance.

Chris

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: override WebElement to remove <html> and <head>

Janko Mivšek
Hi Chris,

Chris Dawson wrote:
> I'm trying to build a widget with Aida and am not sure where I override
> in the framework to remove the <html> and <head>.  I just need to
> generate some Javascript code.  I also want to know how I override the
> content-type.  Thanks in advance.

This means that you'd like to respond to the web request with something
else than a complete web page?

If you want such (like JAvaSript), you do the following:
1. normaly write your App and a view method, say viewJS
2. in that App implement #contentType to return 'text/javascript'
3. in viewJS prepare a WebElement and addText: yourJSCode
4. simply return that element as result of this view

This should work.

Best regards
JAnko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: override WebElement to remove <html> and <head>

Chris Dawson
Janko,

Thanks for your response.  I understand this.  I don't understand how I can "install" this view into my webapp.

For example, I ran this code:

swazooWeb urlResolver defaultURL: '/photos.html' forObject: photos.

So, I can now access photos.html through the viewMain method on my app.  However, I then created a method called viewWidget.  How do I access this in my webapp?  Do I need to send urlResolver again?  How does my application know to route a request like "/widget.html" to viewWidget?

I've been playing with preferedUrl and I have not found a solution yet.

Thanks,
Chris

On Sat, May 24, 2008 at 2:48 PM, Janko Mivšek <[hidden email]> wrote:
Hi Chris,

Chris Dawson wrote:
> I'm trying to build a widget with Aida and am not sure where I override
> in the framework to remove the <html> and <head>.  I just need to
> generate some Javascript code.  I also want to know how I override the
> content-type.  Thanks in advance.

This means that you'd like to respond to the web request with something
else than a complete web page?

If you want such (like JAvaSript), you do the following:
1. normaly write your App and a view method, say viewJS
2. in that App implement #contentType to return 'text/javascript'
3. in viewJS prepare a WebElement and addText: yourJSCode
4. simply return that element as result of this view

This should work.

Best regards
JAnko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida


_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: override WebElement to remove <html> and <head>

Rob Rothwell
On Sat, May 24, 2008 at 8:21 PM, Chris Dawson <[hidden email]> wrote:
Janko,

Thanks for your response.  I understand this.  I don't understand how I can "install" this view into my webapp.

For example, I ran this code:

swazooWeb urlResolver defaultURL: '/photos.html' forObject: photos.

So, I can now access photos.html through the viewMain method on my app.  However, I then created a method called viewWidget.  How do I access this in my webapp?  Do I need to send urlResolver again?  How does my application know to route a request like "/widget.html" to viewWidget?

Aida is very "strict" about maintaining an MVC-like structure.  You create a link to another domain object; you don't "call" the view.

For example, if your photos object is a list of photos, and you want to "open" a photo with your Widget, then you would create a new instance of the Widget, and create a link to it in your PhotosApp, maybe like:

For example, if your photos object is a list of photos, and you want to "open" a photo with your Widget, then you would create a new instance of the Widget, and create a link to it in your PhotosApp, maybe like:

     PhotosApp>>viewMain
          |e|
          e := WebElement new.
          .....
          self photoList do: [:photo |
               widget := Widget forPhoto: photo.
               e addLinkTo: widget text: widget photoName.
               e addBreak.
          ].
          .....

where widget is an instance of your widget object.  Of course, I have assumed I have some idea of what you are trying to do!

Then you would need a corresponding WidgetApp with a viewMain that would do whatever you put in your viewWidget above.

Does this make sense?

Alternatively, you could use ViewTabs to show multiple aspects of a single object like I tried to explain here:

http://www.aidaweb.si/lists%20and%20tabs.html

Hope this gets some ideas flowing for a new round of questions,

Rob

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: override WebElement to remove <html> and <head>

Janko Mivšek
In reply to this post by Chris Dawson
Chris Dawson wrote:

> So, I can now access photos.html through the viewMain method on my app.  
> However, I then created a method called viewWidget.  How do I access
> this in my webapp?  Do I need to send urlResolver again?  How does my
> application know to route a request like "/widget.html" to viewWidget?
>
> I've been playing with preferedUrl and I have not found a solution yet.

Hi Chris,

I hope, I'm not too late for answer yet, you simply:

        /photos.html?view=widget

That is, you can access every view in your App directly by adding view
name in query part of url. Just the default view #main is called without
that query part. This is one of Aida' conventions, another one is that
which you already know: MyDomainObject -> MyDomainObjectApp.

Best regards
Janko


>
> Thanks,
> Chris
>
> On Sat, May 24, 2008 at 2:48 PM, Janko Mivšek <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi Chris,
>
>     Chris Dawson wrote:
>      > I'm trying to build a widget with Aida and am not sure where I
>     override
>      > in the framework to remove the <html> and <head>.  I just need to
>      > generate some Javascript code.  I also want to know how I
>     override the
>      > content-type.  Thanks in advance.
>
>     This means that you'd like to respond to the web request with something
>     else than a complete web page?
>
>     If you want such (like JAvaSript), you do the following:
>     1. normaly write your App and a view method, say viewJS
>     2. in that App implement #contentType to return 'text/javascript'
>     3. in viewJS prepare a WebElement and addText: yourJSCode
>     4. simply return that element as result of this view
>
>     This should work.
>
>     Best regards
>     JAnko
>
>
>     --
>     Janko Mivšek
>     AIDA/Web
>     Smalltalk Web Application Server
>     http://www.aidaweb.si
>     _______________________________________________
>     Aida mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.aidaweb.si/mailman/listinfo/aida
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: override WebElement to remove <html> and <head>

Rob Rothwell
On Sun, May 25, 2008 at 4:26 PM, Janko Mivšek <[hidden email]> wrote:
Chris Dawson wrote:

> So, I can now access photos.html through the viewMain method on my app.
> However, I then created a method called viewWidget.  How do I access
> this in my webapp?  Do I need to send urlResolver again?  How does my
> application know to route a request like "/widget.html" to viewWidget?
>
> I've been playing with preferedUrl and I have not found a solution yet.

Hi Chris,

I hope, I'm not too late for answer yet, you simply:

       /photos.html?view=widget

That is, you can access every view in your App directly by adding view
name in query part of url. Just the default view #main is called without
that query part. This is one of Aida' conventions, another one is that
which you already know: MyDomainObject -> MyDomainObjectApp.

Meaning from a browser?  So if my main app is

http://localhost:8888/mysite/myapp.html

and I want to write another view, I could get to it from

http://localhost:8888/mysite/myapp.html?view=anotherView  ???

can I link to it within the code as well?

I have a DataManager, which is a list of DataAbstractor(s), which contain DynamicRecords.  To define the fields within the DynamicRecord for a particular DataAbstractor, I was planning on creating a DynamicRecordDesigner, so I could create a Designer for: anAbstractor.

However, a designer could be another "view" in an abstractor--it would be like being in "design mode" vs "edit mode," but I didn't think I could do that...

Too many choices...!

Rob

 


Best regards
Janko


>
> Thanks,
> Chris
>
> On Sat, May 24, 2008 at 2:48 PM, Janko Mivšek <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi Chris,
>
>     Chris Dawson wrote:
>      > I'm trying to build a widget with Aida and am not sure where I
>     override
>      > in the framework to remove the <html> and <head>.  I just need to
>      > generate some Javascript code.  I also want to know how I
>     override the
>      > content-type.  Thanks in advance.
>
>     This means that you'd like to respond to the web request with something
>     else than a complete web page?
>
>     If you want such (like JAvaSript), you do the following:
>     1. normaly write your App and a view method, say viewJS
>     2. in that App implement #contentType to return 'text/javascript'
>     3. in viewJS prepare a WebElement and addText: yourJSCode
>     4. simply return that element as result of this view
>
>     This should work.
>
>     Best regards
>     JAnko
>
>
>     --
>     Janko Mivšek
>     AIDA/Web
>     Smalltalk Web Application Server
>     http://www.aidaweb.si
>     _______________________________________________
>     Aida mailing list
>     [hidden email] <mailto:[hidden email]>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida


_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: override WebElement to remove <html> and <head>

Rob Rothwell
On Sun, May 25, 2008 at 7:09 PM, Rob Rothwell <[hidden email]> wrote:
That is, you can access every view in your App directly by adding view
name in query part of url. Just the default view #main is called without
that query part. This is one of Aida' conventions, another one is that
which you already know: MyDomainObject -> MyDomainObjectApp.

Meaning from a browser?  So if my main app is

http://localhost:8888/mysite/myapp.html

and I want to write another view, I could get to it from

http://localhost:8888/mysite/myapp.html?view=anotherView  ???

can I link to it within the code as well?

Boy...I finally just discovered

    e addLinkTo: self text: 'another view' view: 'another',

which links to #viewAnother within the WebApplication referenced by self...

Rob


_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida