× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



That makes sense, Kevin. Thanks.

It's what I thought.. just passing JSON objects to the client to parse.

Does the client make the request to the server for the data using Ajax?
Similar to jQuery get() or post()?

If you travel down the web app road, there are just so many forks to take.
:)

Brad
www.bvstools.com

On Tue, Apr 12, 2016 at 9:04 AM, Kevin Turner <kevin.turner@xxxxxxxxxxxxxxx>
wrote:

Yes we are talking about slightly different things I think. I am not
familiar with Jade, but I have dabbled a fair bit with
Angular/Bootstrap/ejs so that involves either/both templating (server side)
and client side rendering. You can mix it up how you see fit. In our own
Renaissance Framework all the rendering is done client-side - the only
thing that passes to/from the server is a data model in JSON format
(backbone.js to be precise). The server is basically an API to deliver
data - it doesn't know anything about HTML, so it can effectively serve any
type of client.

-----Original Message-----
From: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Bradley
Stone
Sent: 12 April 2016 14:53
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxx>
Subject: Re: [WEB400] Node, Jade and Logic

Interesting. I was looking into client side jade and that just seems to
add more complexity to an already growing stack of complexity. I love JS
so I like node. then you add express.. and jade.. (and jQuery of course,
but that should be a norm on the client side).

My application is returning formatted html data from the server, not
result sets using jQuery and Ajax.

$.post('/customerList', formData, function() {})
.done(function(data) {
$('#customerList').html(data);
})
.fail( function(errorThrown) {
$('#customerList').html(errorThrown.responseText);
});

What you're saying is I should be using ajax to grab the result sets
themselves (not formatted HTML) and doing the rendering on the client side?

We may be talking about 2 different things.

I just don't see the point of starting with node... then realizing I
better use something like express and jade for rendering on the server
side.. and then finding out even that is "wrong".

Then you go down the rabbit hole of "you should use xxxx instead of Jade..
jade is slow, you should render on the client instead, you should render
raw HTML instead.. it's faster", etc.. etc..

Too many ways to skin a cat these days. :) (is "skin a cat" PC these
days?)

Brad
www.bvstools.com

On Tue, Apr 12, 2016 at 2:48 AM, Kevin Turner <
kevin.turner@xxxxxxxxxxxxxxx>
wrote:

Just my opinion of course, although you will find articles supporting
the argument, you are better off doing this sort of thing on the
client. Let's say you have a result set that you have obtained
asynchronously on the server, but you want to manipulate/sort it
further before it's useful, then let the client do it. If you get into
the habit of doing it in your server side node.js code you are
effectively blocking the event loop. You may not notice with a handful
of clients attached, but ramp that up a notch or two and you soon have
client requests waiting to be serviced for no good reason. Your server
side code should be optimised to get that response back asap, so if
you must do it server-side you need to hand it off to a child process to
do it asynchronously.

Sent from my iPad

On 12 Apr 2016, at 01:15, Bradley Stone <bvstone@xxxxxxxxx> wrote:

I'm playing around a lot more with Node.js and Jade using Express on
the IBM i.

I'm just curious how others are handing condition logic, more
importantly,
where.

As an example lets say you're listing customer order details. We
can of course limit records we get in a result set using the SQL.
We can also order things, etc..

Once you have the result set, are you doing any additional
programming in node or the jade template?

Here's an example...

I have a generic routine that returns a result set. I have another
that returns the field headings from the file...: (not checked for
syntax.. )

var sql = "select RRN(a) as RRN, a.* from %s.%s a where CDEMAIL =
'%s'"; sql = util.format(sql, Library, Table, email);

var customerDetailList = myStuff.getResultSet(sql); var columns =
myStuff.getFieldDescriptions();

I then pass these into my jade template as such:

res.render('viewCustomerDetail', {resultSet: customerDetailList,
columnList: columns});

My jade template then has some logic to replace certain headings if
required (like if they're too long). It also has logic so that
certain rows won't be shown... for example:

block content
- var dontShow = ['CDEMAIL', 'RRN', 'CDREGNET', 'CDMNTAX',
'CDDSTC']
- var replaceHeadings = {CDCREQ: 'Requested', CDDAYS: 'Days'}

each fieldValue, fieldKey in resultSet[0]
if (dontShow.indexOf(fieldKey) < 0)
th.small1(align="left")
if (!replaceHeadings[fieldKey])
=columnList[fieldKey]
else
=replaceHeadings[fieldKey]

This works really slick and is moving all the display logic to the
template. But, is this considered ok or is it better to do this
type of logic in the node.js? Manipulate the returned lists,
replace headings, remove columns if we don't want to display them, etc.

Doing things this way I find my templates are generic for lists. I
just need to update the dontShow and replaceHeadings objects for
each specific page. I understand I can limit the columns display
using the SQL
statement
but right now this is how I am doing things while playing around.

It also means I can update my display without needing to stop and
restart my server (very nice!). If I needed to remove or add a
column and use
the
SQL statement to select the columns I'd need to update the node
route and restart the server.

Just throwing out some ideas... thanks!

Brad
www.bvstools.com
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
mailing
list
To post a message email: WEB400@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/web400.


___________________________________________
This email has been scanned by iomartcloud.
http://www.iomartcloud.com/


________________________________

NOTICE: The information in this electronic mail transmission is
intended by CoralTree Systems Ltd for the use of the named individuals
or entity to which it is directed and may contain information that is
privileged or otherwise confidential. If you have received this
electronic mail transmission in error, please delete it from your
system without copying or forwarding it, and notify the sender of the
error by reply email or by telephone, so that the sender's address
records can be corrected.




----------------------------------------------------------------------
----------


CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT

Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
mailing list To post a message email: WEB400@xxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.


--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list To post a message email: WEB400@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.


___________________________________________
This email has been scanned by iomartcloud.
http://www.iomartcloud.com/


________________________________

NOTICE: The information in this electronic mail transmission is intended
by CoralTree Systems Ltd for the use of the named individuals or entity to
which it is directed and may contain information that is privileged or
otherwise confidential. If you have received this electronic mail
transmission in error, please delete it from your system without copying or
forwarding it, and notify the sender of the error by reply email or by
telephone, so that the sender's address records can be corrected.




--------------------------------------------------------------------------------


CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT

Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.