users@woodstock.java.net

Popup menu using problem

From: István Lang <istvan.lang_at_gmail.com>
Date: Thu, 28 Aug 2008 23:55:06 +0200

Hi!

I'm a starter in VWP&Woodstock, and I'm totally confused, because I copied
the source code of popup menu component from '
http://webdev2.sun.com/example/faces/index.jsp<https://woodstock.dev.java.net/>'
to try it, but the defined items aren't visible in browser.


Where is the problem?
It could be, that I copied the source code to wrong place or wrong file?
Could I set anything in facis-config.xml or web.xml?

Please see the picture, too!


Thanks a lot!

*István Lang
*





My source code (in Netbeans 6.1):



*Page1.jsp*

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Document : Page1
    Created on : 2008.08.28., 20:14:54
    Author : Langi
-->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="
http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8"/>
    <f:view>
        <webuijsf:page binding="#{Page1.page1}" id="page1">
            <webuijsf:html id="html1">
                <webuijsf:head id="head1">
                    <webuijsf:link id="link1"
url="/resources/stylesheet.css"/>
                    *<script type="text/javascript">
                        function displayMenu(event) {

document.getElementById("form1:popup1").open(event);
                        }
                    </script>*
                </webuijsf:head>
                <webuijsf:body id="body1" style="-rave-layout: grid">
                    <webuijsf:form id="form1">
                        <webuijsf:menu binding="#{Page1.popup1}" id="popup1"
*items="#{popup2.Option}"* style="left: 240px; top: 168px; position:
absolute" visible="true"/>
                        <webuijsf:hyperlink binding="#{Page1.hyperlink1}"
id="hyperlink1" *onClick="displayMenu(event);return false;"*
                           * onMouseDown="displayMenu(event)" *style="left:
240px; top: 144px; position: absolute; width: 96px" text="Katt ide!"/>
                        <webuijsf:menu id="menu2"
items="#{Page1.menu2DefaultOptions.options}" style="left: 504px; top: 168px;
position: absolute" visible="true"/>
                        <webuijsf:listbox id="listbox1"
items="#{Page1.listbox1DefaultOptions.options}" style="position: absolute;
left: 600px; top: 264px"/>
                    </webuijsf:form>
                </webuijsf:body>
            </webuijsf:html>
        </webuijsf:page>
    </f:view>
</jsp:root>


*Page1.java* (the bold fonts in the bottom are the copy-paste code from
https://woodstock.dev.java.net/)

/*
 * Page1.java
 *
 * Created on 2008.08.28., 20:14:54
 */



package _menu;



import com.sun.webui.jsf.component.Hyperlink;
import com.sun.webui.jsf.component.Menu;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.event.EventListener;
import com.sun.webui.jsf.event.ValueEvent;
import com.sun.webui.jsf.model.DefaultOptionsList;
import javax.faces.FacesException;
import com.sun.webui.jsf.model.Option;
import com.sun.webui.jsf.model.OptionGroup;

/**
 * <p>Page bean that corresponds to a similarly named JSP page. This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Langi
 */
public class Page1 extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component
Definition">

    /**
     * <p>Automatically managed component initialization.
<strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code
inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {

    }
    private DefaultOptionsList menu1DefaultOptions = new
DefaultOptionsList();

    public DefaultOptionsList getMenu1DefaultOptions() {
        return menu1DefaultOptions;
    }

    public void setMenu1DefaultOptions(DefaultOptionsList dol) {
        this.menu1DefaultOptions = dol;
    }
    private Hyperlink hyperlink1 = new Hyperlink();

    public Hyperlink getHyperlink1() {
        return hyperlink1;
    }

    public void setHyperlink1(Hyperlink h) {
        this.hyperlink1 = h;
    }
    private Menu menu1 = new Menu();

    public Menu getMenu1() {
        return menu1;
    }

    public void setMenu1(Menu m) {
        this.menu1 = m;
    }
    private Menu popup1 = new Menu();

    public Menu getPopup1() {
        return popup1;
    }

    public void setPopup1(Menu m) {
        this.popup1 = m;
    }
    private DefaultOptionsList menu2DefaultOptions = new
DefaultOptionsList();

    public DefaultOptionsList getMenu2DefaultOptions() {
        return menu2DefaultOptions;
    }

    public void setMenu2DefaultOptions(DefaultOptionsList dol) {
        this.menu2DefaultOptions = dol;
    }

    private DefaultOptionsList listbox1DefaultOptions = new
DefaultOptionsList();

    public DefaultOptionsList getListbox1DefaultOptions() {
        return listbox1DefaultOptions;
    }

    public void setListbox1DefaultOptions(DefaultOptionsList dol) {
        this.listbox1DefaultOptions = dol;
    }
    private Page page1 = new Page();

    public Page getPage1() {
        return page1;
    }

    public void setPage1(Page p) {
        this.page1 = p;
    }
    // </editor-fold>

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public Page1() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     *
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request. Instead, they represent the
     * property values that were saved for this view when it was
rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component
Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("Page1 Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new
FacesException(e);
        }

        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place. This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit. Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).
Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of
whether
     * or not this was the page that was actually rendered). Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }
*
       public class popup {

        private String items;
        private Option OptionItems[];
        private Option groupOptions[];
        private OptionGroup group;
        private String text = "initial text";

        public popup() {
            items = "langi, kabala, vazze";
            OptionItems = new Option[5];
            OptionItems[0] = new Option("One", "one");
            OptionItems[1] = new Option("Two", "two");
            OptionItems[2] = new Option("Three", "three");
            OptionItems[4] = new Option("Five", "five");
            OptionItems[1].setImage("/images/dice1.gif");
            groupOptions = new Option[2];
            groupOptions[0] = new Option("SubOpt1", "SubOpt1");
            groupOptions[1] = new Option("SubOpt2", "SubOpt2");

            group = new OptionGroup();
            group.setValue("Group1");
            group.setLabel("Group1");
            group.setOptions(groupOptions);
            OptionItems[3] = group;

        }

        public String getItems() {
            return items;
        }

        public Option[] getOption() {
            return this.OptionItems;
        }

        public void setOption(Option[] OptionItems) {
            this.OptionItems = OptionItems;
        }

        public String getSelectedItem() {
            return this.text;
        }

        public void setSelectedItem(String text) {
            this.text = text;
        }
    }

    public void popup1_processEvent(ValueEvent ve) {
    }

}

*