Implementing ICAL calendars jsf - jsf

Im trying to implement ical calendars using java1.8/jsf2.2 in a way that makes embedding them into outlook possible:
It be good if i could store generated calendars and update them automatically. I intend to pass the needed parameters in the url. Something like
http://example.com/ical/calendars.ics?id=12&includeAll=1
I found primefaces FileDownload but Im not sure that is what I need. Maybe some FileServlet? I stumbled upon omnifaces' FileServlet and figured since I have the omnifaces jar anyway I could try to use that. Or the old version of BalusC found here: http://balusc.omnifaces.org/2007/07/fileservlet.html
Would any of those approaches even work?
What Im thinking is storing generated calendars in a temp folder and update them dayly. Or, using a FileServlet, I could generate them on request. Im not sure how to go at it. Which of the suggested ways is the best? Or are all of them wrong?

Since OmniFaces contains the mentioned FileServlet only from Version 2 onwards, which requires CDI, I wont be able to use it because I used Spring for DI. Otherwise that would have been the solution...
Using the BalusC's FileServlet I proposed in my question, I'm able to generate stuff on request.

Related

extend liferay plugin functionality with hooks

Fairly new to Liferay. I learned it is possible to create plugins UI with different frameworks including JSF. Also I learned I can extend functionality of an existing plugin with hooks. Now I am curious if it is possible to add new JSF pages to an existing plugin which interface is build with JSP using hooks?
Suppose I want to extend dynamic data list portlet, add some new functionality and for this I need to add new pages.
Is it possible to add new pages in general?
Can I create a new plugin with JSF as a front end framework, implement the logic I want to add within JSF pages, would it be possible to redirect a user from an original JSP to those JSF pages, let user do something there and then return the user back to original dynamic_data_list JPSs?
If it is possible, how can I do this with Liferay 6.2?
Thanks
The mechanics are documented in the developer guide or the Wiki. It's not exactly a hook that you deploy to the running system, rather a development option to inject custom changes into existing plugins, and you deploy the modified version instead of the original one.
With this, you can do everything that you can add as extra feature this way (see the build process). Technically the answer to the first two bulletpoints is "yes". If the linked documentation doesn't help answering your third bulletpoint, please ask more specifically what actually doesn't work. But keep in mind that only core liferay is customizable with hooks, plugins are customizable at compile time - and not with hooks.

How to understand the flow of a JSF application from the code side?

I am trying to get into a big JSF application made by others with almost no documentation. I already got a general comprehension of the application architecture, and about what it should do from a functional point of view. But now I would like to understand what is the process in the code when I navigate in the application using my web browser.
I especially lack sequence diagrams that would show for a single story what code is called.
I tried using debug mode in eclipse and use break points to see what is called, but since a lot of code is called by the faces servlet, the step by step keeps returning into the JSF library and I am wasting a lot of time guessing what part of the code might be called next. I also look into the xhtml code to see what methods are called, but since each JSF page visible in the browser is made of a dozen of tiny xhtml fragments (using ui composition and custom components) it is quite easy to get lost.
So here is my question: Is there an easy way to associate a story from the browser point of view with the corresponding code in the backing beans?
Ok
I finally managed to get a better understanding of what was happening, thanks to all the comments on my questions, and to the facesTrace project, which was originally part of primefaces and aims to enhance the traceability of JavaServer Faces based applications. I found here how to configure it, and I adapted it a little to my project. Suprinsingly, it worked very well (the project is JSF 1.1). Then I wanted to get the logs working in FacesTrace. I found a hint there, but had to adapt a little because the package name of the Appender has changed.
I would have loved to give a few more links but Stackoverflow limits me to two links, hope those will stay alive forever.
To be fair, using a good old logger and a context listener would produce the same result, but what I appreciate is that it is well presented and I can reduce the scope of the log to the log of the request, even though I have some doubts of what would happens if several users were debugging at the same time since it uses log4J.

How Can OSGI and JSF work together?

