Do I need JSON/AJAX when using JSF? - javascript

I'm working on a new project based entirely on Java EE 6 technologies, including JSF/EJB/JPA. In previous projects I widely used json/ajax before. But this time I'm reconsidering if I really need json/ajax any more. JSF has supplied me with a great way to build web UI. It seems the only benefit left on the json/ajax side is data-refreshing without reloading the page, at the cost of complex data processing in javascript. If I cut off json/ajax, I'm both cutting off the benefit & the javascript work, which doesn't really appear to hurt much to me.
I especially do not like jquery. I think JQuery is like a fabulous promise, which always starts in an attractive way, but as the project grows more and more complex, as more jquery elements added weired javascript errors emerge here and there. Even if I use json/ajax, I will not use jQuery anyway.
What do you think about it? Will you continue to work on json/ajax when using JSF?

Related

ColdFusion built-in AJAX vs JQuery or ExtJS

I was wondering what the difference is between ColdFusion's built-in AJAX functionality and using a JS framework like JQuery?
It seems that ColdFusion ships with tags that can do fancy Javascript layouts and controls e.g.<cflayout> and <cfwindow>. If it can already do this then why would one want to look at JQuery?
I'm asking this question because I have been given the task of making an internal CRM application which should have a 'rich' UI. I started investigating JQuery and ExtJS which do the fancy client-side UI work. However I also noticed that CF has similar abilities. Because I am starting from ground zero I was wondering whether to spend (a lot of) time learning JQuery or ExtJS, or cut down on my development time and just use CF's built in AJAX tools.
With some good design skills, would it not be possible to create a 'rich' application with CF's built-in AJAX controls and some fancy CSS styles?
Any advice would be greatly appreciated.
Some things to consider:
Yes, you could use CF's built-in Ajax/UI stuff to build a nice application. The downside is that doing anything outside the box of what CF has baked in is a big headache., Plus, the version of Ext JS which CF has is quite old...so getting all the goodness from the latest version (v.4.2+) is not an option, since CF doesn't have a mechanism for upgrading that library seamlessly (or freely).
As others have mentioned, you should definitely use a non-CF alternative--they are all dead-simple to integrate with CF-backend anyway, so the amount of effort required to do that vs. wrestling with tweaking the internal CF stuff is actually lesser.
Which library to use? Well, you need to seriously consider your options before jumping into one or the other. jQuery (and jQuery UI) and Bootstrap are nice for design...unlike Ext JS, however, they don't come baked in with uber-rich "data-aware" components (grids, trees, etc). They are more libraries than they are frameworks (like Ext JS). On the other hand, Ext JS, for your purposes, will not be free. Unless you plan on open-sourcing your "internal" CRM codebase, you'll likely have to commercially license the software, which is on a per-developer seat basis. I think it's well worth the cost, considering what you get, but that will have to be part of your organization's calculation if you decide to go that route.
Personally, I don't recommend using CF's Ajax functionality. I've build internal tools using ColdFusion's built in javascript and they run very slow to say the least. Your best bet is to go with JQuery and Bootstrap. This could be a bit more difficult at first, but it would open a lot of doors down the road.
Good luck! Al

Javascript Single Page MVC from scratch

I just wondering what is the technique of creating a single page website by using javascript without using framework like ember js / angular js.
For example in php like they can get
example.com?view=homepage
Can easily get the view and load/display homepage and load homepage's content.
What if in javascript if want to load another page/content?Any technique for building it?
I just building with a simple function like
$("#otherpage").hide();
$("#homepage").show();
I don't know is it the best way to develop a javascript single website page with this way?Or any technique that you all can suggest, cause I need learn from basic, need use javascript to explore and create a single app page without php.
Thanks lot
If it was that easy, do you really think Ember, Spine and Angular would be that widely used?
Snarky comment aside, building a page that refreshes like what you've done, while simple and rather easy to modify, falls very short on quite a few things:
For sites larger than a couple of pages, your HTML markup will become MASSIVE. Not just that, but you'll have to run every single piece of code on every page...per page. Say hi to insane overhead, both on bandwidth and on server-side processing, even with caching.
If you want to dynamically update part of a page, you'll need to use AJAX anyway. Why would it suck to write stuff using an MVC approach from the get-go, rendering data as you go along with AJAX, rather than brute-feeding the entire DOM?
What is the problem with Angular, anyway? Widely used, bug-free, unit-tested, built by reliable people, and if a bug does go through, you can be sure that the community will fix it quicker than you could
If the last comment didn't dissuade you from building your own to replace an already-existing platform, I would strongly recommend you build your JS to be fed data (JSON or otherwise) from your server and to dynamically update the page. You might not want the full-blown MVC approach, but at least the MV part of it. This will also allow modularity.

Developing an image gallery or content slider without any jQuery (or Flash)?

