org.olat.core.gui.components.link
Class LinkFactory

java.lang.Object
  extended by org.olat.core.gui.components.link.LinkFactory

public class LinkFactory
extends java.lang.Object

Description:
offer convenience methods to create and add buttons/links to Velocity Containers quick and easy Typical usage (see also GuiDemoLinksController.java):

  1. instantiate your VelocityContrainter
    mainVC = createVelocityContainer("guidemo-links");
  2. create your button
    button = LinkFactory.createButton("button", mainVC, this);
  3. save it as instance variable, that the controller can listeningController catch its events
  4. add to your velocity page, that shows up the button $r.render("button")
  5. and finally listen to the events the button fired in the listeningController.event(UserRequest ureq, Component source, Event event)
    public void event(UserRequest ureq, Component source, Event event) { if (source == button){ // do something } }
Initial Date: August 10, 2006

Author:
Alexander Schneider

Constructor Summary
LinkFactory()
           
 
Method Summary
static Link createButton(java.lang.String name, VelocityContainer vc, Controller listeningController)
          add a button to the vc Velocity Container and make the listeningController listen to this button.
static Link createButtonSmall(java.lang.String name, VelocityContainer vc, Controller listeningController)
          add a small button to the vc Velocity Container and make the listeningController listen to this small button.
static Link createButtonXSmall(java.lang.String name, VelocityContainer vc, Controller listeningController)
          add a xsmall button to the vc Velocity Container and make the listeningController listen to this xsmall button.
static Link createCustomLink(java.lang.String name, java.lang.String cmd, java.lang.String key, int presentation, VelocityContainer vc, Controller listeningController)
          add a customized link to the vc Velocity Container and make the listeningController listen to this link.
static Link createIconClose(java.lang.String title, VelocityContainer vc, Controller listeningController)
          add a close icon to the vc Velocity Container and make the listeningController listen to the user's click on the close icon.
static Link createLink(java.lang.String name, VelocityContainer vc, Controller listeningController)
          add a link to the vc Velocity Container and make the listeningController listen to this link.
static Link createLinkBack(VelocityContainer vc, Controller listeningController)
          add a back link to the vc Velocity Container and make the listeningController listen to this back link.
static Link deAjaxify(Link link)
           
static Link markDownloadLink(Link link)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkFactory

public LinkFactory()
Method Detail

createLinkBack

public static Link createLinkBack(VelocityContainer vc,
                                  Controller listeningController)
add a back link to the vc Velocity Container and make the listeningController listen to this back link.

Follow these instructions to show the back link and catch its events:

  1. $r.render("backLink") in your velocity page, that the link shows up.
  2. save the returned link as a instance variable myBackLink
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the back link by
    if(source == myBackLink){..your stuff here..}

Parameters:
vc - the VelocityContainer within you put this link
listeningController -
Returns:
the link component

createIconClose

public static Link createIconClose(java.lang.String title,
                                   VelocityContainer vc,
                                   Controller listeningController)
add a close icon to the vc Velocity Container and make the listeningController listen to the user's click on the close icon.

Follow these instructions to show the close icon and catch its events:

  1. $r.render("closeIcon") in your velocity page, that the link shows up.
  2. save the returned link as a instance variable myCloseIcon
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the close icon by
    if(source == close icon){..your stuff here..}

Parameters:
title - - displayed on hovering over the icon - can be null, then no title is displayed
vc -
listeningController -
Returns:
Link which display just the close icon

createLink

public static Link createLink(java.lang.String name,
                              VelocityContainer vc,
                              Controller listeningController)
add a link to the vc Velocity Container and make the listeningController listen to this link.

Follow these instructions to show the link and catch its events:

  1. $r.render("myLink") in your velocity page, that the link shows up.
  2. save the returned link as a instance variable myLink
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the back link by
    if(source == myLink){..your stuff here..}

Parameters:
one - string for name of component, command and i18n key
vc - the VelocityContainer within you put this link
listeningController -
Returns:
the link component

createCustomLink

public static Link createCustomLink(java.lang.String name,
                                    java.lang.String cmd,
                                    java.lang.String key,
                                    int presentation,
                                    VelocityContainer vc,
                                    Controller listeningController)
add a customized link to the vc Velocity Container and make the listeningController listen to this link. A customized link means that you can configure everything by yourself using the constants of the link component e.g. Link.NONTRANSLATED

Follow these instructions to show the customized link and catch its events:

  1. $r.render("myCustomizedLink") in your velocity page, that the link shows up.
  2. save the returned link as a instance variable myCustomizedLink
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the back link by
    if(source == myLink){..your stuff here..}

Parameters:
name - of the link component
cmd - command, null or empty string are not allowed
key - if it's already translated, use at the next parameter Link.NONTRANSLATED, null is allowed
presentation -
vc - the VelocityContainer within you put this link
listeningController -
Returns:
the link component

createButton

public static Link createButton(java.lang.String name,
                                VelocityContainer vc,
                                Controller listeningController)
add a button to the vc Velocity Container and make the listeningController listen to this button.

Follow these instructions to show the button and catch its events:

  1. $r.render("myButton") in your velocity page, that the button shows up.
  2. save the returned link as a instance variable myButton
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the button by
    if(source == myButton){..your stuff here..}

Parameters:
one - string for name of component, command and i18n key
vc - the VelocityContainer within you put this link
listeningController -
Returns:
the link component

createButtonSmall

public static Link createButtonSmall(java.lang.String name,
                                     VelocityContainer vc,
                                     Controller listeningController)
add a small button to the vc Velocity Container and make the listeningController listen to this small button.

Follow these instructions to show the small button and catch its events:

  1. $r.render("mySmallButton") in your velocity page, that the small button shows up.
  2. save the returned link as a instance variable mySmallButton
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the small button by
    if(source == mySmallButton){..your stuff here..}

Parameters:
one - string for name of component, command and i18n key
vc - the VelocityContainer within you put this link
listeningController -
Returns:
the link component

createButtonXSmall

public static Link createButtonXSmall(java.lang.String name,
                                      VelocityContainer vc,
                                      Controller listeningController)
add a xsmall button to the vc Velocity Container and make the listeningController listen to this xsmall button.

Follow these instructions to show the xsmall button and catch its events:

  1. $r.render("myXSmallButton") in your velocity page, that the xsmall button shows up.
  2. save the returned link as a instance variable myXSmallButton
  3. in the listeningController.event(UserRequest ureq, Component source, Event event) you catch the xsmall button by
    if(source == myXSmallButton){..your stuff here..}

Parameters:
one - string for name of component, command and i18n key
vc - the VelocityContainer within you put this link
listeningController -
Returns:
the link component

deAjaxify

public static Link deAjaxify(Link link)
Parameters:
link - the Link to be deajaxified
Returns:
the given Link changed so that it renders its url always in standard mode even if ajax-mode is on

markDownloadLink

public static Link markDownloadLink(Link link)