OW2 Consortium telosys

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13 lguerin 1
package org.objectweb.telosys.uil.taglib.widget.html;
2
 
3
import org.objectweb.telosys.uil.taglib.TagCommons;
4
import org.objectweb.telosys.uil.taglib.widget.GenericTag;
5
import org.objectweb.telosys.uil.taglib.widget.data.MenuItem;
6
 
7
/**
8
 * Commons for menu HTML generation
9
 *
10
 * @author Laurent GUERIN
11
 *
12
 */
13
public class MenuCommonsHTML
14
{
15
    //----------------------------------------------------------------
16
    static protected String getOnclick( GenericTag tag, MenuItem item)
17
    {
18
        if ( ! item.isSubMenu() ) // Is not a submenu ( do not point to a MenuBox )
19
        {
20
	        if ( item.getOnclick() != null ) // JavaScript action
21
	        {
22
		        String s = item.getOnclick().trim() ;
23
	            if ( s.length() > 0 )
24
	            {
25
	                return s + ";fwkAfterMenuItemClick(event)" ;
26
	            }
27
	        }
28
	        if ( item.getHref() != null ) // External HREF link
29
	        {
30
		        String s = item.getHref().trim() ;
31
	            if ( s.length() > 0 )
32
	            {
33
	                return "fwkMenuLink('" + s + "');" ;
34
	            }
35
	        }
36
	        if ( item.getCres() != null ) // Context Resource link
37
	        {
38
		        String s = item.getCres().trim() ;
39
	            if ( s.length() > 0 )
40
	            {
41
	                return "fwkMenuLink('" + tag.getResourceURL(s)  + "');" ;
42
	            }
43
	        }
44
	        if ( item.getScreen() != null ) // ScreenMap link
45
	        {
46
		        String sScreenName = item.getScreen().trim() ;
47
	            if ( sScreenName.length() > 0 )
48
	            {
49
	                String s = TagCommons.getScreenMapURL(tag.getPageContext());
50
	                s = s + "?name=" + sScreenName ;
51
	                return "fwkMenuLink('" + s + "');" ;
52
	            }
53
	        }
54
        }
55
        return "fwkCancelEvent(event)" ;
56
    }
57
}