First post, but I've been lurking around this site for a long while now, and I know how good some of you guys are at this development game.
So, I'm trying to figure out how to develop a gallery/mainnav widget for the top of a landing page, but the page cannot include the jQuery library or any flash objects. I haven't explicitly checked yet, but I don't think mootools will work either. Having said that, I am by far most familiar with building stuff like this using jQuery than any other libraries out there right now, so having had that taken away is proving a difficult obstacle for me.
I'm looking for ideas/suggestions/direction on possibly trying to build something like this using a canvas element (my canvas skills are not that well developed yet, fyi) or if a pure-javascript solution is available somewhere... or really any input that I may not have considered yet.
Thanks guys.
You're probably conflicting with another library, in which case you can use jQuery in .noConflict() mode.
Developing something so UI-heavy without jQuery or some other framework is really not advisable. It will likely take much longer to build, with much longer and less maintainable code that works across fewer browsers.

Help me choose between Javascript, jQuery, or AJAX

before i start of with anything i know that jQuery and Ajax are the JS frameworks and it is nothing but JavaScript itself.
I started to learn Javascript few days ago, and then i realized the need to learn the AJAX and then suddenly i felt jQuery will be the better solution, heck i am confused here, i cannot go three at a time nor do i want to master all the three.
i am a web designer, i know, HTML, CSS, PHP and MySQL, i started to learn JavaScript on the purpose of learning the client side validations or some sort of animations for the website, i need the suggestion from the web gurus, i really don't want to get into the complex java script programming right now, all i want is the simple solution for performing various tasks like validation, and animation for my websites. is jQuery feasible solution for my problem? can i learn jQuery without much prior experience in Javascript. ?
JavaScript is a programming language.
Ajax is a thing you can do with that language.
jQuery is a library that does some heavy lifting in that language for you (including some things relating to Ajax)
You can't choose between them, it doesn't make sense.
is jQuery feasible solution for my problem?
Yes
can i learn jQuery without much prior experience in Javascript. ?
Yes, but you should get a decent understanding of JavaScript and DOM so you know what the library is trying to achieve. Otherwise you are poking around in the dark and won't produce as good results.
It is also very wise to understand progressive enhancement.
Normally I don't say this, but a better solution for you would be to look at jQuery. It is a framework written in JavaScript to make various tasks simpler and cross-browser. AJAX is nothing but just a function - XMLHttpRequest.
Since you don't want to delve deeper into the JavaScript language, the list of existing plugins available for jQuery will be helpful for you.
To understand where things stand in the spectrum
JavaScript is the language
AJAX or XMLHttpRequest is a function available in JavaScript.
jQuery is a framework written in JavaScript to simplify things
Firstly, JQuery is a AJAX library. AJAX is doing the communication manually on a lower level where as JQuery wraps in a higher level library.
Having done not much JQuery myself, I'm not entirely sure but I think you can achieve validation (and maybe animation) quicker by using inbuilt systems from JQuery, the alternative is to write it from scratch in javascript.
Although from the sounds of it if you want pure clientside animation or clientside validation there should be no need to use AJAX or JQuery. I'm not too certain about other libraries you could use for quick development.
My advice would be to learn javascript and keep an eye on whether any parts of JQuery can do exactly what you want it to do.
For example :
http://www.webreference.com/programming/javascript/jquery/form_validation/
Show's you how use JQuery to validate inputs in a rule based system (It looks almost like an extension of CSS)

Complex client-side logic -- better to move to the server side?

I'm working with a third-party search API, and am rather enjoying keeping pretty much the entire application on the browser side. The XML is digested entirely with javascript, and I'm rendering complex result objects dynamically, using a javascript templating engine. There are few page reloads happening, and lots of fancy javascript going on.
It feels clean to me to keep everything on the javascript side. It's going to make deployment much easier, and it's nice to have all my code in one place. I'm trying to be just as rigorous about coding well with javascript as I would were I coding in Java, and so far things seem to be working pretty well. I'm making an effort to work TDD style, using YUI test, and am optimistic that this will make the inevitable cross-browser bugs easier to catch and fix. The code size is not minuscule, but it's not too bad, and I plan to minify it before deployment, which should reduce it to about 2/3 of what it is now.
Are there drawbacks I'm not considering? Any other proponents of front-siding application logic here?
There are few page reloads happening, and lots of fancy javascript going on.
There is one large drawback to relying too heavily on JavaScript. Remember that whenever you design a web application you should base it on the premise that the user doesn't have JavaScript enabled - although this is a minority there are still a lot of users who don't have it enabled for whatever reason, and if your application relies too heavily on JavaScript in its fundamental operation, then it won't be accessible to those who disable JavaScript.
Whenever I write pages that have JavaScript or AJAX functionality I always make sure to have a secondary way of information being displayed or submitted, in case JavaScript is turned off on the user's browser. Of course this often isn't necessary for aesthetics - menu items sliding along a menu bar when clicked and the page is changed won't affect the core functionality of the page if JavaScript is turned off and they simply act like static links; however for core features such as inputting data and having results displayed, you should ensure to provide backup methods that are employed when JavaScript is not enabled.
You should use AJAX only when it actually improves user experience. It is very annoying when trivial functionality requires JS needlessly. I would expect (no idea if it's the case for your app) to be able to enter a search, get the results, and page through the results all without JS.
There's nothing wrong with "extras" like AJAX paging or search refinement. But the essentials should be there either way.

Categories

Resources