Where/How do I programmatically build the component tree?

Hi! I'm having a lot of problems trying to make my JSF application work...
Here's the situation:
- I have to display a form (questionnaire) consisting of a tree (form - subforms - sections - groups - questions - checkboxes/dropdowns...). Each of these parts are custom components, with custom renderers.
- This display is only a small part of a wider application (so the custom ViewHandler solution seems impossible to me), and it is done in an imported jsp (using <jstl:import ...>). In this jsp, there is only one component, representing the "root" of the questionnaire, because the structure of the questionnaire is unknown at the beginning.
- I need to build programmatically (in Java) the component tree of my questionnaire (according to the structure loaded from a database) and integrate it in the component tree of the whole application.
- The problem is I can't get this to work properly in the JSF lifecycle (either the restoreState/saveState methods aren't called, or the "main" tree doesn't contain my "sub-tree" although everything is rendered properly...). I searched on a lot of forums, I tried a lot of solutions (new UIComponent() vs. application.createComponent(...) / create the tree in the component constructor vs. in the component renderer... ) but none of them seemed to meet my requirements, since it seems to be a tricky situation.
So, does anyone knows how to achieve this? How and where to build my component tree?
(ask me if a you need more information about my code!)
Thanks in advance!!
Adriano

Bit_happens wrote:
- I'm using the "createComponent" method to build my tree (instead of just calling the component constructor), is that right? For example:
UISubform subformComponent = (UISubform) application.createComponent(UISubform.TYPE);
//UISubform subformComponent = new UISubform();What is the difference with the plain constructor call?You are not implementation dependent then.
- Apparently, I have to explicitly add the panelGroup to the component tree, or else it won't be part of the tree. Is that normal? Shouldn't JSF add it to the tree automatically when it finds it in the JSP? I have to do the following:
UIComponent parent = facesContext.getViewRoot().findComponent("form_subview").findComponent("main_form");
parent.getChildren().add(panel);
panel.setParent(parent);- Is there a difference between creating the "sub-tree" in an ascending way, or in a descending way? I.e. first creating the leaves and then going up the branches until I plug the root component into the main tree, or first creating the root component and then going down the branches until all the leaves are created?No, there isn't.
- I think my custom components themselves should be right, and they're declared in faces-config. It looks like the panelGroup doesn't renders its children, but it should by default, right? When I look at the rendered page source code, the panelGroup is empty:
<span id="form_subview:main_form:formPanel"></span>- Do you think of anything else I should check? Any tricky setting I could have forgot?Try adding existing components to the panelGroup, e.g. HtmlOutputText. If that works, then I rather think there is a flaw in your component.

