Skip to main content

how to use jmaki accordion menu

18 replies [Last post]
lazarus___
Offline
Joined: 2008-08-26

Hi ,
i have already exposed my problem in another post but i open this new one because the other post were abt another question...

I want use the accordion menu that in Jmaki dojo.

i my start page now i have tree link :

 </p>
<p>

every link call a function declares in a command bean.. Now i want to know how put links in accordion menu to have the same effect i have know.. Plus i want to know if exists a guide for the widgets use that show how to use widgets with jsf. I don t want to disturb the forum every time i d on t know hot to do something but i m new about jmaki technology and thanks of snolab i have understood the publish submit mechanism...
Plus i wish know how to set properties of widgets for example the dropdown picker give me a date like yyyy mm dd how i have to do if i want a date like dd mm yyyy?
i know i m boring with my questions and i ask sorry for that but i dont know where i can find some clear documentation. Thanks to everybody and sorry again for disturbing
Laz

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dan862
Offline
Joined: 2009-11-16

Hey Greg,

I am new Jmaki and wanted to use accordion menu. I have two problems

1. I cannot use JSF and need to pass the json object to the widget. Is there any way to do that. Ours is a plain java project and cannot incorporate any other framework. This is the main reason for using jmaki

2. In the accordion menu if more groups and their sub groups are there will be able to rotate the list to show last one first

sloanb
Offline
Joined: 2003-09-14

First off don't ever feel bad for posting questions. That is what these forums are all about. We are here to learn from each other and make things better by doing so.

With the links you have set up, how are you wanting them to navigate? Are you wanting async calls to your managed beans to perform the logic and pass the navigation? If this is not the case can you explain exactly what the main goal of the links are and I will gladly help you out.

Regards,
--SB

lazarus___
Offline
Joined: 2008-08-26

Hi there Thanks for the help guys..
no i don t need of asynchronous calls for the menu for now i have the links i have posted how you can see when you click on them the function listSetup of every bean is called...
Now i wanna put this links in the accordion menu but i don t know how i have to write them..
You know when u select accordion in jmaki widgets u get that
[code]
value="{menu : [
{label: 'Links',
menu: [
{ label : 'Sun.com',
href : 'http://www.sun.com'},
{ label : 'jMaki.com',
href : 'http://www.jmaki.com'}
]
},
{label: 'Actions',
menu: [
{ label : 'Select',
action :{topic: '/foo/select',
message: { targetId : 'bar'}}
},
{ label :'Set Content',
action :{topic: '/foo/setContent',
message: { value : 'test.jsp'}}
}
]}
]
}" />

[/code]
now i would like to know how can i put inside this my links
I hope my problem is clear .f
Ah Yes i use netbeans plug in for jmaki it is great.
Thanks really much for ur help and for the time u are spending for me.

sloanb
Offline
Joined: 2003-09-14

The links are inside the model you pasted. For example:

[code]
{label : 'Links',
[/code]

This is the mapping to the menu header of an accordian. It will display links.

[code]
menu: [
{ label : 'Sun.com',
href : 'http://www.sun.com'},
{ label : 'jMaki.com',
href : 'http://www.jmaki.com'}
]
[/code]

This represents the links that you want to display in the "Links" menu in the accordian. If you want to put your links in you would add them as such:

[code]
menu: [
{ label : 'Show All Tariffarioazione Items',
href : 'yoururl.jsf'},
{ label : 'Show All Superuser Items',
href : 'showSuperUsers.jsf'}
]
[/code]

As you see I added some of your example links to the accordian menu. Does this help?

lazarus___
Offline
Joined: 2008-08-26

Hi Sloanb,
Well i knew that labels was the links u see in ur page my problem is that my links call a function of a manged bean now i will tell you better this thing
u see this link in my page:
Show All Tariffarioazione Items
this link has this code :
[code]

[/code]
How u can see when u click on this link the action tariffarioazione.listSetup is lunched.
tariffarioazione.listSetup is a function that has this code:
[code]
public String listSetup() {
reset(true);
return "tariffarioazione_list";
}
[/code]
It returns the tariffaazione_list String, in my faces-connfig.xml file there is this navigation mapping:
[code]


tariffarioazione_list
/tariffarioazione/List.jsp


[/code]
Now my question is how do i have to put my links in the accordion menu to have the same result i have now? and how can i modify the size and the color of the accordion menu?
this is my problem i have already tried to put my page directly in the accordion menu but nothing happens..
Thanks for your help you are the best really.
Laz

sloanb
Offline
Joined: 2003-09-14

You would use actions on each link element to call a listener in your glue. Please see the following thread as it should show you an example.

http://forums.java.net/jive/thread.jspa?messageID=301761&#301761

Regards,
--SB

lazarus___
Offline
Joined: 2008-08-26

Hi Sloanb

I tried to do as u said but i have a question i did in this way :
[code]

//welcome.jsp

value="{menu : [

{label: 'Actions',
menu: [

{ label :'Set Content',
action :{topic: '/foo/setContent',
message: { value : 'listSetup'}}
}
]}
]
}" />
// glue.js
jmaki.subscribe("/foo/setContent/onSelect", function(args){
var message;
if(args.value) message= args.value;
jmaki.doAjax({
methos:"POST",
url: jmaki.webRoot+"/faces/attivitaclienti-setContentAttivitaClientiList.ajax",
content:{cmq:'showAttivitaclientiLis', value: message}
});
});

