Should I use Angular JS for faceted search? - angularjs

I'm planning to build a webpage that compares large amounts of products.
I need faceted search/filters for that, so the visitor can filter the product on price/color etc.
I couldn't find a ready to implement webshop script for that, so I'm planning to build it myself.
I'm a fan of Laravel, but to avoid page refreshes if the user is changing the filters in the side bar, you need a kind of AJAX calls to your Eloquent ORM.
So that's when AngularJS can be handy, but now I'm confused if I do need Laravel for such a stack. Because if you use AngularJS and MongoDB, you don't need Laravel at all.
So I'm not sure what is best practice.

Disclaimer: I know nothing about Laravel, but a quick google tells me it's a PHP framework for making a restful API.
The 'standard' stack for angular apps at the moment is the "MEAN" stack. That is: MongoDb, Express, Angular, Node. I'm not sure this can be considered a "Best Practice", because it's not necessarily better, but it is definitely the common practice, and as such will be easier to get support and help with.
All that being said, angular really doesn't care about the back-end. It's a front-end framework for making single page web applications. All it really needs is a decent API that you can access by creating a custom service. There is no reason you can't replace node and express with PHP and laravel, and mongo with SQL, you just won't get such a nice acronym!

Related

Develop backend (Spring) without frontend (angular)?

I am programming a spring-boot project. I only want to create the backend. Another developer will later on create the frontend with AngularJS.
I want to develope my backend without spending to much effort to create a test-frontend, since I dont know anything about JSP,Angular..
What should my Controllers(#Requestmapprings) return (Model, ModelAndView,JSON-Objects, Strings, ...??), so the angular-developer can use them for creating the view?
Is there any easy way to develop my backend without creating a frontend at all and still being able to test it somehow? I dont want to spend time to create basic Forms/Buttons/checkboxex but i would like to check if my scripts are working..
You must start looking into REST services.
https://spring.io/guides/gs/rest-service/
To see how it is consumed by angular please refer.
https://spring.io/guides/gs/rest-service/
You can get lots of tutorials and documentation on developing REST services independent of frontend.
I would suggest taking micro services approach based on the UI requirement and then segregate the services based on the functionality. This would make the code maintainability and development easier. If you are going to use spring-framework, it has vast stack of features, which are production ready.

RESTFUL App in symfony 3

I am still quite confused about REST API, Angular and so on.
I would like to build simple web app which allows users to book events and I would like to do it in Symfony 3 + Angular.
In future, I could make it work on mobile phones as well.
The reason I want to do it is to learn symphony 3, REST API and Angular better and to increase chance I will get hired.
I have few questions:
1) Apart of the fact I am going to learn Angular what is the real benefit of using Angular rather than twig templates and HTML for the front end ?
2) As far I have seen people usually suggesting light weight frameworks to build REST API. Why would not they suggest symphony ?
3) What would you suggest to build to show you have got good skill set to get hired ?
1) Angular a complete framework. In your case, you would use angular as front end. This would be two options.
First one is completely using Angular, Symfony serves the RESTful API. Then twig is not involved anymore.
The other is used Angular within twig, acting like a server side rendering Angular. This way is not very common right now, rather less examples could be found.
In any case, Angular could provide single-page application, which could give your users better user experience, faster load speed, move the html view part completely to browser(make server less tasks regarding rendering the view). You could also achieve this by using twig+javascript, but it would be a bit more complex depends on your skills.
But in my opinion, the best benefits would be separate the frontend and backend from architecture perspective.
2) Symfony is a very complete PHP framework. Building a REST API is only an example of using Symfony. And in this way, some features from Symfony could not be used. I would say some lightweight framework would deliver the same result as using Symfony. It would also be easier using some lightweight framework(less code, less configuration, etc.). However, the performance of Symfony and large community might also need to take into consideration when you choose the right framework.
3) Always a good protfolio by showing your experience and skills.

what are the advantages of using 2 MVC architectures(frontend and backend) in same project. AngularJS and Spring MVC

