You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by William Crose <ip...@gmail.com> on 2006/01/06 05:37:32 UTC

Re: JSCookMenu now supports ActionListener

Thomas,

I used the two files you attached "jscookmenu.jsp" and "JSCookMenuBean.java"
to create a menu to navigate between two jsp pages. The navigation doesn't
work from either page to the other (no navigation at all).  Here is the
snippet of code from the jsp that creates the menu:

<t:jscookMenu layout="vbr" theme="ThemePanel">
        <%/* Availaible jscookMenu themes: ThemeIE, ThemeMiniBlack,
ThemeOffice, ThemePanel
             Availaible jscookMenu layout: hbr, hbl, hur, hul, vbr, vbl,
vur, vul
             respect to Heng Yuan
http://www.cs.ucla.edu/~heng/JSCookMenu<http://www.cs.ucla.edu/%7Eheng/JSCookMenu>
       */%>
  <t:navigationMenuItems id="nav_1"
                         value="#{ navigationMenu.JSCookMenuNavigationItems}"
/>
    <t:navigationMenuItem id="nav_2"
                        actionListener="#{navigationMenu.actionListener}"
                        itemLabel="#{messages['nav_about']}"
                        itemValue="go_about"
                        action="go_about"
                        icon="images/menublank.gif"/>
</t:jscookMenu>

I have included the menu that was created when I ran the app:

<html>
    <head>
<script type=
"text/javascript"
src="/faces/myFacesExtensionResource/org.apache.myfaces.component.html.util.MyFacesResourceLoader/11364315/navmenu.jscookmenu.HtmlJSCookMenuRenderer/JSCookMenu.js"
><!--

//--></script>
<script type="text/javascript"
src="/faces/myFacesExtensionResource/org.apache.myfaces.component.html.util.MyFacesResourceLoader/11364315/navmenu.jscookmenu.HtmlJSCookMenuRenderer/MyFacesHack.js"
><!--

//--></script>
<script type="text/javascript"
><!--
var myThemePanelBase='/faces/myFacesExtensionResource/org.apache.myfaces.component.html.util.MyFacesResourceLoader/11364315/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemePanel/';
//--></
script>
<script type="text/javascript" src=
"/faces/myFacesExtensionResource/org.apache.myfaces.component.html.util.MyFacesResourceLoader/11364315/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemePanel/theme.js"><!--

//--></
script>

<link rel="stylesheet" href
="/faces/myFacesExtensionResource/org.apache.myfaces.component.html.util.MyFacesResourceLoader/11364315/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemePanel/theme.css"
type="text/css" />
  <meta HTTP-EQUIV=
"Content-Type" CONTENT="text/html;charset=UTF-8" />
  <
title> The title</title>
  <link rel="stylesheet"
type="text/css" href="css/ipstyle.css" />

  <link rel="shortcut icon" href="images/favicon.ico"
/>
</head>

    <body>


                <table
 id="header_group1" border="0"
class="pageHeader"><tbody><tr><td><
img id="header_logo" src="images/IPIWebSiteHeader.gif"
alt="" /></td><td><
span style="font-size:10px;color:#000000">Wednesday, January 4, 2006</span
>




            </td></tr>
<tr
><td><img id="header_spacer_main" src
="images/horizontal-spacer-main.gif" alt="" /></
td><td><img id="header_spacer_left"
src="images/horizontal-spacer-right.gif" alt=""
/></td></tr>
</tbody></table>


<
table border="0" class="pageBody"><
tbody><tr><td class="panelMenu"><
script type="text/javascript"><!--
var idJsp4_menu =
[[null, 'Home',
'idJsp4_menu:L#{navigationMenu.actionListener};Home:Ago_home',
'linkDummyForm', null],

['<img src="images/menublank.gif"/>', 'About',
'idJsp4_menu:L#{navigationMenu.actionListener};go_about:Ago_about',
'linkDummyForm', null]];
//--></script><
div id="idJsp4_menu"></div>
<script
 type="text/javascript"><!--
	cmDraw ('idJsp4_menu', idJsp4_menu, 'vbr', cmThemePanel, 'ThemePanel');
//--></script>


		

	

            </td><td class=
"panelSpacer"><img id="spacer" src=
"images/vertical-spacer.gif" alt="" />

            </
td><td class="panelContent">
                <P>&
nbsp;</P>
             <P> Some text here </P>

            </td></
tr>

</tbody></table>
    <form id=
