JSF and Phonegap - jsf

I am a new Java developer and I would like to develop a JSF mobile application. I know I could use JSF 2.0 together with Richfaces, IceFaces or PrimeFaces to develop my app, but I think it would run only on the server and I am not sure if it would have access to offline storage and device’s camera, required by the application.
Question: is it possible to use Phonegap or a similar framework to make my JSF mobile app go native?

I don't think JSF and phonegap can be used together. Phonegap's app is HTML/CSS/javascript app, which doesn't require server. It is client only. JSF app is client-server: application logic mostly located on server and all html generated by server. You can't port it to phone now.
If you need access phone's stuff: offline storage, camera, you can create app in phonegap, sends ajax request to your server. Server can provide some API and you can write it in java. You don't need JSF in this case. Google for REST and Spring for java web services. Or better check this question: https://stackoverflow.com/questions/1710199/which-is-the-best-java-rest-api-restlet-or-jersey

You might want to look at Primeface Mobile. It is a UI toolkit for writing JSF web applications tailored for mobile clients.
http://www.primefaces.org/showcase-labs/mobile/index.jsf

Related

Native apps, Web apps communicating with same application server

Hello guys i was learning web developments and have a simple question. If i built a e-commerce web page using node.js and ejs template engine and everything works fine. The next decision is to build a native app for the same e-commerce site either android or IOS. I want the native app to also communicate with the same application server designed in node.js. Do i have to redesign the application server?
My approach or thought:
Native app will have to consume data either xml or json. So i will have to change the business logic of my endpoints. And if i do it this way, i will also have to change the way the web ui interacts with the application server and it also has to consume json or xml response using ajax call. Is my thinking or approach on the right track? But if using node.js, should i avoid the template engines?
Yes, you have to redesign the application server logic by exposing API endpoints. As mobile apps (iOS/Android) will interact with the server using these API endpoints, via JSON. And this will affect your web page also, as everything thing now has to be done via AJAX calls.
Best practice is to built a single page web application using Angular or React.
That way both your mobile app and web app would behave almost the same.

API for Mobile web app development

I am trying to build a mobile web app using worklight .I checked the IBM website but they have limited documentation on it.I wanted to know is there any inbuilt API provided by IBM in order to develop the mobile web app?
I am specifically looking for API to to control the refresh button and the back button in mobile web browser
Why limited? Where did you look? There is comprehensive user documentation and training modules in the following websites:
IBM Worklight Getting Started training modules
IBM Worklight user documentation: client-side JavaScript API reference
Regardless, there is no such thing as "controlling a browser's Back and Refresh buttons".
These buttons are provided by the mobile browser and are out of scope for whatever is running within.
It would be more beneficial for you to edit the question and explain your specific scenario - what it is that you are actually trying to accomplish.
In Worklight, you have WL.Client.reloadApp, for example, which can be used to refresh the web resources displayed. As for "back button"-like functionality, this can only be determined once you explain what you are trying to accomplish.
Additionally, keep in mind that while Worklight provides some API methods for controlling UI elements, it does so only to a certain degree and only for elements that are most common to all mobile environments (iOS, Android, ... for example, creating a tabbar); when you develop a web app for the Mobile Web environment, you cannot control via the app things like the Refresh button that the mobile browser supplies.
Lastly, you can and probably should opt to 3rd party frameworks such as jQuery Mobile and the like for the UI aspect in your Worklight application.

Mobile JSF how to start in Netbeans?

I would like to write a simple, hello world page in JSF as well as for mobiles and ordinary web pages. Found this: http://mobiforge.com/book/mobile-jsf but seems to be outdated. I cant even download the plugin which is mentioned there (download is unavailable, 404).
I searched Internet and it seems that theres no simple step by step tutorial for writing mobile JSF pages. Any ideas where and how can I start?
Maybe it can help you to use a mobile component framework like PrimeFaces Mobile or IceMobile.
There are some tutorials which describe how to build mobile websites with JSF and PrimeFaces Mobile:
Create Mobile Websites using Java Server Faces and PrimeFaces Mobile
Primefaces Mobile - Weather App Example
PrimeFaces tutorial
PrimeFaces Mobile User Guide
Here are some tutorials about IceMobile:
ICEmobile Tutorials & Samples
Just add mobility: JSF and JSP with ICEmobile
If you don't want to use a mobile JSF component framework you can search the web for the tutorials about combining mobile JavaScript frameworks like jQuery Mobile or Bootstrap with JSF.

can i use a gwt library in a jsf project

I want to create a mobile app using PrimeFaces. In it, I also want to use Phonegap, but not directly, rather through its GWT abstraction- phonegap-gwt.
Some of the features provided by PhoneGap, in a phonegap application, require the web page accessing the phone's functionality to be a local page(on the device where phone's functionality is to be accessed)... this can be done using phonegap-gwt in a google web toolkit project also, i.e. dont put server side code in the page that utilises phonegap-gwt code(correct me if I am wrong here, so far?)... On the other hand, the program created by jsf(i.e. primefaces) is a mobile web application.
Hence, what I am confused about is, can I keep GWT code (for Phonegap access through GWT) and JSF code in the same project? I understand that the phonegap gwt code will get compiled into Javascript, but can such programming,i.e. keeping gwt code with jsf code, be implemented? Even if this is possible theoretically, wont there be issues/restrictions that I would have to keep track of? What are those restrictions? Have you tried combining GWT code with JSF code? Did it work?

Implementing chat in my JSF page

I have J2EE web application which uses JSF framework. Now I am trying to add chat functionality to my application. The problem that I am facing is
When someone pings me, i should be able to see a chat notification on my jsp page. Which means server should be able to update my page when new chat notification comes. Please tell me how can my jsp page listen to incoming packets.
You should look into push technologies. Many JSF libraries support it directly: icefaces, richfaces and primefaces at least. If you don't want to use any of these you may also check out atmosphere, but this will require some javascript and server side coding.

Resources