what are the advantages of using 2 MVC architectures(frontend and backend) in same project. AngularJS and Spring MVC.
Without using AngularJs, can I update single div data without loading the entire page? Is AngularJS responsible for updating single <div> data out of multiple <div>s without loading entire page? If so, please explain in detail.
Once you have a single-page application you have to make sure all the different parts of that application are consistent, that's what the MVC/MV-Whatever in the front end is doing for you. That's not an issue in an old-school web application because the relevant state is regenerated with each request, but once the updates are coming in bits and pieces then different pieces of the front end need to be coming from the same model and that model needs to get updated consistently.
Obviously you can implement div updates with raw JavaScript, you don't need frameworks just to do AJAX. The JavaScript frameworks are written in JavaScript, after all. The frameworks and libraries do make things easier by doing things like papering over browser inconsistencies and providing convenient and useful features (like databinding in Angular).
The server-side MVC does become less complex and involved than it was in the old-school web application, you have less POST-Redirect-GET going on, the front end is more in control about what it is asking for. The front-end application is decoupled much more from the server-side because that whole server-side view layer of JSPs or Facelets or whatever is greatly reduced or just missing, instead you have services supplying JSON over HTTP and there is a much more limited, well-defined contract.
You can update a single element of your page without using AngularJS. As an alternative, for example, you can use JQuery.
You should wonder for the best approach for your project. This answer explains very well the differences between this two approaches.
As an aside note, AngularJS is not exactly a MVC architecture. Instead, the community has decided to call it MVW (Model View Whatever). Check this source for more details.

Should sites like ebay and amazon use frontend frameworks like angular js or vue js?

I'm thinking about upgrading my site. It's a trade place a lot like ebay.com.
My site is build in Laravel 5.1, but without any front-end framework. Because of that, I was wondering if it made any sense to use a front-end framework like angular js?
Pros and cons please.
I don't know that much about angular js, but if I convert my laravel application to fully obey the REST principles, i'm also well suited for building an iOS-app when that time comes???
http://tilsalg.dk - Link to my site
I don't know whether it is suitable to use angularjs for this purpose. The problem is as far as I am concerned, that website which are written in javascript (so angular) can not be indexed well by SEO's. I'm hearing a lot that Google can index it but I'm a little sceptical about this. For a trading website like ebay it's very important that the site is SEO optimized. Of course if you use REST principles you can always change the frontend and that is also the way to do it.

Should I use Servlet for Database access and Display results in JSP using JSTL?

I've been learning Java for more than 6 months. I'm developing a web app and learning through building it. I'm using Glassfish Server and MySql. No frameworks. Using Servlet, JSP and EJB.
Now I'm querying database through JSP page and displaying results. Is this the best way? or Should I use servlet for querying database and displaying results in JSP?
I want to display only part of the resultset object and show the remaining if the user wants to see it. So Could I implement this using jsp alone?
I would recommend usind your Servlet to handle the database-connunication only and perhaps some logging on the usage of the Connection. The logic would best be implemented in JSP alone since you can better maintenance it.
Querying database through JSP page is not the best way. And because you are not using any framework is definitely not the best way to learn. While learning you need to try as much frameworks as possible to find out which one you can use or not to use. You are also need to learn patterns for building Java EE applications.
Should I use servlet for querying database and displaying results in jsp?
This approach is much better, but is not enough because of coupling database code with servlet code.
I want to display only part of the resultset object and show the remaining if the user wants to see it. So Could I implement this using jsp alone?
What do you want to display should be coded in the servlet.
You should avoid coding your business logic codes in your JSPs. Segrate your application into multiple layers, take a look at MVC design pattern.
Model: These are plain POJO classes where your DB transaction and business logic happens.
Controller: This is where your servlets goes. These classes accept user request, call appropriate Model classes and send response to view.
View: This is you JSPs, displays data to users. Avoid using Scriptlets in your Jsps. Use JSTL and EL.
Take a quick look at this example MVC application, and do your own searching on MVC. Hope it helps you to get started.

Resources