"linkDummyForm" name="linkDummyForm" style="display:inline"
method="post" action="/about.jsf"><
input type="hidden" name="jsf_tree_64"
id="jsf_tree_64"
value="H4sIAAAAAAAAAK1Qu07DQBBcGSLES7wKWgokqGxBQZMyEiFREIiXhFxYx/liX2TfHed1MA0dPR/AF6B8AV9AR8tP0FKzVgyJU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zkWiwvCo4lIk4ZG/JndFllCkaXufSpEzhxQLMeCSPWLOeMkvibKfn2j1f++UOL+vq6qKKUFS+z74oTKxpSuf3XT6/+eeG9FyzULL+CdcYMLDG0NFGhH+SC4WeCovM2VNWoXNlA5cLa0bOsfuX7K6ERdnEZ2kSn3qJ2e62rjNPO2+BJA/jQkJQlPH4EP1OZGPApGR8LLQVlwpSuw75+1f11sW1vRimEDRqKKHpK6sdA5dxnt4+c+2HppgWWC/d5PiNJomC8r2HreKT7dcLrmCvd693ZMdja+TzJxKqExzdIkzL7VZRgNooDPQOctmBQrEwXZ+eet9o0SXQ1ktN7dTKmaHvfOKffx8MRFimZdl52TtFmI1K5THYYLQ8rma970WuD5yzw9z78vHg3AulEdudsW1xGZ3msCDvQjXcA4yFnPdv+R9bYVAXro3fJ+tFNWcsobCmkjc6HNyOe/dcUrHXnwEFD7UGxCS0Lj3ean7sGhk25F+GZnvV8z3ouG0in29CPCRJTtkjjdP+UMRsmoXxT10nq1jBQuxFgo5kwgjNhlgdrAxMBzEQoZ9kdIG43eVoHAAA="
/><input type="hidden" name
="jsf_viewid" id="jsf_viewid" value=
"/about.jsp" /><input type="hidden"
name="autoScroll" /><input type=
"hidden" name="jscook_action" /><script
 type="text/javascript"><!--
function clear_linkDummyForm() {
  var f = document.forms['linkDummyForm'];
  f.elements['jscook_action'].value='';
  f.target=''
;
}
clear_linkDummyForm();
//--></script></form><script type=
"text/javascript"><!--
function getScrolling() {
    var x = 0; var y = 0;
    if (self.pageXOffset || self.pageYOffset) {
        x = self.pageXOffset;
        y = self.pageYOffset;

    } else if ((document.documentElement &&
document.documentElement.scrollLeft)||(document.documentElement &&
document.documentElement.scrollTop)) {
        x = document.documentElement.scrollLeft;

        y = document.documentElement.scrollTop;
    } else if (document.body) {
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    }
    return x + "," + y;
}
//--></
script>


</body>
</html>


In the navigation rules section of the myfaces-config.xml file I have the
following rules:
....
        <from-view-id>*</from-view-id>

        <navigation-case>
            <from-outcome>go_home</from-outcome>
            <to-view-id>/home.jsp</to-view-id>
        </navigation-case>

        <navigation-case>
            <from-outcome>go_about</from-outcome>
            <to-view-id>/about.jsp</to-view-id>
        </navigation-case>
.....

The "JSCookMenuBean.java" was used just as it was provided.

I am using the nightly build dated 12/30/2005.  Can you please tell me what
I am missing?  Can someone please provide a working example of a JSCookMenu
using a backing bean?

Thanks in advance....!




On 12/19/05, Thomas Spiegl <th...@gmail.com> wrote:
>
> Hi,
>
> I implemented the actionListener for JSCookMenu. Get the latest version
> from SVN or use nightly build to get the new feature.
> Attached you will find an example.
>
> 1) Example 1  Static
> <t:navigationMenuItem id="nav_2"
>     actionListener="#{navigationMenu.actionListener}"
>     itemLabel="#{example_messages['nav_Home']}"
>     itemValue="go_home"
>     action="go_home"/>
> The actionListener JSCookMenuBean.actionListener(ActionEvent event) will
> be executed. HtmlCommandJSCookMenu is now holding the itemValue of the
> clicked menu entry. Additionaly the action attribute may be given to trigger
> a page navigation.
>
> 2) Example 2 Dynamic
> Shows how to generate menu items 'dynamically' by using
> NavigationMenuItem(s) + how to define an ActionListener per item (see
> JSCookMenuBean.getJSCookMenuNavigationItems())
> The actionListener JSCookMenuBean.actionListener(ActionEvent event) will
> be executed. HtmlCommandJSCookMenu is now holding the value that was set for
> the NavigationMenuItem (see JSCookMenuBean.getMenuNaviagtionItem(...))
>
> Cheers
> Thomas
>
> --
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>