REST and JSF: Library to use? How to solve it? - java

The problem:
When the user clicks on www.example.com/myapp/myview?id=1 I need to display the item with id=1 which is in the database. To do that I need to execute bean methods. (Ideally the user would have to login first if not in cookies and then redirect but that's another problem).
I'm using Richfaces 3.3.3 with JSF 2.0 (So VDL is deactivated and Facelets have to be used yet) so it's incompatible with PrettyFaces (they use the built in Facelets into JSF2).
RestFaces does not have JSF2.0 Version and seems outdated (last version is from June 2008).
Any idea how to solve it?
Thanks in advance.

Check RestEasy it is used in
JbossSeam which also integrates JSF with Rich- and Icefaces,Rest and much more.

have a look at http://ocpsoft.com/prettyfaces/ if that helps ... or else try some magic with preRenderView event in jsf2

Related

Access static members in JSF via EL 3 (Tomcat 8.0.14/27)

As the title states, I'm having issues rendering static values via EL 3 in JSF.
There's a similar issue like mine but it's in JSP and there was a workaround (see this Access static property or method in JSP via EL 3.0 (JEE7; Tomcat 8) )
The issue is nothing is being rendered when I use something as simple as this in any of my .xhtml files
#{Boolean.TRUE}
Although this site https://java.net/projects/el-spec/pages/StaticField says the following would work.
#{T(java.lang.Boolean).TRUE}
It also failed with an error similar to
javax.el.ELException: Function 'T' not found
I've gone ahead and tried the workaround that was mentioned in Access static property or method in JSP via EL 3.0 (JEE7; Tomcat 8). The workaround, which worked for JSP guys, is to replace the jsp-api.jar with javax.servlet.jsp-api-2.3.2-b01.jar in their Tomcat lib.
This DIDN'T work for me either :(
What does work for me is the standalone implementation, like so
ELProcessor elp = new ELProcessor();
Object ret = elp.eval("Boolean.FALSE");
getLog().info("Output Value: " + ret);
And I do get the correct output like so
2015-10-07 17:38:13 INFO WelcomeAction:38 - Output Value: false
I've tried with both true and false value and they worked fine. Not sure if this info will help, but I'm using spring 4.1.1 with webflow 2.4.1. I've also tried on two different tomcat instances 8.0.14 and 8.0.27 and neither worked.
There's no way that I'm the only one dealing with this. I have yet to find a bug report regarding this, although one was reported and solved for JSP https://java.net/jira/browse/GLASSFISH-20778
Would really appreciate some help right about meow. Thanks in advance. Aloha!
The issue is nothing is being rendered when I use something as simple as this in any of my .xhtml files
#{Boolean.TRUE}
Unfortunately, that works in JSP only via ${Boolean.TRUE}, not in Facelets.
Although this site https://java.net/projects/el-spec/pages/StaticField says the following would work.
#{T(java.lang.Boolean).TRUE}
That site contains only proposals/prototypes. The final implementation is indeed done differently. For the final implementation, read EL 3.0 specification document instead.
Basically, the change needs to be done in Facelets side, not in EL side. EL 3.0 provides support for static fields, but Facelets simply isn't utilizing it. Even the EL 3.0 import handler after all doesn't work in Facelets. It's likely an oversight. I've pinged the JSF EG on this.
In the meanwhile, your best bet is to create a custom taghandler which does the job. JSF utility library OmniFaces has exactly such taghandler in its assortiment, the <o:importConstants>.

Primefaces Calendar does not show up

I am trying to integrate Primefaces 5.2 to a JSF application which has version of 2.0.11-02. I am using IBM WebSphere 8.5.5 as application server. I am trying to use p:calendar in my page but it does not show up.
When I checked from Google Chrome Dev Tools, I noticed that the corresponding input field has no "click" event listener attached to it. In Primefaces Showcase the input fields has "click" event listener so when you click, calendar shows up.
I am also having the same trouble with sorting of datatable. The column has no "click" event listener, so it does not send any request when the header of a sortable column is clicked.
Please help me with that problem.
P.S: The application I am working on was a JSF 1.2 application and were using JWL libraries of IBM. Since I am upgrading the application to JSF 2, I am not able to use that library anymore. That's way I am trying to integrate Primefaces. primefaces-5.2.jar is placed under /WEB-INF/lib and I also still have jsf-ibm.jar, odc-jsf.jar in that directory.
try to create a lib folder out of the meta-inf and PrimeFaces put the library, or you could also try creating a page with the component PrimeFaces calendar to see if it works and put in
<html xmlns:p="http://primefaces.org/ui"</html>
Are you sure that you save your XHTML file with proper extension? If you have deafult settings it would be *.jsp as far as I remember

Spring MVC. Rendering layout

I'am new to Java Spring MVC. Official documentation is very poor and i've got a lot of questions about rendering pages in Spring.
I have page and top block with menu. This menu must be dynamic and must be displayed on all pages. In PHP frameworks this is very common and very easy task. But Spring makes my brain explode.. How can i separate rendering of this menu in some peace of logic and tell spring to render it all the time? For example in JSP. Shoud I use beans or other stuff?
Thanks for your answers!
Official documentation is very poor
No it isn't. Its the one place I always refer back to.
I use a jsp include and yes pass a java bean to the jsp from the controller. The included jsp will be cached the first time it is included. In other places I connect to a controller using jquery and ajax, which dynamically updates the page.
I'd suggest the official tutorials, and krams as good starting points.
You won't find much information about this in the Spring documentation because it's out of the scope of Spring.
You can use JSP includes just as you would do PHP includes. This will however force you to repeat the page layout and the include in each and every page of the application :
<jsp:include page="/menu.jspf" />
Or use a templating engine, like Sitemesh or Apache Tiles (see http://static.springsource.org/spring/docs/3.1.0.RC1/spring-framework-reference/html/view.html#view-tiles for Tiles integration in Spring).
The easiest way would be to use <jsp:include page="/menu.jsp" /> where "/menu.jsp" is a path to your menu jsp.
There are other solutions like using tiles, but <jsp:include> should do.

How do I run "Hello, world!" with WebSphere and Wicket?

I am a Wicket beginner, and I need to develop a Wicket application using WebSphere Application Server 7.0. I've searched Stack Overflow and Google, and found these resources
http://apache-wicket.1842946.n4.nabble.com/Wicket-and-Websphere-td1917050.html#a1917051
https://cwiki.apache.org/confluence/display/WICKET/Websphere
but I can't figure out how to run a "Hello, world!" app on WebSphere. Can anyone tell me how to run one, step by step, using Wicket?
For example, for the step "Add a new property called com.ibm.ws.webcontainer.invokefilterscompatibility," where will I add the property?
I have Wicket 1.4 in production on WAS 7.0 and it works just fine - with one exception. I had to use the WicketServlet instead of the WicketFilter.
Try the following:
Create a Wicket Quickstart project
Modify the web.xml to use the Servlet instead of the Filter. The second link you provided contains instructions on how to do do.
Deploy!
I don't recall having to do anything special beyond that.
Note: As I use the Servlet, I have no need to use the com.ibm.ws.webcontainer.invokefilterscompatibility property.

Dyanamic Graphs using jsf

My requirement is I need to populate dyanamic graphs in a jsp page. I am using jsf for my project. I planning to use "jfreecharts" but dont know how to bind my jsp page with the back bean. I have some drop downs on the basis of the selection I my BackBean is fetching the data from the DB. Can you please suggest me some procedure to that with some sample code for my reference?
You can use Fiji (Exadel) library.
They have charts, as well as support for wrapping SWF elements and sending properties in JSF.
See an example here. For each component, there is source code as well so you can try it yourself.
Primefaces has a nice chart component as well.
Fiji is very nice but check out this http://www.fusioncharts.com/

Categories

Resources