• 第五十三章 开发自定义标签 - Using csr %cspQuote Methods


    第五十三章 开发自定义标签 - Using csr %cspQuote Methods

    Using csr %cspQuote Methods

    %cspQuote例程定义包含两个不同引用方法的定义。

    • Quote

    • QuoteCSP

    Quote Method

    $$Quote^%cspQuote(line As %String)
    
    • 1

    用引号将输入字符串括起来。

    QuoteCSP Method

    $$QuoteCSP^%cspQuote(line As %String)
    
    • 1

    用引号将输入字符串括起来,并解析#()###()###''##server#url调用。

    创建标记以显示表格

    本节包含一个名为GridExample的规则示例,它创建了两个标记,这两个标记在CSP页面上创建了一个信息表。

    • tag

    • tag

    Grid Rule Definition

    <csr:rule name="GridExample" match="GRID">
    <csr:action>
    <script language =Cache runat=compiler>
        Set maxrows=##this.GetAttribute("COLS")
        Set maxcols=##this.GetAttribute("ROWS")
        Do ..WriteText("",1)SetGRIDDATA="";GetGridDataSet count=##this.Children.Count()For i=1:1:count {Set el=##this.Children.GetAt(i)Set tagname=el.TagNameIf tagname="GRIDDATA"{Set value=el.GetAttribute("VALUE")Set col=el.GetAttribute("COL")Set row=el.GetAttribute("ROW")SetGRIDDATA(row,col)=value
             }};WriteGridElementsFor row=1:1:maxrows {Do..WriteText("",1)For col=1:1:maxcols {Set d=$G(GRIDDATA(row,col))Do..WriteCSPText("",1)}}Do..WriteText("",1)Do..WriteText("
    "_d_"
    "
    ,1) </SCRIPT> </csr:action> </csr:rule>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    虽然属性在的规则定义中被处理,但仍然需要一个空规则来实例化标记:

    
    
    This purpose of this empty rule is to instantiate the GRIDDATA tag
    into the Document Object Model.
    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    Generated Grid Class

    上述规则定义编译成以下两个类:

    • Grid
    • GridData
    Import User
    
    Class csr.csp.GridExample Extends %CSP.Rule
    {
    
    Parameter CSRURL = "/csp/user/GRIDEXAMPLE.CSR";
    
    Method CompilerMethod1() [ Language = cache ]
    {
         Set maxrows=##this.GetAttribute("COLS")
         Set maxcols=##this.GetAttribute("ROWS")
         Do ..WriteText("",1)SetGRIDDATA="";GetGridDataSet count=##this.Children.Count()For i=1:1:count {Set el=##this.Children.GetAt(i)Set tagname=el.TagNameIf tagname="GRIDDATA"{Set value=el.GetAttribute("VALUE")Set col=el.GetAttribute("COL")Set row=el.GetAttribute("ROW")SetGRIDDATA(row,col)=value
             }};WriteGridElementsFor row=1:1:maxrows {Do..WriteText("",1)For col=1:1:maxcols {Set d=$G(GRIDDATA(row,col))Do..WriteCSPText("",1)}}Do..WriteText("",1)Do..WriteText("
    "_d_"
    "
    ,1) } Method RenderStartTag() As %Status { New element Set element=##this Set %statuscode=$$$OK Do ..CompilerMethod1() Quit:$$$ISERR(%statuscode) %statuscode Quit $$$SKIPCHILDREN } }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46

    GridData Class

    Import User
    
    Class csr.csp.GridDataExample Extends %CSP.Rule
    {
    
    Parameter CSRURL = "/csp/user/GRIDEXAMPLE.CSR";
    
    Method RenderEndTag() As %Status
    {
     New element Set element=##this
     Do ..RenderDefaultEndTag()
     Quit $$$OK
    }
    
    Method RenderStartTag() As %Status
    {
     New element Set element=##this
     Do ..RenderDefaultStartTag()
     Quit $$$PROCESSCHILDREN
    }
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    Using the Grid Rule

    网格规则现在可以用在CSP页面的正文中:

    <html>
    <head>
    <title>Grid Example</title>
    </head>
    <body>
    <grid cols="5" rows="5">
    <griddata value="Cell-1-1" col="1" row="1">
    </griddata>
    <griddata value="Cell-2-1" col="2" row="1">
    </griddata>
    <griddata value="Cell-2-2" col="2" row="2">
    </griddata>
    <griddata value="Cell-2-3" col="2" row="3">
    </griddata>
    <griddata value="Cell-2-4" col="2" row="4">
    </griddata>
    <griddata value="Cell-2-5" col="2" row="5">
    </griddata>
    <griddata value="Cell-3-1" col="3" row="1">
    </griddata>
    <griddata value="Cell-4-1" col="4" row="1">
    </griddata>
    <griddata value="Cell-4-3" col="4" row="3">
    </griddata>
    <griddata value="Cell-5-1" col="5" row="1">
    </griddata>
    <griddata value="Cell-5-5" col="5" row="5">
    </griddata>
    </grid>
    </body>
    </html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    Grid Rule Displayed Page

    CSP页面现在显示以下内容:

      Cell-1-1 Cell-2-1 Cell-3-1 Cell-4-1 Cell-5-1
               Cell-2-2
               Cell-2-3          Cell-4-3
               Cell-2-4
               Cell-2-5                   Cell-5-5
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    编译一个基于debian/ubuntu,centos,arhlinux第三方系统
    【CAN】CAN基础概念1
    自然语言处理 Paddle NLP - 结构化数据问答-理论
    信息系统项目管理师---第七章 项目成本管理
    python编程复习系列——week3决策声明(if-else)
    数字化转型的关键在于节省时间
    react实现时钟翻牌效果
    信驰达RF-DG-52PAS CC2652P Zigbee 3.0 USB Dongle烧录指南
    Spring Aop 入门与理解
    【OpenCV】图像上绘制文字cv2.putText()函数用法,添加倾斜透明水印
  • 原文地址:https://blog.csdn.net/yaoxin521123/article/details/127957157