Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 17 total
Thread Questions from a new user
Wed, Nov 26 2014 6:29 PMPermanent Link

A.Kyr

Hi to all.
I follow for more than a year the EWB but only last days found the time to try seriously to test it in praxis. My test is to use it for a web front end of an existing 3tier application that uses kbmMW as data provider library.

I have managed up to now to build with EWB a small web application that access and retrieves data from my server (using kbmMW components) and fills back a EWB Dataset using JSON.
I would like to know from more experienced with EWB users the followings:
1.
My thought is to create html pages in appl.server with parameters given by EWB web application and pass them back to browser inside a TPage component for display. The returned html will contains a table referring to some records.  Is possible somehow - putting any tag, href or anything else inside the html that is created and sent back to EWB web aplication - clicking on an item in the html inside the TPage,  to call a procedure/function of my EWB program? (ex: to open a form for editing the specific record that is clicked).
In other words I want to keep the application control with EBW, use pure EWB controls for inserting/editing the data but use html for listing/displaying the data.
2.
When a custom appl.server is used - like in my case - which is the preferred way to inform the server side for the identity (credentials) in any single request after the succeeded login?

I hope that my questions are not too silly... Smile
Thanks in advance for your time

A.Kyriakos
Athens, Greece
Wed, Nov 26 2014 10:38 PMPermanent Link

Steve Gill

Avatar

Hi A,

<< 2.
When a custom appl.server is used - like in my case - which is the preferred way to inform the server side for the identity (credentials) in any single request after the succeeded login? >>

Not too sure about point #1 but with the 2nd point I use a unique session identifier. I use a PHP backend on the server but the principal is the same.

When the user successfully logs in, a session id is created by the server and passed back to the EWB app.  Whenever the EWB app sends a request to the server it passes back the session id. The session id is then checked and, if valid, the request is executed.  

The session automatically expires if no requests are received within a specific time, eg. 5 minutes.  Whenever a request is received within the time limit the "timer" is reset.

Hope that helps.

= Steve
Thu, Nov 27 2014 4:23 AMPermanent Link

Matthew Jones

A.Kyr wrote:

> 1.
> My thought is to create html pages in appl.server with parameters
> given by EWB web application and pass them back to browser inside a
> TPage component for display. The returned html will contains a table
> referring to some records.  Is possible somehow - putting any tag,
> href or anything else inside the html that is created and sent back
> to EWB web aplication - clicking on an item in the html inside the
> TPage,  to call a procedure/function of my EWB program? (ex: to open
> a form for editing the specific record that is clicked).  In other
> words I want to keep the application control with EBW, use pure EWB
> controls for inserting/editing the data but use html for
> listing/displaying the data.

Okay, the simple answer is yes, it can be done. But the solution is not
simple, and the main thing is how to get authentication between the two.

I don't know if you are familiar with the Verified by Visa system, but
that requires that an application shows a third party web page, and the
post from that page then goes to their server which posts to your
server. Your server can then tell the browser via whatever means you
want that something needs to be changed. In my web shop, I have the EWB
application poll the server for status and instructions. The EWB
application cannot know anything about what is happening in the TPage
area, so that link through the server is quite important.

You also have to be careful about authentication here - the end user
can get the URL of that embedded page and open it elsewhere.

--

Matthew Jones
Thu, Nov 27 2014 8:56 AMPermanent Link

A.Kyr

Steve Gill wrote:

Hi A,

<< 2.
When a custom appl.server is used - like in my case - which is the preferred way to inform the server side for the identity (credentials) in any single request after the succeeded login? >>

Not too sure about point #1 but with the 2nd point I use a unique session identifier. I use a PHP backend on the server but the principal is the same.

When the user successfully logs in, a session id is created by the server and passed back to the EWB app.  Whenever the EWB app sends a request to the server it passes back the session id. The session id is then checked and, if valid, the request is executed.  

The session automatically expires if no requests are received within a specific time, eg. 5 minutes.  Whenever a request is received within the time limit the "timer" is reset.

Hope that helps.

= Steve

Thanks for the reply.
You mean that you pass the taken session id in one of the TServerRequest's params leaving its UserName & Password properties empty?
Thu, Nov 27 2014 9:13 AMPermanent Link

A.Kyr

"Matthew Jones" wrote:

A.Kyr wrote:

