Display a widget as a hyperlink

While this example displays a label as a hyperlink, you can use this example as a template for making other types of widgets appear as hyperlinks.

In this example, we create a snippet file that displays the lable as a hyperlink.

  1. Create the snippet file that displays a label as a hyperlink. For this example, we name the file LabelURL.xhtml.
    <?xml version="1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns:gwc="http://www.4js.com/GWC">
    <!-- the head element is ignored -->
    <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Label snippet</title>
    </head>
    <body>
    <!-- the template snippet is the content of the gwc:snippet-root element -->
     <gwc:snippet-root>
      <a gwc:content="value" gwc:attributes="href value"/>
     </gwc:snippet-root>
    </body>
    </html>
  2. In the application configuration file, add a SNIPPET element that specifies to use the newly-created snippet file (LabelURL.xhtml) when the form displays a label whose style property is "LabelUrl".
    <APPLICATION Parent="defaultgwc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="http://www.4js.com/ns/gas/2.50/cfextwa.xsd">
     <EXECUTION>
      <PATH>$(res.path.demo.app)/howto/labelUrl/src/4gl</PATH>
     </EXECUTION>
     <OUTPUT>
      <MAP Id="DUA_HTML5">
       <THEME>
        <SNIPPET Id="Label" Style="LabelUrl">
         $$(res.path.demo.app)/howto/labelUrl/web/labelURL.xhtml</SNIPPET>
       </THEME>
      </MAP>
     </OUTPUT> 
    </APPLICATION>
  3. For each label you want to appear as a URL, set the style property to "LabelUrl" (as shown in this .PER file):
    LAYOUT 
    GRID g1
    {
    Enter a URL in the field below and click on change action 
    to make the URL appear as a link
    [edt10 ]
    [lbl01 ]
    }
    END 
    END 
    
    ATTRIBUTES 
    EDIT edt10=formonly.edt10, SCROLL; 
    LABEL lbl01=formonly.lbl01, STYLE="LabelUrl"; 
    END
    To run and test this example, you can use this sample Genero code.
    MAIN 
      DEFINE edt10 STRING 
      LET edt10 = "http://www.google.com"
    
      CLOSE WINDOW SCREEN 
      OPEN WINDOW w WITH FORM "sample" 
    
      INPUT BY NAME edt10 WITHOUT DEFAULTS ATTRIBUTES(UNBUFFERED)
        ON ACTION change
          DISPLAY edt10 TO lbl01
      END INPUT 
    
      CLOSE WINDOW w 
    END MAIN