File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Recursive Composite Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Recursive Composite Component" Watch "Recursive Composite Component" New topic
Author

Recursive Composite Component

Dominik Müller
Ranch Hand

Joined: Apr 28, 2009
Posts: 36
Hi together,

i try to build up a recursive composite component, but have some problems.
I reduced the critical issue to a very simple (and needless) example, but it shows the main problem i think:

Have an Composite Component


Should print out just a countdown (again this is just an example to show the critical point)
But results in a: java.lang.StackOverflowError

I think there is a misunderstanding from me about the time where the expressions and tags will be interpreted, but no details in my mind.
Somebody an explementation or any ideas to solve the Problem?

thanks a lot !
Dom
Rahul Jjain
Greenhorn

Joined: Aug 06, 2011
Posts: 3
Were you able to resolve the problem. I am facing the exact same issue. It seems while building the component it does not take the rendered attribute in consideration and c:if does not affect until rendering time.

If you found a problem to this issue, please do reply. Thanks for your time.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

Yet another example of why JSF and JSTL don't mix. Don't use JSTL on JSF views and components and life will be much more pleasant!


Customer surveys are for companies who didn't pay proper attention to begin with.
Rahul Jjain
Greenhorn

Joined: Aug 06, 2011
Posts: 3
Yes Tim! I understand that but the problem is that the rendered attribute seems to be not honored in all the phases. I have used rendered attribute hardcoded to false but in some phase of JSF lifecycle it is not evaluated and I get Stack Overflow error.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

Rahul Jjain wrote:Yes Tim! I understand that but the problem is that the rendered attribute seems to be not honored in all the phases. I have used rendered attribute hardcoded to false but in some phase of JSF lifecycle it is not evaluated and I get Stack Overflow error.


"rendered" is a directive to the view renderer, so its only application is to instruct the renderer as to whether or not it should generate output. That is done during the Render Response phase.

However, your "cc:Deep" element didn't have a "rendered" attribute, so it would render unconditionally.

One reason WHY you shouldn't mix JSF and JSTL is that JSTL is designed for JSPs. JSPs are compiled into servlets as straight-line interpretations of the page definition into sequential Java code text and in particular, the "c:if" tag renders into straight Java if/then logic. JSF is not compiled into executable code, even when you define a JSF View with the ".jsp" filename extension. JSF is compiled into a 2-dimensional data structure which is used by the renderer as a reference object. The renderer is obliged to observe output element (geometric) placement and precedence - meaning a render-suppressed container suppresses rendering of its children - but it can process the tree in any order it finds convenient. Including, if the environment is right, in parallel.

The only reason why stack overflow should be an issue (unless you're already at critical memory usage), is if you're mis-applying the JSF architecture. A common mistake is that people put heavy processing into propery "get" methods. Sometimes this is the only reasonably-clean way to get something done, but it should be avoided as much as possible, and such operations should always be designed realizing that the "get" methods can be invoked several times over the request/response cycle, and therefore should A) cache their results to cut overhead and B) NEVER have side-effects (in Computer Science terms, they should be idempotent).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recursive Composite Component