Add UIComponents to the page via the backing bean

Is it possible to add a UIComponent to my page (Page1.jsp) from the backing bean (Page1.java)?
For example:
public class Page1 extends AbstractPageBean {
  public Page1() {
    HtmlPanelGroup panel = new HtmlPanelGroup();
    this.page.getChildren().add(panel);  //<-- doesn't work
}

Hi Lexicore:
I'm new to JSF and tried to utilize your example - with no success (see below)...
I assume I took your suggestion to literally.
Please tell me what is missing.
****jsp page: jsp1.jsp****
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<f:view>
<head>
<title>jsp1</title>
  <link rel="stylesheet" type="text/css" href="./style.css" title="Style"/>
</head>
<body bgcolor="#ffffff">  TESTING...
  <h:form id="form1">
    <h:panelGrid id="panelgridtest" binding="#{jsp1Bean.component}"/>
  </h:form>
</body>
</f:view>
</html>
****backing bean: "Jsp1Bean.java" ****
package test;
import javax.faces.application.*;
import javax.faces.component.*;
import javax.faces.component.html.*;
import javax.faces.context.*;
import javax.faces.el.*;
public class Jsp1Bean
    protected UIComponent component;
    public Jsp1Bean()
        component = new UIPanel();
    public UIComponent getComponent()
        return component;
    public void setComponent(UIComponent component)
        this.component = component;
//initialization block
        try
            FacesContext facesContext = FacesContext.getCurrentInstance();
            UIViewRoot uIViewRoot = facesContext.getViewRoot();
            Application application = facesContext.getApplication();
//outputText1
            HtmlOutputText outputText1 = (HtmlOutputText) facesContext.getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
            outputText1.setValue("---the outputText1 value---");
//inputText1
            HtmlInputText inputText1 = (HtmlInputText) facesContext.getApplication().createComponent(HtmlInputText.COMPONENT_TYPE);
            inputText1.setValue("---the inputText1 value---");
//add outputText1 and inputText1 to component ("UIPanel")
            component.getChildren().add(outputText1);
            component.getChildren().add(inputText1);
        catch (java.lang.Throwable t)
            System.out.println("java.lang.Throwable exception encountered...t.getMessage()=" + t.getMessage());
            t.printStackTrace();
    public String doAction()
        return "submit";
****faces-config.xml****
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
  <navigation-rule>
    <from-view-id>/jsp1</from-view-id>
    <navigation-case>
      <from-action>submit</from-action>
      <to-view-id>/jsp1</to-view-id>
      <redirect/>
    </navigation-case>
  </navigation-rule>
  <managed-bean>
    <managed-bean-name>jsp1Bean</managed-bean-name>
    <managed-bean-class>test.Jsp1Bean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
  </managed-bean>
</faces-config>
**** Error Message I receive from trying to run ****
Nov 5, 2004 5:05:03 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /test from URL file:C:\tomcat\webapps\test
Nov 5, 2004 5:05:09 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /tomcat-docs from URL file:C:\tomcat\webapps\tomcat-docs
Nov 5, 2004 5:05:09 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /webdav from URL file:C:\tomcat\webapps\webdav
Nov 5, 2004 5:05:10 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8084
Nov 5, 2004 5:05:10 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8012
Nov 5, 2004 5:05:10 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=15/234  config=c:\tomcat\conf\jk2.properties
Nov 5, 2004 5:05:10 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 16656 ms
java.lang.Throwable exception encountered...t.getMessage()=null
java.lang.NullPointerException
        at test.Jsp1Bean.<init>(Unknown Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:308)
        at java.lang.Class.newInstance(Class.java:261)
        at java.beans.Beans.instantiate(Beans.java:204)
        at java.beans.Beans.instantiate(Beans.java:48)
        at com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:204)
        at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:253)
        at com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:78)
        at com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:125)
        at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:146)
        at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
        at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
        at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
        at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:389)
        at javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1018)
        at javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1045)
        at javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:742)
        at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:423)
        at com.sun.faces.taglib.html_basic.PanelGridTag.doStartTag(PanelGridTag.java:442)
        at org.apache.jsp.jsp1_jsp._jspx_meth_h_panelGrid_0(jsp1_jsp.java:152)
        at org.apache.jsp.jsp1_jsp._jspx_meth_h_form_0(jsp1_jsp.java:131)
        at org.apache.jsp.jsp1_jsp._jspx_meth_f_view_0(jsp1_jsp.java:101)
        at org.apache.jsp.jsp1_jsp._jspService(jsp1_jsp.java:62)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

