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 108443

Summary: Users want prerender() in page fragment
Product: obsolete Reporter: Chris Kutler <ckutler>
Component: visualwebAssignee: Winston Prakash <wjprakash>
Status: NEW ---    
Severity: blocker    
Priority: P2    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description Chris Kutler 2007-06-28 17:08:38 UTC
http://forum.java.sun.com/thread.jspa?forumID=881&threadID=5145309
http://forum.java.sun.com/thread.jspa?forumID=881&threadID=5097095
If I understand well, We must call the method wich generate dinamically the tree menu inside the page fragment in each
JSP Page in the prerenderer method? If it is the case, I think It's not so useful.
If I have one page fragment with tree menu and 100 JSP pages, It will be more useful, for me, to put only once the code
that generate the tree menu inside the page fragment instead of calling the method for the 100 Pages.
Thanks for a better solution.

http://forum.java.sun.com/thread.jspa?forumID=881&threadID=5145309
That's the same problem, the workaround is to update the property in every prerender() method (of every page fragment)
to guarantee rendering it correctly. And that's bad, the fragments are more or less independent and they are shown on
multiple pages.

So, you means I have to put the code in Main page (the page that load the fragmented pages) to set and unset the
property. That's what I think, but I got a problem then, I have to put the code on all of pages that using those
fragmented page. is my assumption right ?

http://forum.java.sun.com/thread.jspa?forumID=881&threadID=5063954
I want to create a menu fragment which not all user has the same access right, they have to login first to get the menu
and the menu will be generated base on the user permission to access a module. Also, in header fragment I want to put an
autentification within each page. If I and my teams have to include that code for every page that is oke .. but if it is
possible I want to avoid that, so the development could be handled as easy as possible :)

http://forum.java.sun.com/thread.jspa?forumID=881&threadID=5062267
> Certainly I'll give it a shot, but the problem is
> that my code is in the constructor of a Fragment and
> prerender is not called for the fragment. Would it
> work if i move it to the init() function?

Answer: No 

On the initial rendering of a page that includes the fragment, the backing bean for that fragment is not loaded (and
therefore the init method on the fragment is not called) until the first time that fragment is referenced.  In general,
this is likely to happen during the render response phase (i.e. aftger the page1 prerender method has returned, and the
lifecycle has advanced to the Render Response phase).  On the postback, the fact that the saved component state includes
component bindings to properties in the fragment's backing bean will cause it to be loaded (and therefore init called)
much earlier.

If you want init on the fragment to be called early, you'll need to do something (such as evaluate an expression that
references the fragment's backing bean) inside, say, your action method.  However, I not tend to design an app this way.
 Instead, I would make the prerender method for the page responsible for setting up any data required by the fragments
included by that page (after all, the page author should know which fragments those are) instead of relying on the init
method of the fragment to do setup stuff. 

>
craigmcc writes:
You are correct that not having prerender() callbacks in a fragment is a current limitation. In the past, I have worked
around this by defining a public method in the fragment's class, and then calling that method from the prerender()
method of the surrounding page bean(s). The call would look something like this:
Comment 1 Winston Prakash 2007-07-10 02:07:09 UTC
This is an enhancement request