> 1.
> My thought is to create html pages in appl.server with parameters
> given by EWB web application and pass them back to browser inside a
> TPage component for display. The returned html will contains a table
> referring to some records.  Is possible somehow - putting any tag,
> href or anything else inside the html that is created and sent back
> to EWB web aplication - clicking on an item in the html inside the
> TPage,  to call a procedure/function of my EWB program? (ex: to open
> a form for editing the specific record that is clicked).  In other
> words I want to keep the application control with EBW, use pure EWB
> controls for inserting/editing the data but use html for
> listing/displaying the data.

Okay, the simple answer is yes, it can be done. But the solution is not
simple, and the main thing is how to get authentication between the two.

I don't know if you are familiar with the Verified by Visa system, but
that requires that an application shows a third party web page, and the
post from that page then goes to their server which posts to your
server. Your server can then tell the browser via whatever means you
want that something needs to be changed. In my web shop, I have the EWB
application poll the server for status and instructions. The EWB
application cannot know anything about what is happening in the TPage
area, so that link through the server is quite important.

You also have to be careful about authentication here - the end user
can get the URL of that embedded page and open it elsewhere.

--

Matthew Jones

Thanks for your reply.
I consider my self as experienced programmer in C/S and 3tier level but novice as web one.
So I am not familiar with Visa System, but if I understand your reply you say that the only way for the asked functionality is that the link in TPage must call again by itself the web server with some parameters (ex: session id and record id), the server will keep the info somewhere. &#932;he EWB application  polling continuously to SebServer, will get the info and do the asked process (ex: open the specific record for editing.
Have I understood well you?

I was hoping for something more simple and bandwith saving.
Isn't really possible to call from a html inside a Tpage an existing Jscript (using something <button onclick="myFunction()"> Click me</button>)  inside EWB application? Even if I create the html in code inside EWB and not using an url?

A.Kyriakos
Thu, Nov 27 2014 10:22 AMPermanent Link

Raul

Team Elevate Team Elevate

On 11/27/2014 9:13 AM, A.Kyr wrote:
> Thanks for your reply.
> I consider my self as experienced programmer in C/S and 3tier level but novice as web one.
> So I am not familiar with Visa System, but if I understand your reply you say that the only way for the asked functionality is that the link in TPage must call again by itself the web server with some parameters (ex: session id and record id), the server will keep the info somewhere. &#932;he EWB application  polling continuously to SebServer, will get the info and do the asked process (ex: open the specific record for editing.
> Have I understood well you?

Today TPage is very limited and does not provide any callback events for
this type of thing. WHile i don't know for sure i would hope this is
something that might be (more) doable in v2.

The core issue is two-fold:
- this takes away from EWB core concept of protecting the user (compile
time checks etc) so you might break the EWB app from your tpage this way
- this also requires compile time support (something like declaring
interfaces into EWB - again something that does not exist in 1.x)


> I was hoping for something more simple and bandwith saving.
> Isn't really possible to call from a html inside a Tpage an existing Jscript (using something <button onclick="myFunction()"> Click me</button>)  inside EWB application? Even if I create the html in code inside EWB and not using an url?

Have not tried it myself so what i'm about to say might be all wrong but
theoretically yes you could hack something for now.

EWB output is pure javascript so you could in theory add a function (you
need to make sure it gets into a call path somehow or EWB will not even
compile it into javascript since its not used) and then go into compiled
code and figure out what your function got mangled into : for example
one of my sample apps a function is
ufrmtestserver_tform1.$p.processresponse.

Now if you were to supply your tpage content from your app server and
then have a user click call a javascript function in there (this all
needs to be supplied by your app server) and that JS function can
internally simply call "this.processresponse" with appropriate params.
That should get the call into EWB side of things (keep params simple
like integer ID or such).

Obviously there is a risk of EWB function name changing during compiles
(though the way it gets named that is unlikely).

Anyways - i have not tried this so consider it just a conceptual idea.

Raul
Thu, Nov 27 2014 10:42 AMPermanent Link

Raul

Team Elevate Team Elevate

On 11/27/2014 10:22 AM, Raul wrote:
> internally simply call "this.processresponse" with appropriate params.

Actually correction - "this" would likely not refer to the right owner
here possibly so a full initialied object variable is needed (in my case
the function seems to be ufrmtestserver_tform1.$p.processresponse).