Similar Messages

  • How to construct the component tree in my custom component?Help!

    Hi, i am writing a custom component like this:
    public class HtmlCategory extends HtmlPanelGrid
         public void processRestoreState(javax.faces.context.FacesContext context,
                java.lang.Object state)
              setColumns(1);
              HtmlCommandLink link=new HtmlCommandLink();
              link.setValue("Let's Bingo");
              MyUtil.setActionListener(context,link,"#{temp.mytest}");
              UIParameter param=new UIParameter();
              param.setName("name");
              param.setValue("Robin!");
              link.getChildren().add(param);
              param.setParent(link);
              getChildren().add(link);
              link.setParent(this);
              super.processRestoreState(context,state);
    }         you see, i want to construct the compont tree at Restore View phase this way,because the structure of the component tree will always be the same, so i don't the user to write extra code.
    But the children of the component are not rendered,the renderer of the HtmlCategory component just extends the HtmlGridRenderer(myfaces) directly,and always calls the "super" methods in the encode methods of the renderer.
    I got a message from the console:
    Wrong columns attribute for PanelGrid id0:id4: -2147483648
    but i have set the columns attribute in the code above, so what's happening? or please give some advice about how to render the component tree by myself in Restore View with the tree constructing code in the custom component class code,just lke the code above.
    Best Regards:)
    Robin

    Well, i don't know if i have got my question clear.
    usually, according to the tags you use in the jsf page, a component tree will be created at the Restore View phase,for example:
    <f:form>
      <h:panelGrid ...........>                         
              <h:dataTable ................>
              </h:dataTable>
       </h:panelGrid>
    </f:form>but because i am writing a component for my web app, all the child components and their attributes are not likely to change. so i want to reduce the tags into one custom tag, and construct the component tree internally by myself.But it is not the case of backing bean.So i wrote the the code in the method:
    public void processRestoreState(javax.faces.context.FacesContext context,java.lang.Object state)as it is shown in my orginal message.But it seems that it is not right way to construct my component tree.So where should i put the code that construct the component tree?Overriding the method :
    public void processRestoreState(javax.faces.context.FacesContext context,java.lang.Object state)is not the right way?
    Best Regards:)
    Robin

  • How do we programmatically "enable" the Page to have

    Some body known how do we programmatically "enable" the Page to have
    Item level security. - analogous to checking the box in the Page edit mode for "Enable item level security"
    J.

    Try this. It might work for you.
    declare
         l_page portal.wwsbr_api.page_record;
    begin
         select * into l_page
         from portal.wwv_user_owned_corners
         where siteid = <page group id>
         and id =<page id>;
         -- 0 is disabled . 1 is enabled.
         l_page.haveitemsecurity := 1;
         portal.wwsbr_api.modify_folder(
                   p_page => l_page
         wwpro_api_invalidation.execute_cache_invalidation;
         commit;
    end;
    regards
    Suresh.

  • How do I programmatically reference the current page in 902?

    Hello,
    How do I programmatically reference the current page in 902?
    The Portal Smart Text option for Current Page is not flexible enough, and I wish to create my own custom greeting using PL/SQL.
    Cheers,
    John

    hi,
    If you are developing a PLSQL Portlet, then you do have a way for getting the page URL.
    The page URL can be obtained from the record, portlet_runtime_record. There is a filed page_urlavailable with portlet_runtime_record.
    The portlet_runtime_record is passed as a argument to the show_portlet procedure.
    --Sriram                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How do I find out the component ID on a certain page?

    How do I find out the component ID on a certain page? problems is that I'm using some page template which I do not have source code for that.I need to find out the component id to pass to UIComponent.findComponent(id) as parameter. is there anyway?
    Thanks

    If you go to the partial trigger property of any of your page component you can open the edit partial trigger browser.
    There you can find the components of your template and their ids

  • Manipulating the component tree at runtime

    How is it possible to add components into a form at runtime. I need to create role specific menues after login. I have tried adding new children to the form object but they do not seem to render.

    in a short word, when is the rendered attribute value processed?is it part of the request map, and at Restore View Phase when restore the component tree, the inputText component will not be restored,and is this the reason the new name value is not applied?
    But if i change the editable attribute in the same class( User.java) with the name attribute,and change the jsf code like this:
    <h:selectBooleanCheckbox value="#{user.editable}" onclick="submit()"></h:selectBooleanCheckbox>
          <h:inputText  value="#{user.name}" rendered="#{user.editable}" required="true"></h:inputText>
          <h:outputText value="#{user.name}" rendered="#{not user.editable}"></h:outputText>The new value is applied!!
    Please give some suggestion, and many many thanks:)
    Best Regards:)
    Robin

  • Modifying the component tree in FacesListener

    Hi,
    I want to modify the component tree of every page that is accessed within my JSF application. For example, say I want to remove one component(id is known) from every page that is accessed. Obviously, I don't want to edit the page manually.
    I wrote and configured a FacesListener which will be executed during the RESTORE_VIEW phase. In the afterPhase() method, I get the view root from FacesContext. I traverse down to the component with the given Id and remove it from its parents child list. But it doesn't get removed. The component is rendered. Even trying to chage its value or adding a new component doesn't work. Basically any modification done to the tree after the RESTORE_VIEW phase in the FacesListener is not reflected in the rendered output.
    Is it the right phase to modify the view?
    Thanks,
    Siva

    There is a typo in my question. I mean PhaseListener not FacesListener.
    Siva

  • Bug report - font disappear in the component tree

    bug report - font disappear in the component tree
    thanks
    from Peter ([email protected])

    Any more information? Does this always happen? Sometimes?
    Does it depend on the font used in Eclipse?
    Does it depend on the Eclipse theme used?
    What distro/version of Linux are you using? What window manager?

  • How do i programmatically get the current version of a file?

    I asked this same question in the SP2013 forum and I haven't been able to determine the solution. So I posting this here, to maybe get more eyes on this issue. 
    ...I am basically trying to programmatically get the current version of a document in a library, then determine if its a major or minor version, in code. I have tried doing this, to get the current version but I keep getting an empty string returned.
    var versions = item.File.Versions;
    string currentVersion = string.Empty;
    foreach (SPListItemVersion version in item.Versions)
    DateTime lastMod = version.Created;
    foreach (SPFileVersion fileVersion in versions)
    if (fileVersion.IsCurrentVersion == true)
    currentVersion = fileVersion.ToString();
    Does anyone know what am doing wrong, and how to get this resolved? I really appreciate the help. Thanks

    Why not just get the SPListItem and look at it's Version property? That'll be the latest version.
    No need to go into the Versions collection etc. When you get a list item you get the current version as standard.
    w: http://www.the-north.com/sharepoint | t: @JMcAllisterCH | YouTube: http://www.youtube.com/user/JamieMcAllisterMVP

  • How can I programmatically change the fill color Settings of the Cwslide ActiveX Controls

    In design mode (Visual Studio 6.0),I want to programmatically change the fill color in properties of  cwslide  ActiveX Controls.what's the command?
    Attachments:
    cwslide.JPG ‏11 KB

    First, if you want to start getting beyond the basics with DAQ, you are going to have to stop using the DAQ assistant and do it with lower level DAQmx VI's.  There are hundreds of examples in the example finder.  You can even right click on the DAQ assistant and select open front panel.  That will create a subVI that you can open and see what is going on behind the scenes.  Do it.  I think you'll find the DAQ task is being recreated on each (though I'm not 100% of how the settings are established or maintained in each section of that subVI).
    The second problem is you have a bit of a race condition on iteration 0.  Those two DAQ property nodes are running at the same time.  So when you read the AI.Max, it may be happening before or after the AI.Max is set in your case structure.
    Third, make sure you wire up your error wires.

  • How do I programmatically force the RT engine to reboot?

    I have a stand alone emebedded executable which I run on a PXI-8156B controller. It needs to stop and reboot itself under certain circumstances. How do I do this programmatically (ie like calling ExitWindowEx with windows)? The only thing I can think of is to force the watchdog timer to expire.

    Dr. Billy,
    Forcing the watchdog timer to expire is the only way to programmatically reboot the PXI Controller at this time. If you would like to request a feature that will allow you to do it another way, visit http://www.ni.com/labviewrt and click on LabVIEW Real-Time Wishlist.
    Chad H.
    Applications Engineering
    National Instruments
    http://www.ni.com/ask

  • How to remove and add the component to JFrame at runtime.

    Hi
    How to delete the JTabbedPane component from the Jframe at runtime and how to add the same component with different data at runtime.
    But the remaining components should not distrub.
    When i try to delete and add the component at runtime the remaing components are distrubed.
    when i minimize and maximize the screen, the components are adjusted. but i need a help on this without minimize and maximize the screen.

    Hi
    I am sending my code snippet, please look into this......i am doing the same even though i am not able to..................can u suggest anything seeing this code snippet.
    here one function called createtabpane (It creates the JTabbedpanes with the table information at runtime).
    private void getTimeSheetObj(String weekDate){
    //Object[][] rowObj=null;
    try {
    System.out.println("Inside the gettimesheet method try block");
    if(projTables!=null){
    for(int i=projTables.length-1; i>=0; i--){
    JTable jt = projTables;
    jTabbedPane_Main.remove(jt);
    System.out.println("Removing Table:"+i);
    jPanel_Tabbedpane.remove(jTabbedPane_Main);
    jTabbedPane_Main = new JTabbedPane();
    jTabbedPane_Main.revalidate();
    jPanel_Tabbedpane.revalidate();
    getContentPane().validate();
    getContentPane().repaint();
    jTabbedPane_Main.addChangeListener(new ChangeListener(){
    public void stateChanged(ChangeEvent ce){
    getTabbedPaneListenerValues();
    // this.setState(JFrame.ICONIFIED);
    // this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    res = GetTimesheetResponseDocument.Factory.parse(new File("C:\\Narayana.xml"));
    response = res.getGetTimesheetResponse();
    proDets=response.getProjectDetailsArray();
    numOfPro = proDets.length;
    String taskDayValues[] = new String[8];
    System.out.println(numOfPro);
    proArr=new Object[numOfPro];
    Object[][] taskValues=null;
    for(int p = 0;p<numOfPro;p++){
    System.out.println("Inside1");
    taskDet = proDets[p].getTaskDetailsArray();
    taskValues = new Object[taskDet.length][8];
    for(int t=0;t<taskDet.length;t++){
    System.out.println("Inside2");
    taskValues[t][0] = (taskDet[t].getTaskName());
    taskValues[t][1] = (taskDet[t].getDay1HH()+":"+taskDet[t].getDay1MM()).toString();
    taskValues[t][2] = (taskDet[t].getDay2HH()+":"+taskDet[t].getDay2MM()).toString();
    taskValues[t][3] = (taskDet[t].getDay3HH()+":"+taskDet[t].getDay3MM()).toString();
    taskValues[t][4] = (taskDet[t].getDay4HH()+":"+taskDet[t].getDay4MM()).toString();
    taskValues[t][5] = (taskDet[t].getDay5HH()+":"+taskDet[t].getDay5MM()).toString();
    taskValues[t][6] = (taskDet[t].getDay6HH()+":"+taskDet[t].getDay6MM()).toString();
    taskValues[t][7] = (taskDet[t].getDay7HH()+":"+taskDet[t].getDay7MM()).toString();
    System.out.println("After taskvalues");
    proArr[p]=taskValues;
    createTabPanes(jTabbedPane_Main, proArr);
    System.out.println("outside");
    jPanel_Tabbedpane.add(jTabbedPane_Main);
    jTabbedPane_Main.getAccessibleContext().setAccessibleName("Proj");
    getContentPane().add(jPanel_Tabbedpane);
    pack();
    }catch(XmlException xe) {
    System.out.println("Inside the XmlException block");
    System.out.println(""+xe.getMessage());
    } catch(IOException ioe) {
    System.out.println("Inside the IOException block");
    System.out.println(""+ioe.getMessage());
    /* JOptionPane.showMessageDialog(null,
    "Values Displayed in the below tables",
    "Alert!",JOptionPane.ERROR_MESSAGE); */
    System.out.println("Initial JFrame Bounds:"+this.getBounds());

  • How can I programmatically retrieve the CVI Target Version Settings (e.g. File Version, Copyright, etc) in my CVI application?

    Is there any way that I can programmatically retrieve the CVI Target Version Settings (e.g. File Version, Copyright, etc) in my CVI application?
    I am using LabWindows/CVI version 7.0.
    The settings that I'd like to retrieve within my application are those that are set under Build | Target Settings... | Version Info...
    e.g.
          File Version
          Product Version
          Company Name
          Legal Copyright
    Thanks,
    Darren
    Message Edited by Darren Draper on 01-16-2006 02:03 AM

    Well, "File access permission denied" claims for an authorization problem . I suggest you double check file attributes in the project directory: it could be that you have downloaded this example from a CD and the read-only attribute has not been cleared.
    The library does not reside in the example folder: as you can see by selecting View >> Show full pathnames in the project window, it should be in ....CVI\sdk\lib folder.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How can you Programmatically recalculate the tax on AR Transaction Line

    Hi
    Does anyone have any clue about the API which can be used to programmatically recalculate the tax on the sales order line.
    We are using EBTAX Engine.
    Regards

    Which tax engine are you using in your environment? Are you using standard Oracle e-biz tax?

  • Building the swing tree  -- GR8 JAVARIANS PLEASE HELP

    I need to create a swing tree where i have set of co-ordinates in a array.
    My array contains the following value
    1.1.1.2
    1.1.3
    1.2.3
    2.6.2
    Based on this array i need to create the tree structure
    in the above co ordinates
         1.1.1.2 ->First level - First node (parent)
         1.1.3 --> should be the child node for 1.1.1.2 since this the only coordinate which is in the next level (child for      1.1.1.2)
         1.2.3- This should be the next level (2nd level)
         2.6.2- This should be the 3rd level
    My array is dynamic how to build the tree using co-ordinates?.. is there any algorithm ? API ?
    HELP NEEDED !!!!

    I'm glad you recognise that an API is what you need. You'll find one by clicking on the link on the left labelled APIs.

Maybe you are looking for

  • There was a problem connecting to the server. This error message comes continuously when running final cut pro x

    I used to have a nas connected to my mac, i mounted it with AFP. Added some music to my movies from that location but all downloaded to my local mac. There is nothing on the nas that is required in my movie, still i get the message continously poppin

  • Two problems with 10.9.3 update

    Two problems that seem to have appeared after the latest update. 10.9.3 1) My trackpad will not scroll up/down left/right. All other functions work. 2) User accounts are not showing up in finder windows. When I click on internal or external drive (bo

  • Update asking for 2.1 which i scare phone be blocked i am not in hk

    I have baught 3g it work but when updates for some apps i try it say update to 2.1.As i have baught it from thailand using in Afghanistan, some one told me that if you update to 2.1 u r phone will block.pls guide me.

  • Importing folders?

    New user of Premiere Pro CS6. While I have a lot of long past Premiere 6.5 experience, I've been away from editing for a while. Now I'm back on CS6! How do I import whole folders of clips into CS6? I tried going into Edit>Import, and this will let me

  • Print results the script in landscape mode

    Hi folks, how I can in powershell print off the results ofthe following code in landscape mode: $result | Where {!$_.Values} | Foreach {Start-Process -FilePath "s:\INVOICES\0070\$($_.Invoices).pdf" –Verb Print}