Access ViewRoot before render response in a PhaseListener

Hi,
I'm trying to access UIComponents just before the render response phase to change some attributes of the UIComponents. Therefor I have created a PhaseListener, which is called before the render response phase. My idea was, to get the ViewRoot and iterate over it to access all UIComponents, but in the beforePhase, the ViewRoot has no children. How can I solve this problem?
Here is my PhaseListener:
public class SecurityPhaseListener implements PhaseListener {
    private static Log log = LogFactory.getLog(SecurityPhaseListener.class);
    public void afterPhase(PhaseEvent pe) {
    public PhaseId getPhaseId() {
        return PhaseId.RENDER_RESPONSE;
    public void beforePhase(PhaseEvent pe) {
        UIViewRoot viewRoot = pe.getFacesContext().getViewRoot();
        System.out.println("before render response " + viewRoot.getChildCount()); // returns 0
        // the following is just sample code for you to get an idea of what i want to do
        // change attributes according permissions
        for (Iterator iter = viewRoot.getChildren().iterator(); iter.hasNext();) {
            UIComponent comp = (UIComponent) iter.next();
            if(comp instanceof HtmlInputText) {
                HtmlInputText htmlInputText = (HtmlInputText) comp;
                htmlInputText.setRendered(false);
}

Morphy wrote:
this means that an initial call has no real life cycle...beforePhase has no component tree, afterPhase is too late.... umpf... can i alter component tree in a specialized ViewHandler?
the ViewHandler api is not deeply documented, which is the best point to hook to address this?You can, but I would use that as the last resort.
A better solution would be to use the binding attribute to get access to the component. If your getter initially returns null, JSF will create the component and then invoke the setter; at that point you can manipulate the component.

Similar Messages

  • Handle Exceptions during the Render Response phase

    Hi,
    How can we handle exceptions that occur during the render response phase, e.g. to redirect the user to an error page?
    In our application we have an unbounded taskflow with one page (jspx). It's quite a simple page, as it only displays some data from a managed bean.
    When we run the application and e.g. throw explicitly a RuntimeException form one of the getters, all we get is the 'progress indicator', not even a stacktrace on the page (only in the logs).
    Unfortunately, it doesn't seem possible to handle the exception, not via the taskflow Exception Handler, the web.xml error-page or a custom ADF Controller exception handler. In the latter case, we can catch the exception but when we try a redirect (on the external context or response) we get a 'java.lang.IllegalStateException: Response already committed' exception.
    Any suggestions?
    Ciao
    Aino

    Hi Aino
    I'm not sure if that's the problem, but I recently read somewhere (wish I remember where) an IllegalStatementException that was throwing because there was no entry page defined in web.xml.
    If you are trying that, remember that web.xml doesn't support .jspx pages.
    Edited by: TheCrusader on 09-jul-2010 15:03
    Edited by: TheCrusader on 09-jul-2010 15:10

  • If I switch on my iCloud will I still be able to access my iWeb created web site currently on MobileMe. I understand I need to find anotherhost before June, but I would like to access iCloub before then.

    If I switch on my iCloud will I still be able to access my iWeb created web site currently on MobileMe. I understand I need to find another host before June, but I would like to access iCloub before then.

    If you want to migrate your MobileMe account to iCloud you do so at http://me.com/move . You will need Lion 10.7.2 on your Mac to be able to use its facilities. Your calendars, contacts, bookmarks and email will be moved to iCloud.
    Your iDisk, including website hosting and Gallery, will be unaffected and can still be accessed as before, though the migration process will probably sign you out in System Preferences>MobileMe and you will need to sign in again there.
    You will continue to be able to use your iWeb site as before. As you say, this will cease at the end of June. This page examines some alternatives:
    http://rfwilmut.net/migrate2

  • Access denied before end of subscribtion

    I have Adobe Reader and have subscribed and paid to be able to create pdf but on 3.31. I could no longer create a pdf in spite of my subscribtion lasting until 4.10.??  And I can't get access to anyone at Adobe either (that option is not available under Reader)...   Anyone knows how to solve this?

    Yes, it was here on my end 
    2015-04-03 21:11 GMT+02:00 Sara.Forsberg <[email protected]>:
        Access denied before end of subscribtion  created by Sara.Forsberg in *Adobe
    Acrobat.com Services* - View the full discussion

  • What is the idea behind Render Response and Exception Handling in TF?

    Dear All,
    While searching for answer for my question, I find it hard to decipher this line.
    task flow exception handling doesn't handle any exception that is in Render Response phase
    I found this several times in many post like this.
    Re: ADF Exception handling (including RENDER RESPNSE PHASE)
    and this
    Re: Exception Handling in TaskFlow
    What's the idea behind exception handling in task flow that is related to JSF/ADF life cycle?
    I can't find a resource on why I should know what phase an exception has been thrown?
    Sorry if my question might be vague/ignorant to others, but I just would like to know the idea from experts around here. :)
    Thanks.
    JDEV 11G PS4

    Hi,
    Render Response is the last lifecycle phase processed during JSF request. The ADF controller has no chance of handling exceptions that occur during this time (example, exception thrown in managed bean) and therefore in its default exception handling implementation ignores this lifecycle phase. As an application developer you don't need to know when an exception is raised. However, if you find that an exception occurs during Render Response and it is not handled by the ADFc declarative exception handler, then you know. You can try and override the framework exception handler as explained here:
    https://blogs.oracle.com/jdevotnharvest/entry/extending_the_adf_controller_exception_handler
    However, better practice is to use try/catch blocks surrounding e.g. calls in a managed bean that could cause exceptions
    Frank

  • Attribute sharing before setting response

    Hello, I have a problem, because I use Session-attributes to share information between servlets, but when I want to read the attributes before the response has returned to the browser the attributes haven't been refreshed.
    How should I fix this problem? This is the code:
    RequestDispatcher disp;
    disp = req.getRequestDispatcher("login");
    if (disp != null)
         disp.include(req, res);then in the called servlet I put an attribute in the session called user and I try to read it in the dispatcher
    HttpSession ses = req.getSession();
    String theUser = (String) ses.getAttribute("user");like that, but before the response is returned this value is 'null'...
    How can I fix this problem, or do it in another way?

    are you sure you want to keep it in the session? I use the servlet dispatching to jsp method all the time and use a lot of
    request.setAttribute("servlet.created.object",obj)
    request.getAtrribute("servlet.created.object")
    this way you don't waste memory as in this obj only exists for the lifecycle of this request.
    what you are trying to do should work so i'm not sure why. I also build user objects through login servlets and add them to the session and then have the jsp use that object in the dispatch. The only thing that ever causes problems with that is having browser cookies disabled. If cookies are being blocked then no session variables will work.
    Hope that's some help, graeme.

  • Getting Children Components from ViewRoot before RenderResponde Phase

    Hi,
    I need develop a component for applying security in JSF components. This security configuration will placed into XML File.
    I was thinking in execute a PhaseListener before RenderResponse for applying security (rendered, readonly, disable, etc), but I don't get children componentes from ViewRoot.
    How can I get children componentes before RenderResponse?
    Thank you.

    You cannot. You need to do it at component level, e.g. rendered="#{user.admin}" and so on.

  • Disappointed Stuttering .MTS Files In Program View Before Render

    AVCHD, MTS files on my CS4 Premiere Pro. In the program monitor, when I am trying to make tight edits and add effects in specific spots, the video is stuttering as if I haven't enough power.
    I just got a dell XPS 730, INTEL Core2 processor 2.83, 1333 FSB, quad core 12 MB of cache, Dual NVidia GeForce 9800GT Scalable Link Interface video cards, 4GB of DDR3 SDRAM at 1333 MHz. The hard drive is a SATA 2 at 7200 RPM.
    When I render the video, it plays okay, but I have enough power to watch it smoothly on the program monitor as I edit. What is the problem?
    A few years ago I had a very small computer and Premiere 7.0 and I had no problems.
    I called tech support and they were clueless. They sent me from India (2 levels) to the States, a 3rd level.
    I need smooth video BEFORE I render. What can I do??
    P.S. The video (.MTS) plays fine on Windows Media Player.
    I have Vista Ultimate.

    Well, my man, if you're over 50 like me and have watched the development of commercial software for 25 years on distributed platforms, you know that Adobe more than any other company has gone out of their way to BLOAT their products into oblivion. Being a retired corporate programmer, developer, designer, integrator, buyer, and ultimately officer and executive, I never understood the logic of their approach on any level. They have single handedly spawned a whole sub-industry of Adobe alternatives.
    They simply don't write tight code anymore. And the number of user complaints is way above the median for the industry. We are on release 10. The product simply needs a rewrite. And they need to re-remember that the BEST software works seamlessly with the user. It doesn't now.
    Premiere Pro fulfills a need to a high degree. BUT it's not perfect. And there are better written NLEs out there.

  • Error while accessing Sales-force adapter response variable

    Hi,
    Using salesforce adapter we are creating an account. Based on the response planning to proceed the next flow. But while accessing success variable in the salesforce response. we are getting following exception:
    The <from> value is invalid. The result of from-spec is null. Either the from node value or the xpath query in the from node value was invalid. According to BPEL4WS spec 1.1 section 14.3, the from node value should not be empty. Verify the from node value at line number 104 in the BPEL source.
    But in flow trace(Audit trail) we are able to see response.
    Thanks,
    KANN

    Hi Anoo,
    you can use app_id,page id ,session in javascript function,see the code given below
    $v('pFlowId') // APP_ID
    $v('pFlowStepId') // APP_PAGE_ID
    $v('pInstance') // SESSIONEdited your code, try it.
    <script type="text/javascript">
    $( function() {
        $("#P1_ENG_PART1").autocomplete({
            source : function( request , response) {
                            data = getJParticipant(request.term);
                            response( data );
            focus  : function(event , ui){
                        event.preventDefault();
    function getJParticipant(key)
       // Here i want to check the App_session logic code and hence i had implmented which is not working.
           Can any one help me how we can resolve the below problem.
         if ($v('pInstance')) is not null then
          var ajaxRequest = new htmldb_Get( null , '&APP_ID.' , 'APPLICATION_PROCESS=GET_JPARTICIPANT' , 0);
       ajaxRequest.add( 'G_MX01' , key);
       ajaxResult = ajaxRequest.get();
       return ((ajaxResult.length>0)? ajaxResult.split( '~' ):null);
    end if;
    </script>Regards,
    Jitendra

  • GetStyle() of JSF component before render

    Hey guys,
    I'm hoping this is an easy one, here goes...
    For one reason or another, I need to modify the CSS of certain components in a JSF page before it is rendered to the browser. The JSF pages are going to be laid out in Netbeans 6.0 (beta right now) using mostly Woodstock components and will have the 'style' attribute filled in for each component. However, like I said, I want to modify the CSS style value of some components prior to rendering.
    Looking through the Javadocs for Woodstock (javadocs are included with plugin) I see that many components do indeed give you access to this attribute ('style'), com.sun.webui.jsf.component.Field.getStyle() returns "CSS style(s) to be applied to the outermost HTML element when this component is rendered" for example.
    I figured this would be straight forward enough and attempted to retrieve the style using the prerender() method. Unfortunately, getStyle() returned null. After playing around with it for a while, it appears as though the components do not get these properties set (by the Netbeans attribute) until DURING the renderResponse phase. I say this because I tried setStyle() during prerender() and my changes were ignored. I then went back to Netbeans and removed my 'suggested style', now my setStyle() call during prerender() holds showing that somewhere in the renderResponse phase (after prerender()) the style is being set if one is given.
    Obviously making any changes after prerender() [like in afterRenderResponse()] will not cut it.
    To sum up:
    Even as late in the lifecycle as prerender(), the CSS style attribute of a Woodstock component is not yet set (getStyle() returns null and setStyle() ends up being overwritten). Any suggestions on how to modify the style?
    Thanks in advance (and I hope this is an applicable forum),
    Sean

    Solved:
    Once I wrapped my head around the problem I found a much more elegant solution.
    What I wanted to do was relatively position page fragments but was having trouble as the Netbeans IDE positions components within fragments absolutely. To make my page dynamic I was taking the style="position: absolute" attribute out of the <div> tag that was holding the <jsp:directive-include>. The components within the fragments were then being positioned absolutely on the resulting page, ending up strewn all over the place. This led me off on the tangent to reposition the components when the page was called (original post above).
    The weekend did me well I suppose. I came up with the bright idea to CHANGE the style attribute on the <div> tag rather than remove it. Making the <div> component "position: relative" passed its positioning down the the containing components and now my fragments are displayed correctly while being dynamically repositionable.
    Hope this helps anyone coming across the same problem.

  • Not a secure site window pops up, have accessed sites before

    when i try to access sites that i have had, verizon, capitol one, att , amer. express, i get a page that says, this connection is untrusted, you have asked firefox to connect to to but we can't confirm connection secure. have not had a problem with any of these before the last month
    == This happened ==
    Every time Firefox opened
    == in trhe last month

    Hello Joan.
    This happens when your connection has been hacked. DO NOT access any secure website while this isn't fixed and don't put your passwords or personal information ANYWHERE online until then.
    That said, simply factory resetting your router should fix the problem. If you can't do that, contact your network administrator and inform him of the problem. I repeat, DO NOT put your personal info on the internet while this is not solved!
    You have been warned.

  • JSF RI  1.1_01: UIInput component value was not set during render response

    I've just started to learn JSF, read corresponding chapters in J2EE guide and spec and tried to play little bit with JSF RI 1.1_01. I found very strange (at least for me) behaviour of regular input component (corresponds to inputText tag).
    I have very simple example form (contains "select one", input component and command button). Corresponding backing bean has request scope. I set breakpoints in backing bean getters and during debug found:
    1. On initial request both getters were called during rendering phase.
    2. On form submit request getter for property bound to input component was called again (this looks strange for me) but getter for property bound to select box was not called (it looks as I've expected). This strange call occurs during validation phase. As far as I understand it was the following flow:
    a) During initial request rendering response input box value wwas not stored in component state (I even may suggest that it was not set on component, just corresponding HTML tag with initial value was rendered).
    b) On submit form submitted string value of input component was decoded from request parameters but local value was set to null (see above).
    c) During validation phase submitted value was successfully converted and validated.
    d) Then implementation had to detect component value change and called getValue() in order to obtain old value.
    e) Implementation of getValue() first looked for local value field - it is null, then it should request for bound value from model.
    I tried different ways to store state (client or server) but it was the same. Sadly MyFaces 1.1.1 implementation did even worse - local value of select was also null during first postback.
    I wonder why it was implemented this way...
    Thank you

    I've just started to learn JSF, read corresponding chapters in J2EE guide and spec and tried to play little bit with JSF RI 1.1_01. I found very strange (at least for me) behaviour of regular input component (corresponds to inputText tag).
    I have very simple example form (contains "select one", input component and command button). Corresponding backing bean has request scope. I set breakpoints in backing bean getters and during debug found:
    1. On initial request both getters were called during rendering phase.
    2. On form submit request getter for property bound to input component was called again (this looks strange for me) but getter for property bound to select box was not called (it looks as I've expected). This strange call occurs during validation phase. As far as I understand it was the following flow:
    a) During initial request rendering response input box value wwas not stored in component state (I even may suggest that it was not set on component, just corresponding HTML tag with initial value was rendered).
    b) On submit form submitted string value of input component was decoded from request parameters but local value was set to null (see above).
    c) During validation phase submitted value was successfully converted and validated.
    d) Then implementation had to detect component value change and called getValue() in order to obtain old value.
    e) Implementation of getValue() first looked for local value field - it is null, then it should request for bound value from model.
    I tried different ways to store state (client or server) but it was the same. Sadly MyFaces 1.1.1 implementation did even worse - local value of select was also null during first postback.
    I wonder why it was implemented this way...
    Thank you

  • Before render, option to warn user of pending warp stabilization of pre-analysed clips

    Hi, I work with hours and hours of footage, and sometimes it is almost impossible to go through every clip and check if warp stabilizer needs more frames to analyse, as well as other affects that have a blue, red or green line across the clip which renders with the project in use.
    I was wondering if there is a script/option that can warn a user before rendering a project that warp stabilizer needs frames to analyse as the ''Media offline'' warning that comes up when media is missing or misplaced?
    Looking forward to any help as this can save me hours of time, I am sure users out there are eager to find a solution to this too.
    Thanks, Ckerux

    I second this motion! would love to know if there's a way, or put in a request to add a feature for something to flag us that there are clips that need to be analyzed/re-analyzed.

  • ClassNotFoundException while invoking EL function during render response

    I wrote a simple EL function to retrieve the clientId of a UIComponentBase object -- I'm generating some javascript. The first time I load the page (without a submit), the page generates just fine, including the javascript output that successfully invoked my EL function from a h:outputText element.
    However, when I submit the form it throws a ClassNotFoundException (for my EL function class) and generally freaks out after that. Now, obviously it should be able to find the class since it managed to find it on the initial rendering of the page.
    Am I missing something about using EL functions in a JSF tag? (I'm using JBoss Seam under the covers, but am not sure if this is a Seam issue or a pure-JSF issue.) Thanks for any light you folks can shed on this.

    The Faces Context is set up by the Faces Servlet, which hasn't run yet in a filter.
    I haven't tried it, but [url http://blog.lightwaysoftware.com/2010/10/accessing-facescontext-from-a-servlet-filter/]this may help you.
    DOH! That's what you are doing already.
    If you're using JDev 11.1.2.x, you could try [url http://ocpsoft.com/java/jsf-java/jsf-20-extension-development-accessing-facescontext-in-a-filter/]this
    John

  • Accessing Forte from Voice Response System

    We are looking at writing a Forte application that is accessible from a
    telephone voice response system. Has anyone tried this? If so, how do you set
    up the interface between our Forte server (running on AIX) and the voice
    response system. The voice response vendor we are looking at is Periphonics.
    They supply their own hardware running SUN-OS. Communication between the
    Periphonics box and our RS/6000 will be done using TCP/IP.
    My impression is that we will have to wrapper some C code within Forte.
    However, since we are new to Forte I am not sure how this will be done. Any
    suggestions?
    David Wilbur email: [email protected]
    University of Windsor phone: 519-253-4232 ext. 2779
    Windsor, Ontario Canada
    -----------------------------------------------

    David,
    Forte has a new "ExtrenalConnection" class reference in framework which
    you can use with any reliable TCP/IP entity. You should not have to wrapper
    any C code. The ExternalConnection class supoorts fully asynchronous
    processing in both clients and servers.
    Paul Buchkowski
    [email protected]
    Merrill Lynch Canada
    We are looking at writing a Forte application that is accessible from a
    telephone voice response system. Has anyone tried this? If so, how do you set
    up the interface between our Forte server (running on AIX) and the voice
    response system. The voice response vendor we are looking at is Periphonics.
    They supply their own hardware running SUN-OS. Communication between the
    Periphonics box and our RS/6000 will be done using TCP/IP.
    My impression is that we will have to wrapper some C code within Forte.
    However, since we are new to Forte I am not sure how this will be done. Any
    suggestions?
    David Wilbur email: [email protected]
    University of Windsor phone: 519-253-4232 ext. 2779
    Windsor, Ontario Canada

Maybe you are looking for

  • EXCEL ONLINE - Automaticly refresh data in excel from the online data

    Hi Love some help with this one QUESTION Is their anyway 5 users can use excelonline fileA and also keep a uneditable version fileA open in desktop excel and manually refresh the desktop version to see the latest version of the document in uneditable

  • Two routers in the same house...

    Hi, I've been searching the forums all day trying to figure out a solution to my issue. I am not at all tech say when it comes to setting up networks. If you are able to provide me with a solution, please use layman's terms or be overly specif so I c

  • Using terminal to recover files

    I have a new MacBook Air running OS X v. 10.10.2.  It will not boot.  I have a day-old Time Machine backup, but would like to recover work I did today using Terminal before I restore from backup. Is there any way to do this?

  • Rewire track problem

    I've got Logic Pro 7.3, and I've never had to create a rewire track before. Now that I've tried, I'm simply met with the message "No more tracks available". This is not different when I create a new project or start up an old one. Has anyone met this

  • Alternative UOM in product overview(/n/sapapo/pov1)

    Hi, In the product overview,we can see the product quantities in base UOM. our requirement is,we have to see Alternative UOM. How to get this? Thanks & Regards Akthar