// in the managedBean
public String setContentAttivitaClientiList(FacesContext context, AjaxResult result){
return listSetup();
}
[/code]
But it does not work...
plus i have a question, When you use jmaki framework you are out from the JSF framework..
So if i use the function, that normally return the string "attivitaclienti_list"
(this string is mapped in faces-config.xml), still works?
in other words if i call the function listSetup from an another function called from jmaki can i still get the same result i got calling the function listisetup in this way [code]

[/code]

Thanks another time for your help :p and sorry if i don't understand faster this stuff :p
Laz

sloanb
Offline
Joined: 2003-09-14

Looking at the code you posted lets check over the following:

* You are using attivitaclienti as your managed bean name is that how you have the bean mapped in the faces-config.xml?
* Have you debugged the glue.js to make sure that processing the subscription properly?

Your async call does not have a callback method which means you are not doing anything with the resulting managed bean call on your client side. You need to put a callback in your jmaki.doAjax function in order to work with the results. You will probably want to also include an onerror in this function to handle errors or at least to debug that its failing.

Have you debugged the server side to see if it actually calls the method?

lazarus___
Offline
Joined: 2008-08-26

Hi,
there is not a callback function in glue because i don t need of doing anything with the result.
I try to tell how actually my program works so i hope u can say how to do with jmaki to get the same result.

In the welcome page u have a list of links, i will show only one as example :
[code]

[/code]
when you click on it the function listSetup in the managed Bean TariffarioAzione is called.
This function is showed here :
[code]

public String listSetup() {
reset(true);
return "tariffarioazione_list";
}
[/code]

The string returned is mapped in my faces-config

[code]


tariffarioattivita_list
/tariffarioattivita/List.jsp


[/code]
so how you can see when you click on the link the function listSetup return the string tariffarioattivita_list that is mapped on the jsp page List.jsp.
My problem is i like a lot the jmaki accordion menu and i would like put my link in it leaving things working like now....
Is it possible?
when you use the ajax framework you are out from the jsf framework.. so still works the mapping there is in navigation rule?
how do i have to put my link in accordion menu?
Thanks
Laz

gmurray71
Offline
Joined: 2003-07-31

One option you might consider is having the links load different pages that contain jsf components like what you see at:

http://jmaki.com/jmaki/containers/

Basically the jmaki.accordionMenu drives another jMaki component called a dcontainer which contains content derived from loading different page fragments.

Another solution would be to use dynamic faces which is a JSF extension (and incorporated in JSF 2.0) to load different regions of a page using Ajax calls.

If either interest you sloan or I could provide you with further pointers to source.

-Greg

lazarus___
Offline
Joined: 2008-08-26

Hi, Sorry if I answer to you only now but i was working on another part of my project and only now i saw your post.
I accept your help gladly lol because i really don't know how i could make work jmaki with the standard jsf framework, You say to use dynamic faces but i already started to use jmaki in my project and i dont want to put too many frameworks inside.
I can give to you all code you need to see how my project actually works too see if we can resolve this situation...
Thanks for your help and sorry again if i have been so slowl answering

Laz

lazarus___
Offline
Joined: 2008-08-26

Hi, Sorry if I answer to you only now but i was working on another part of my project and only now i saw your post.
I accept your help gladly lol because i really don't know how i could make work jmaki with the standard jsf framework, You say to use dynamic faces but i already started to use jmaki in my project and i dont want to put too many frameworks inside.
I can give to you all code you need to see how my project actually works too see if we can resolve this situation...
Thanks for your help and sorry again if i have been so slowl answering