I'm new in OSGI and I'm having many problems to try to create WABs. I'm using BndTools with Eclipse to help me with OSGi. My problem now is how can I integrate JSF with OSGi. I want to make one main web server, and add bundles with jsf pages runtime. How can I do this? What are the needs?
Thanks in Advance!
JSF is quite complex due to it's classloading mechanism. If you use Pax-Web you are able to use JSF, though it requires some special handling. For more details get in contact with the OPS4j community.
Another hint, since you seem to try to build your own "web-container", I don't recommend that, try to use an existing one, makes life easier :)

Primefaces 2.2.1 with FileUpload from Primefaces 3.0

Related to the last comment on this question, i would like to know if anyone managed to use the HTML5-Fileupload of Primefaces 3.0 with an older Primefaces version.
We have a lot of trouble with the old flash-version of the fileupload.
I know that the best option would be to update the whole project to the new primefaces version but it´s not possible for this project.
This is not going to be trivial. That you're already asking this question already indicates that it's going to be a long journey. I'd rather use a barebones and to-the-point file upload component of another component library such as Tomahawk's <t:inputFileUpload>. It only doesn't support asynchronous uploading and you need to make the submit button of the form a non-ajax one, but it does the job you want it to do without much hassle.
You can find in this answer detailed step-by-step instructions how to integrate and use it in your project: JSF 2.0 File upload. In case of PrimeFaces, you only need to make sure that you have removed PrimeFaces' own file upload filter from the web.xml, otherwise it would consume the uploaded file before Tomahawk's own filter get the chance.
Thats very difficult, I have many problems with fileupload and finally migate to 3.0 but witch are problems?.
If you wanna to change fileupload you will can change source code in library is not very smarted if you desnt know jquery ui o you can use other framework or use directly.
http://www.matlus.com/html5-file-upload-with-progress/
good luck

Securing JSF applications

I've been asked by a freelancer friend of mine to join him on a JSF 2.0 project, and I'm slowly picking up speed and putting the pieces together. Coming from a Windows Forms .NET world, I have a lot to learn to say the least.
My major concern is with the lack of apparent consensus on how to protect a JSF application.
Some methods have been proposed here on SO, including using Spring security, Seam security, custom phase listeners, or simply using the rendered="#{...}" attribute to show/hide components based on user authentication.
I have tried to implement some of these methods, for example Spring security, only to find out that it gets easily defeated by the JSF navigation mechanism that forwards to views instead of redirecting. In other words, Spring security will work fine if the user types in the url of a secured page directly, but not if a h:commandButton's action takes him there.
In view of this, some have suggested to force a redirect by using "faces-redirect=true", but we feel that this could become a performance issue as this causes 2 requests from the browser each time.
On the other hand, I gave up trying to implement Seam security after getting so many missing dependencies errors.
The best solution I have found so far is a custom phase listener from Duncan Mills - Effective Page Authorization In JavaServer Faces, but I'm not 100% convinced this should be used on public facing JSF applications.
So finally, what does this leave us with ? I know this is a pretty wide open ended question, but I honestly have no clue where to go next. I'm pretty sure I have followed the different tutorials to the letter, for example Spring tutorials, but I'm still not satisfied with the way it works.
Could anyone at least confirm/infirm the fact that Spring security is supposed to work across JSF forwards, as I've seen many posts by others having the same issue ? That would at least give me a direction to keep going.
Thank you.
Combination of servlet filter for page validation (applied to the faces servlet), identity session bean (storing user attributes e.g. Role, login id) and a few methods for entitlement checks (e.g. isAdmin(), canViewRecord(recordID)) well ised throughout your page.
You see, when it comes to security I opt for not leaving it in anybody else's hand. also, I validate in several places (hiding a component won't keep folks from forging the right POST request to trigger specific bean methods so watch out).
When I work with JSF I use spring-security.
About the behavior that you comment that spring security allows redirections done with commands button, is weird you must have a wrong configuration because it seams working fine in my project (I just tested).
In any case you can also use the spring security tags to render or not components according to the user's role.
This is a project that can help you to implement the tags.
http://www.dominikdorn.com/facelets/
Hope this helps..

Resources