Which bring up another point in that the response would be tied to a
form in this case. If you need this tied to application object then you
could modify the framework itself and add the function into TApplication
and then there route it appropriately (function you'd have to call would
become more straightforward as well - looks like
"webforms_application.processevent").


Raul
Thu, Nov 27 2014 11:55 AMPermanent Link

Matthew Jones

A.Kyr wrote:

> I was hoping for something more simple and bandwith saving.
> Isn't really possible to call from a html inside a Tpage an existing
> Jscript (using something <button onclick="myFunction()"> Click
> me</button>)  inside EWB application? Even if I create the html in
> code inside EWB and not using an url?

You understand well. I am not sure, but I think that the TPage
"content" is totally independent, because of the security models.
However, it is possible that there is a way to communicate, but you
could find that just by searching for how to do this in JavaScript. If
it is possible, then it will translate back to EWB.

One thought is that you have access to the Browser LocalStorage, and
could use a named value to communicate between them. The EWB app would
"poll" the storage on a timer, and watch for instructions. Just an
idea, don't know if it would work.

--

Matthew Jones
Fri, Nov 28 2014 6:48 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< 1. My thought is to create html pages in appl.server with parameters
given by EWB web application and pass them back to browser inside a TPage
component for display. The returned html will contains a table referring to
some records.  Is possible somehow - putting any tag, href or anything else
inside the html that is created and sent back to EWB web aplication -
clicking on an item in the html inside the TPage,  to call a
procedure/function of my EWB program? (ex: to open a form for editing the
specific record that is clicked).
In other words I want to keep the application control with EBW, use pure EWB
controls for inserting/editing the data but use html for listing/displaying
the data. >>

Is there any particular reason why you want to do this, instead of using the
TGrid control in EWB for displaying the data ?

<< 2. When a custom appl.server is used - like in my case - which is the
preferred way to inform the server side for the identity (credentials) in
any single request after the succeeded login? >>

Just cache the credentials in memory in your EWB application, and send them
over with every request that requires authentication.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Nov 28 2014 7:16 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Raul,

<< Today TPage is very limited and does not provide any callback events for
this type of thing. WHile i don't know for sure i would hope this is
something that might be (more) doable in v2. >>

I'm not quite sure what you're asking here - there really isn't much that
one can do with a TPage that we're not already doing, without dropping down
into the WebDOM unit and starting to deal with the DOM elements directly via
the iframe's contentDocument.  Which is certainly possible to do.  The
reason that EWB doesn't do these things from the TPage control is because it
has zero idea of what you're going to load into an iframe via the TPage, so
about all it can do is trigger an OnLoad and then let you go at it.

I think a core concept that people keep forgetting about is that there's
nothing to prevent anyone from using the classes/code in the WebDOM unit to
code their own access to the DOM along the lines of what one might do with
native JS code.  As long as the same-source origin security policies are
respected in the browsers, you can grab an iframe's contentDocument property
and start hooking up event handlers, etc. without any problem:

http://stackoverflow.com/questions/18668541/handling-iframe-event-in-the-parent-web-page

For TPage, just create a descendant class and then you'll have access to the
Frame property, which is the iframe element.  From there, you can do
whatever you want in terms of access to the elements that make up the loaded
document via the contentDocument property.  For example, if you wanted to
have a specific document trigger a custom event, then just code some JS into
the document's content on the server-side to create a new event type and
initialize it so that it bubbles up to the document level.  Then, just use
the SetDocumentEventHandler function in EWB's WebDOM unit to set an event
handler for that custom event at the contentDocument level, and then handle
the event in your EWB code.  EWB will *automatically* take care of scoping
"this" to the class instance of the event handler, and you're all set.  Most
element events in the DOM bubble automatically, so setting a handler at the
document level is normally sufficient.  But, there's nothing stopping you
from setting handlers on specific elements, either.

Of course, all of this will be *immensely* easier in EWB 2 since you'll be
able to create a TPage descendant (it's not called TPage in EWB2, BTW), and
then install it on the component palette.  So, you're descendant class will
be able to create published properties that you can easily modify at design
time, including click event handlers, etc.

Just remember, everyone, there's a wealth of code in the WebDOM unit - it
surfaces just about every piece of functionality of the browser in Object
Pascal, and in a way that the EWB compiler understands and can use.  I think
everyone is completely over-thinking these types of problems.  If you
couldn't do these things in EWB, then it wouldn't be possible for EWB itself
to do them, either. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page »
Jump to Page:  1 2
Image