This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 188602 - JSF pages from entity for EE 5 uses JSP even if Facelets is set as the default page language
Summary: JSF pages from entity for EE 5 uses JSP even if Facelets is set as the defaul...
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF (show other bugs)
Version: 6.x
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Alexey Butenko
URL:
Keywords:
: 185491 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-07-12 15:35 UTC by Petr Jiricka
Modified: 2010-09-01 09:44 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch (13.07 KB, application/octet-stream)
2010-08-12 13:15 UTC, Alexey Butenko
Details
updated patch (17.53 KB, application/octet-stream)
2010-08-16 10:56 UTC, Alexey Butenko
Details
one more change (2.02 KB, patch)
2010-08-17 01:02 UTC, David Konecny
Details | Diff
patch (46.01 KB, application/octet-stream)
2010-08-17 11:47 UTC, Alexey Butenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-07-12 15:35:43 UTC
1. Create a Java EE 5 web project with JSF 2.0 framework and Facelets as the preferred page language
2. Create entity classes from database
3. Create JSF pages from these entity classes

Pages will be generated as .jsp, even though I set Facelets as my page language. Verified with both WebLogic and Tomcat 6 as the target server.
Comment 1 David Konecny 2010-07-13 00:16:33 UTC
The problem is (I think) that code generated for Facelets requires EE 6 (uses EJB in Web app??) and therefore it cannot be generated for EE 5 app. Alexey, could you have a look and confirm please? Would it be hard to rewrite the generated code to run on EE 5?
Comment 2 Odhinn 2010-07-23 00:18:00 UTC
I'm encountering this problem as well. I am using Java EE 6. Additionally, when I added the framework through the IDE, I set Facelets as the preferred page language. However, when I view it again, JSP is set. No matter how many times I change this JSP is still set as the preferred page language. I am using Java EE 6, GlassFish 3, NetBeans 6.9, and Windows 7.
Comment 3 Odhinn 2010-07-23 18:47:17 UTC
Update: I had removed the dependencies from the POM for jsf-api, jsf-impl, jstl, and the standard taglibs, as I already had javaee-web-api defined and the implementation was provided by GlassFish. After adding these back, the pages were created properly, using facelets instead of jsp.
Comment 4 Alexey Butenko 2010-08-10 12:55:27 UTC
(In reply to comment #1)
> The problem is (I think) that code generated for Facelets requires EE 6 (uses
> EJB in Web app??) and therefore it cannot be generated for EE 5 app. Alexey,
> could you have a look and confirm please? Would it be hard to rewrite the
> generated code to run on EE 5?

Yes, the code requires EE6 because of the EJB 3.1. It is not hard, but it will take some time, since there are a mess in the code for generating JSF entities.
Comment 5 David Konecny 2010-08-11 02:26:24 UTC
(In reply to comment #4)
> Yes, the code requires EE6 because of the EJB 3.1. It is not hard, but it will
> take some time, since there are a mess in the code for generating JSF entities.

Yeah, it is messy. I branched code generator for Facelets and it uses customizable templates. My motivation was to leave old Java API based generator as it was. And similarly I would not want to complicate new template based code generator. Unless there is a simple way which would not increase complexity (ie. messiness). Let me know please how would you fix this before you head that way so that we can review it first. Thx.
Comment 6 Alexey Butenko 2010-08-12 13:15:59 UTC
Created attachment 101340 [details]
patch
Comment 7 Alexey Butenko 2010-08-12 13:17:21 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Yes, the code requires EE6 because of the EJB 3.1. It is not hard, but it will
> > take some time, since there are a mess in the code for generating JSF entities.
> 
> Yeah, it is messy. I branched code generator for Facelets and it uses
> customizable templates. My motivation was to leave old Java API based generator
> as it was. And similarly I would not want to complicate new template based code
> generator. Unless there is a simple way which would not increase complexity
> (ie. messiness). Let me know please how would you fix this before you head that
> way so that we can review it first. Thx.

I've attached the patch for you to review.
Comment 8 Petr Jiricka 2010-08-13 07:39:58 UTC
Cc'ing also Sergey so he can review the JPA part of the patch.
Comment 9 Petr Jiricka 2010-08-13 21:55:51 UTC
Alexey, I am trying out your patch - the generated code looks good, but does not quite work with WebLogic.

When I access the generated listing pages, then the Chrome browser outputs:
error on line 11 at column 15: Encoding error
Firefox displays question marks in some places.

BTW, the generated facelet encoding is ISO-8859-1  - shouldn't this be UTF-8?

Next, the server console contains the following warnings:

WARNING: JSF1063: WARNING! Setting non-serializable attribute value into HttpSession (key: customerJpa, value class: p.CustomerJpaController).
WARNING: JSF1063: WARNING! Setting non-serializable attribute value into HttpSession (key: customerController, value class: p.CustomerController).
Comment 10 Alexey Butenko 2010-08-16 10:56:04 UTC
Created attachment 101410 [details]
updated patch
Comment 11 Alexey Butenko 2010-08-16 10:57:19 UTC
Petr, 

I've updated the patch according to your comments.

(In reply to comment #9)
> Alexey, I am trying out your patch - the generated code looks good, but does
> not quite work with WebLogic.
> 
> When I access the generated listing pages, then the Chrome browser outputs:
> error on line 11 at column 15: Encoding error
> Firefox displays question marks in some places.
> 
> BTW, the generated facelet encoding is ISO-8859-1  - shouldn't this be UTF-8?
> 
> Next, the server console contains the following warnings:
> 
> WARNING: JSF1063: WARNING! Setting non-serializable attribute value into
> HttpSession (key: customerJpa, value class: p.CustomerJpaController).
> WARNING: JSF1063: WARNING! Setting non-serializable attribute value into
> HttpSession (key: customerController, value class: p.CustomerController).
Comment 12 David Konecny 2010-08-17 01:01:18 UTC
Looks good. One or two thing needs to be changed:

* <Entity>JpaController class should not be managed bean. It should have constructor accepting (UserTransaction utx, EntityManagerFactory emf). That way class can be used in different context for example from JSF managed beans, web services etc. It is job of whoever is using <Entity>JpaController to retrieve UserTransaction and EntityManagerFactory.

* <Entity>Controller class should have UserTransaction and EntityManagerFactory injected and should create <Entity>JpaController lazily in getJpaController() method

* <Entity>ControllerConverter class should retrieve <entity>Controller property and call on it getJpaController().
Comment 13 David Konecny 2010-08-17 01:02:13 UTC
Created attachment 101432 [details]
one more change

and you probably want to do also this
Comment 14 Alexey Butenko 2010-08-17 11:47:43 UTC
Created attachment 101446 [details]
patch
Comment 15 Alexey Butenko 2010-08-17 11:49:14 UTC
Patch updated according to the latest comments.
Comment 16 Petr Jiricka 2010-08-17 16:10:20 UTC
Hi Alexey, I tested it and it looks good. If David has no other comments, you can check it in and we will deal with any outstanding issues later.
Comment 17 David Konecny 2010-08-17 20:53:13 UTC
(In reply to comment #16)
> Hi Alexey, I tested it and it looks good. If David has no other comments, you
> can check it in and we will deal with any outstanding issues later.

If patch works and addresses the issues identified then go ahead and push it. Thx.
Comment 18 Alexey Butenko 2010-08-18 08:38:10 UTC
http://hg.netbeans.org/web-main/rev/ce83e94c8d02
Comment 19 Quality Engineering 2010-08-19 03:25:29 UTC
Integrated into 'main-golden', will be available in build *201008190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ce83e94c8d02
User: Alexey Butenko <alexeybutenko@netbeans.org>
Log: #188602: JSF pages from entity for EE 5 uses JSP even if Facelets is set as the default page language
Comment 20 Sergey Petrov 2010-09-01 09:44:58 UTC
*** Bug 185491 has been marked as a duplicate of this bug. ***