Laz

gmurray71
Offline
Joined: 2003-07-31

Hi Lazarus,

Dynamicfaces is not required (it's the future though). jMaki works fine with JSF 1.1+ and you can use a managed beans with jMaki.

Following is a Managed bean that will generate the JSON you need for a Menu. You can modify it to do you null checking.

Here is the bean:

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import jmaki.runtime.jsf.*;
import java.util.ArrayList;
import java.util.Iterator;

public class ApplicationBean {

ArrayList

menus;

public ApplicationBean() {
menus = new ArrayList

();
Menu menu = new Menu("Links");
menus.add(menu);
menu.items.add(new MenuItem("Google", "http://google.com"));
menu.items.add(new MenuItem("Ajaxian", "http://ajaxian.com"));
}

public String getMenu() {
StringBuffer result = new StringBuffer("{ \"menu\" : [");
Iterator

it = menus.iterator();
while (it.hasNext()){
Menu m = it.next();
result.append("{ \"label\": \"" + m.label + "\", \"menu\":[");
Iterator mit = m.items.iterator();
while(mit.hasNext()) {
MenuItem mi = mit.next();
result.append("{ \"label\": \"" + mi.label + "\", \"href\":\"" + mi.href + "\"}");
if (mit.hasNext()) result.append(",");
}
result.append("]}");
if (it.hasNext()) result.append(",");
}
result.append("]}");
return result.toString();
}

class Menu {

public String label;
public ArrayList items;

public Menu(String label) {
this.label = label;
items = new ArrayList();
}
}

class MenuItem {
public String label;
public String href;

public MenuItem(String label, String href) {
this.label = label;
this.href = href;
}
}
}

Now from you tag use:

Let me know how it goes.

-Greg

lazarus___
Offline
Joined: 2008-08-26

Hi gmurray, I was looking dynaic faces because you said it will be the future. it seem an easy tecnology for ajax and i would ask to u a thing. Could i use dynamic faces for ajax and jamky for grafic components?
could i use both thing in my project?
if i cant iwhat tecnology for u is better?
i think jmaki is really good and has a strong grafic components but i find alot of problem to integrate it in my jsf progect...
Dynamic faces is really easer but it has not grafic components....
what isyour opinion?
Thanks alot Laz

gmurray71
Offline
Joined: 2003-07-31

You can use dyanmic faces and jMaki together. We have members of the jMaki team that have gone through extra efforts to make sure that the integration works well.

For more on this see:

https://ajax.dev.java.net/usingFaces.html

and this really cool feature that only is provided with JSF version of jMaki:

https://ajax.dev.java.net/jmakieventlistenertag.html

The charting components should work out of the box without issue as well.

Regards,

-Greg

lazarus___
Offline
Joined: 2008-08-26

Hi Grag,
Yes i have recolved. I m using both.
Plus Dynamic Faces is really powerful, easy and really fast im very happy to use it.
I was looking documentation because i would like to implement a method that run when u open a page to check if there are in the db some actions near to go out of date...
I was thinking to implement it with the onload body event but my question is DynaFaces works with this event?
i dont understand what managed bean i have to call for this event because body is out of h:form.
In the documentation i have read about this option:

methodName |CLIENT_ID|,|METHOD_NAME|,[phaseId]
Is this the right option to use?
Thank you for your work and your help
Laz

dan862
Offline
Joined: 2009-11-16

Hey Greg,

I am new Jmaki and wanted to accordion menu. I have two problems

1. I cannot use JSF and need to pass the json object to the widget. Is there any way to do that. Ours is a plain java project and cannot incorporate any other framework. This is the main reason for using jmaki

2. In the accordion menu if more groups and their sub groups are there will be able to rotate the list to show last one first

adelukman
Offline
Joined: 2008-01-06

Hi Laz ,
First of all if i may ask do u have the JMAKI plugin install?
if so the JMAKI widget should be seen on ur palette if u want to build any JSF page.
To work with the accordion widget just go to the category where u have jmaki dojo dijit and select the accordion menu then drag the accordion menu into the page which immediately u should see statements declaring the widget.to configure the accordion menu place ur cursor in the statement that declared the widget and right click ,select jmaki option followed by the jmaki option again to display the properties . Alternatively after placing ur cursor on the statement that declared the widget find a JMAKI button exactly on top of the editor if u are using netbeans.

hope this helps