Similar Messages

  • When I am on Safari, the page randomly goes back to the previous page I was on. This is really frustrating when I am writing something online because it does not save my work. Fix for this?

    When I am on Safari, the page randomly goes back to the previous page I was on. This is really frustrating when I am writing something online because it does not save my work. Fix for this?

    (A) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.
    (B) Reset all settings
    Settings>General>Reset>Reset all settings
    Note: Data will not be affected but settings will be reset.

  • How to get the page navigation buttons back at the bottom of the page?

    After upgrading to Acrobat X I discovered that there is only one option for the page navigation buttons - at the upper left. I'm mystified as to why they put them there. Most users are right-handed. With the buttons at upper left it's awkward to reach up there, across the page, with the mouse cursor for every page turn (yeah, I know you can use the PgUp/PgDnkeyboard keys, but that requires taking your hand off the mouse every page turn).
    What I really want is to be able to put a copy of these buttons back down at the bottom center of the page, which was an option in previous versions. Is there some way to get those back at the bottom?

    Hi terpenoid,
    Have you tried Read Mode yet ( under the View menu)?  It displays a nivagation bar at the bottom of the PDF with next/previous page, zoom in/out, etc.
    Hope this helps,
    Dimitri
    WindJack Solutions
    www.windjack.com
    www.pdfscripting.com

  • Add a favicon to iweb via the HTML snippet...how?

    Is there a way to add a favicon to iweb via the HTML snippet?
    My search on google has found many ways to do it by editing the published files, but this is more work than it is worth (since it needs to be done on every new publish).
    Any ideas?
    thanks
    bob

    bob:
    There's been no way to add a favicon via HTML snippet that I've found. Using TextWrangler which can do multi-file find and replace doing it the old fashion way, post publication editing, is a little easier as described in Old Toad's Tutorial #22 - Adding a Favicon to Your Web Site.
    Send a feature request to the iWeb developers via http://www.apple.com/feedback/iweb.html
    OT

  • JSF and ADFBC: How to Run a method every time the page is posted back

    Hi everyone,
    I am using ADFBC and JSF in my project, and there is a page which runs the following logic: The page displays a set of radio options and a submit button. It has a total of 4 options, but they never display all at once. For example, when user enters the page for the first time, only selectItem 1 displays. When it clicks on the submit button, the page is posted back and hides the first select item, showing now the second, and so forth. The steps i did to achieve this are:
    1 - Created a method on the App Module that inserts a row corresponding to the select item choice.
    2 - Created another method that verifies which is the lastly entered row and returns a string containing the relevant attribute, for example, "E".
    3 - Created the methodAction binding to run the insertMethod (1) and retrieveMethod (2).
    4 - Created an invokeMethod executable for the retrieveMethod (2) and set the refresh property to "always".
    5 - Created a variableIterator with a variable to hold the retrieveMethod return, also setting the refresh to "always".
    6 - Lastly, bound the "rendered" attribute of each select item to the variable's value, for example "#{bindings.returnVariable == 'E'}
    When i run the page, the logic works almost fine, except for one detail: When the user clicks the button that calls insertMethod, the page is posted back, and i assume the selectItems should be re-rendered accordingly. Yet, the button click inserts the row in the DB (called insertMethod) but keeps showing the previous radio item. If i restart OC4J, when i enter the page again the radio is now correct, showing the next option.
    Do you know how can i tell the page that the model has been refreshed, so it runs the retrieveMethod again, alters the variable and the radio options without having to leave the page or restarting OC4J?
    Thanks in advance for your help!
    Regards
    Thiago Souza

    Hi all,
    It seems i have figured out the error. It was a logic mistake on my method, ADF was doing the refreshes just fine. There is another little question i wanted to ask now: I need to execute a JSF Navigation Case when the page loads, in order to navigate to another page due to a certain condition. is there any way to run some logic to redirect the request before the page has been rendered, just like the onLoad() javascript event runs on the body every time it gets loaded?
    What i'm trying to do exactly is this: When the login.jspx page runs the "success" navigation case, it goes to "page1.jspx". But before "page1.jspx" is loaded, i need to run an Application Module method to check for a certain situation; if this criteria is not met, i must run "fail" navigation case, from "page1.jspx" to "page2.jspx" without ever displaying page1.jspx.
    Is it clear enough? Can you guys give me some pointers on how to do it?
    Thanks a lot!
    Thiago

  • What can I do to get back to a point that I can directly purchase Apps from my itouch via wi-fi. I was able to before I purchased an app on my PC and loaded it into the device via the sync cable.

    What can I do to get back to a point that I can directly purchase Apps from my itouch via wi-fi. I was able to before I purchased an app on my PC and loaded it into the device via the sync cable. My itouch 2G was bought 2nd hand, so when trying to get Apple support I was unable to register my device because I didn't know it's original purchase date. Note: I am still able to download the apps to my computer and load/sync them into the device.

    Why can you not buy from the ipod?
    What happens when you try?
    Error message?
    What does it say?
    Any info?

  • Add another mail login page besides the default mail login page

    I want to add another mail login page besides the default mail login page(http://mail.mine.com). This should be accessed as:http://mail.mine.com/soo.htm.
    I will keep the default page available too.
    Is this possible? where to put this new page? How to config this?
    Thanks!!!

    If it works, then you have found it.
    I make no claims to be a javascript programmer, nor do I claim to program html code.
    If it doesn't work, you may need to remember that Messaging Express isn't really a web server, it's only a piece of one. . .

  • My emails are appearing along the top of the page in the tool bar area? how do i get rid of this and back to the regular email page

    I opened my Mozilla yesterday and noticed my email page format was different then after a second, I noticed all my emails were now appearing along the top of the page in the tool bar area below "Fine Edit View Go ...etc" I'm not sure what happened. PLEASE help me I'm sure it's probably an easy fix, however I don't know how to fix it :)~ Also they are oldest email first, and since I normally save them for 45 days before deleting, I cant seem to get to the most recent email first. Ugh.
    Truly appreciate your help.

    This is what happens when you continually open messages in tabs but never close them. Pretty soon all you have are message tabs showing and you have pushed the Inbox off the screen.
    Get in the habit of closing message tabs after you read them.
    To get out of your situation now, right click one of the tabs and select Close Other Tabs. Then use the x to close the last one.

  • Pass parameter to apex page via the URL

    Hi, I need to pass a parameter into a page that will be used in a query inside a report region,
    e.g report region query is
    select link_id, page_id, menu_parent_id, link_text, link_url
    from portal_pages
    where page_id = :page_id
    So the page will display different links depending on what value is passed to the page in the variable.
    I know with normal URL syntax it would be something like
    http://www.domain.com/page.html&page_id=1 (where page_id is a hidden variable in apex)
    but how do I do this with an apex page like :-
    http://host:port/pls/apex/f?p=123:9 <what goes here ? and what goes in the page for it to work>
    Any help appreciated - noob to Apex
    Thanks
    Phil.

    If your item to be used in the url is P1_Page_Id, the
    url should be something like:<br>
    http://host:port/pls/apex/f?p=123:9:page_id:&P1_Page_I
    d.
    Thanks for comments, understand the syntax of the apex URLs now, got the item sorted in the page now, all working.

  • In firefox, whenever i have my mouse over the page (not the toolbar section), any selection i have moves. For example - a text entry box and the cursor keeps returning to the start of the box. This is only in firefox, everything else works fine (IE and Ch

    I have an issue with FF. Whenever I have my mouse on the page (not the toolbar area) any selection I make gets altered in the following way:-
    Text boxes - The cursor keeps moving to the left.
    "Radio" buttons - Selection keeps moving up.
    This is only happening in FF, I am not seeing this behaviour in Chrome or IE.
    == This happened ==
    Every time Firefox opened

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • How do I get rid of the new "status bar" at the bottom of the page where the web address pops up?

    On the left hand side of the page in the bottom corner, the web address pops up every time a new page is loading. What if I don't want that? How do I disable it?

    miss.bev.brown, Right-click on a toolbar, then click on teh "Add-on bar" entry to de-select it.
    If the add-on bar keeps coming back, you will have an add-on that is causing this. One that does this is the McAfee Site Advisor, disabling or uninstalling it stops that from happening.

  • HT1414 When I search for stuff on the internet it says safari could not open the page because the server stopped responding and non of my games work either. What do I do to fix this?

    When I search for stuff on the internet it says safari could not open the page because the server stopped responding and non of my games work either. What do I do to fix this?

    Settings → scroll down to Safari → in Safari settings, I selected both Clear History and Clear Cookies and Data.
    IF that does not work -
    Restart or reset your iPhone, iPad, or iPod touch - Apple Support
    Finally - if problem still present -
    Go to Settings>General>Reset
         Reset the network settings - you will need to add the password of your home WiFi in your phone once more
    The device should turn itself off & back on then go into Settings>Wifi and join your network

  • No background or the page is the size of the screen

    I have used Visio for 20 years, currently using 2000,  but whole of a suddenly the background, that used to be a bluage green became white, the same as the page so now I can't see the size of the page. It does not matter if I change the page background
    color under Tools-"Options". Nothing changes. However, if I change the Page color the whole workspace become that color. From that it's like the whole workspace become the page no matter what size the page is set to. The only way I can see the "page"
    is to select View-Page Break. Then it display the page size correct. I even uninstalled the program fully and reinstalled it with the same result. I'm at a loss.
     Any  idea?

    Hi Berntronny,
    Does any update install on your PC before background disappear? If yes, we can uninstall it temporarily. Let’s open Visio in safe mode to disable some add-ins and macros.
    Since Visio 2000 SR1 is end of life, if you need further support, I recommend you can upgrade a newer version of Visio.
    If there is anything I can do for you regarding this issue, feel free to post back.
    Best regards,
    Greta Ge
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.
    Fortunately there are people here who are more than willing to help those using older versions of software. Some people can't upgrade, business policy may not allow it, can't afford it, or just plain might think Visio 2000 was the best ever version. Are
    Pactera paid by Microsoft for this support?
    If this Configuration Analyzer Tool you are advertysing can scan for hundreds of issues in Office, why cannot these issues just be fixed?
    Paul Herber, Sandrila Ltd. Engineering and software shapes for Visio
    Sandrila Ltd

  • A bridge between the page and the EO using the action listener

    hi
    i have a requirement that when pressing a button i want some action to be performed and this action is related to some field in the database.
    i have the problem that i don't know how to reach the EO from the action on the screen
    answer by John Stegeman:
    Put an actionlistener on the button, and in the backing bean call a method (that you will write) to do the same thing and set the attribute in the VO, not the EO.
    please can u give me more details
    thanks

    User,
    In the ADF Developer's Guide for Forms/4GL developers - section 8 shows how to put some code in your Application Module to do model manipulation.
    Section 21.6 shows how to call that method from an ADF Faces web page via the binding layer.
    Best,
    John

  • When I try to use Safari on my i6 phone to connect to internet, it says "Safari could not open the page because the server stopped responding."  However, my wi-fi is connected on the phone and computer.  What can I do to correct this?

    When trying to connect to internet, my i6 phone says "Safari could not open the page because the server stopped responding."  However, our house's wi-fi is on. Any ideas why this is happening?

    Settings → scroll down to Safari → in Safari settings, I selected both Clear History and Clear Cookies and Data.
    IF that does not work -
    Restart or reset your iPhone, iPad, or iPod touch - Apple Support
    Finally - if problem still present -
    Go to Settings>General>Reset
         Reset the network settings - you will need to add the password of your home WiFi in your phone once more
    The device should turn itself off & back on then go into Settings>Wifi and join your network

Maybe you are looking for

  • Can you use a custom cursor with drag and drop?

    Hi there! I'm a newbie flash user and working on a simulation for a graduate course in instructional design. I'm using Flash Professional CC on Mac. Here's what I'm trying to do. I have several draggable sprites on the stage and three target sprites.

  • Thin driver / 8i / Solaris hangs for 60 seconds

    I am having the same problem that I have also seen in these two messages: http://technet.oracle.com:89/ubb/Forum8/HTML/002149.html http://technet.oracle.com:89/ubb/Forum8/HTML/001335.html Using the thin driver to connect to Oracle 8.1.6 on Solaris 7,

  • I can reset my secret question and I do not have rescue email. What I do ?

    Help  Ito get my secret question  and I do not have rescue mail

  • Phone and SMS Spam

    I am getting unwanted Phone calls and SMS messages from Spammers on my iPhone. Can I set up my iPhone in such a way Calls and SMS messages from any one not in my contacts list, will not be responded to or sent to voice mail, indicating to the Spammer

  • Oracle development suite 10g

    Hi I m in learning phase of oracle and m trying to installing oracle development suite on windows XP. After installing oracle development suite on windows 2000 my sqlnet.ora,listner.ora and tnsnames.ora has the following structure: I am trying to run