jsp & tag library. Eine Einführung  toc  prev  next


7

 nested tags

7.1 Kommunikation zwischen tags

<mt:switch value="dark">
    <mt:case value="light">
       <P>This is light.</P>
    </mt:case>
    <mt:case value="Dark">
       <P>This is Dark.</P>
    </mt:case>
    <mt:case value="dark">
       <P>This is dark.</P>
    </mt:case>
</mt:switch>

Bei verschachtelten tags kann der innere (case) auf Werte des äußeren zugreifen durch z.B.

public int doStartTag() throws JspTagException {
    // Get the outer tag
    SwitchTag parent =
         (SwitchTag) findAncestorWithClass(this,SwitchTag.class);

    if(parent==null) {
        throw new JspTagException("Case Tag without Switch Tag");
    }

    try {
        if(parent.getValue("value").equals(getValue("value")))
        ...

jsp & tag library. Eine Einführung  toc  prev  next                         [ back to  a P a g e ]