cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robby.pelss...@vodafone.com
Subject RE: calling methods in xsp
Date Tue, 24 Aug 2004 13:07:00 GMT
I guess it is possible :-)
 
 
<xsp:page 
  language="java" 
  xmlns:xsp=" http://apache.org/xsp <http://apache.org/xsp> "
  xmlns:xen=" http://www.osirion.nl/xenophon/xenophon/1.0
<http://www.osirion.nl/xenophon/xenophon/1.0> ">
 
  <xsp:structure>
    <xsp:include>java.text.*</xsp:include>
    <xsp:include>java.util.*</xsp:include>
    <xsp:include>java.util.Locale</xsp:include>
    <xsp:include>org.apache.cocoon.environment.Session</xsp:include>
    <xsp:include>org.apache.cocoon.environment.Request</xsp:include>
 
 
<xsp:include>com.vodafone.xenopsis.accessnetwork.AccessRoute</xsp:include>
 
<xsp:include>com.vodafone.xenopsis.accessnetwork.AccessRouteConnection</xsp:
include>
 
<xsp:include>com.vodafone.xenopsis.accessnetwork.AccessRouteNode</xsp:includ
e>
 
<xsp:include>com.vodafone.xenopsis.accessnetwork.AccessRouteSwitch</xsp:incl
ude>
 
<xsp:include>com.vodafone.xenopsis.accessnetwork.AccessRouteSite</xsp:includ
e>
    <xsp:include>com.vodafone.xenopsis.corenetwork.Link</xsp:include>
    <xsp:include>com.vodafone.xenopsis.corenetwork.Port</xsp:include>
  </xsp:structure>
 
  <accessroute>
    <xsp:logic>
 
      try {
          String id = (String)request.getParameter("Id");
          ar = new AccessRoute(id);    
         
          <id><xsp:expr>ar.getId()</xsp:expr></id>
          <status><xsp:expr>ar.getStatus()</xsp:expr></status>
          <xsp:logic>
            AccessRouteConnection start =
(AccessRouteConnection)ar.getConnections().core.getFirst();
            doFirstNode(start.getAEnd(), xspAttr);
 
            count = 0;
            for (Iterator i =
ar.getConnections().core.iterator();i.hasNext();){
                count = count + 1;
                AccessRouteConnection  arc =
(AccessRouteConnection)i.next();
                if (!arc.getLink().core.isValid()){
                   doCoax(arc.getLink(), xspAttr);
                }
                if (arc.getLink().core.isValid()){
                    if (arc.getLink().getType().equalsIgnoreCase("ISW")){
                        doInterSwitch(arc.getLink(), xspAttr);
                    }
                    if (arc.getLink().getType().equalsIgnoreCase("ACCESS")){

                        doLandLine(arc.getLink(), xspAttr);
                    } 
                    if (arc.getLink().getType().equalsIgnoreCase("Access
Link")){
                        if (arc.getLink().getTechnology().startsWith("Lease
line")){ 
                            doLandLine(arc.getLink(), xspAttr);
                        } 
                        else if
(arc.getLink().getTechnology().equalsIgnoreCase("Ring")){ 
                            doRing(arc.getLink(), xspAttr);
                        } 
                        else{
                            doRadioLink(arc.getLink(), xspAttr);
                        }
                    }    
                }
                doNode(arc.getBEnd(), xspAttr);
            }
            count = count * 2  + 1;
 

            if (count * 80 &gt; 800) {
                division = (800 / (count * 80));
            }
            else {
              division = 1.0;
            }
            Locale myLocale = new Locale("en","US");
            MessageFormat mf = new
MessageFormat("{0,number,#.##}",myLocale); 
            Object[] objs = {new Double(division)};
            scale = mf.format( objs );
            <count><xsp:expr>count</xsp:expr></count>
            
            if (count * 80 &gt; 800) {
                <scaling><xsp:expr>scale</xsp:expr></scaling>
            }
            else {  
                <scaling>1.0</scaling>
            }
         
          </xsp:logic>
      } 
      catch(Exception ex){
      }
 
    </xsp:logic>
  </accessroute>
 
  <xsp:logic>
    private void doFirstNode(AccessRouteNode arn, AttributesImpl xspAttr)
throws Exception {
 
      if(arn.getIsSite()) {
        doSiteOnSwitch(arn.getAccessRouteSite(), xspAttr);       
      } 
      else if(arn.getIsSwitch()) {
          if (arn.getAccessRouteSwitch().getHasDxxCluster()) {
            <node type="firstnode" hasDxxCluster="true" position="1">
 
<name><xsp:expr>arn.getAccessRouteSwitch().getSwitch().getName()</xsp:expr><
/name>
 
<description><xsp:expr>arn.getAccessRouteSwitch().getSwitch().getDescription
()</xsp:expr></description>
 
<url><xen:page-url>"/application/portal/corenetwork/switch.html?Id=" +
<xsp:expr>arn.getAccessRouteSwitch().getSwitch().getId()
</xsp:expr></xen:page-url></url>
              <bsc>
                <name> <xsp:expr>ar.getRblt().getElement().getName()
</xsp:expr> </name>
                <description>
<xsp:expr>ar.getRblt().getElement().getDescription() </xsp:expr>
</description>
                <url> <xen:page-url>
"/application/portal/corenetwork/networkelement.html?Id=" +
<xsp:expr>ar.getRblt().getElement().getId() </xsp:expr> </xen:page-url>
</url> 
              </bsc>
              <bscport>
                <name> <xsp:expr>ar.getRblt().getName() </xsp:expr> </name>
                <url> <xen:page-url>
"/application/portal/corenetwork/port.html?Id=" +
<xsp:expr>ar.getRblt().getId() </xsp:expr> </xen:page-url> </url>
              </bscport> 
              <ddfposition>
                <name> <xsp:expr>ar.getRblt().getDdfPosition().getName()
</xsp:expr> </name>
                <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>ar.getRblt().getDdfPosition().getId() </xsp:expr> </xen:page-url>
</url> 
              </ddfposition>
              <networkelement type="DXX-CL">
                <name>
<xsp:expr>ar.getDxxClusterPortIn().getElement().getName()</xsp:expr> </name>
                <description>
<xsp:expr>ar.getDxxClusterPortIn().getElement().getDescription()</xsp:expr>
</description>
                <url> <xen:page-url>
"/application/portal/corenetwork/networkelement.html?Id=" +
<xsp:expr>ar.getDxxClusterPortIn().getElement().getName()</xsp:expr>
</xen:page-url> </url>
                <portin>   
                  <name>
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortIn().getName()
</xsp:expr> </name>
                  <url> <xen:page-url>
"/application/portal/corenetwork/port.html?Id=" +
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortIn().getId()
</xsp:expr> </xen:page-url> </url> 
                  <ddfposition> 
                    <name>
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortIn().getDdfPosition().
getName() </xsp:expr> </name>
                    <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortIn().getDdfPosition().
getId() </xsp:expr> </xen:page-url> </url>
                  </ddfposition> 
                </portin> 
                <portout>   
                  <name>
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortOut().getName()
</xsp:expr> </name>
                  <url> <xen:page-url>
"/application/portal/corenetwork/port.html?Id=" +
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortOut().getId()
</xsp:expr> </xen:page-url> </url> 
                  <ddfposition> 
                    <name> <xsp:expr>
arn.getAccessRouteSwitch().getDxxClusterPortOut().getDdfPosition().getName()
</xsp:expr> </name>
                    <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>arn.getAccessRouteSwitch().getDxxClusterPortOut().getDdfPosition()
.getId() </xsp:expr> </xen:page-url> </url>
                  </ddfposition> 
                </portout> 
              </networkelement>
            </node>  
          } 
          else {
            <node type="firstnode" hasDxxCluster="false" position="1">
 
<name><xsp:expr>arn.getAccessRouteSwitch().getSwitch().getName()</xsp:expr><
/name>
 
<description><xsp:expr>arn.getAccessRouteSwitch().getSwitch().getDescription
()</xsp:expr></description>
              <url><xen:page-url>
"/application/portal/corenetwork/switch.html?Id=" +
<xsp:expr>arn.getAccessRouteSwitch().getSwitch().getId()
</xsp:expr></xen:page-url></url>
              <bsc>
                <name> <xsp:expr>ar.getRblt().getElement().getName()
</xsp:expr> </name>
                <description>
<xsp:expr>ar.getRblt().getElement().getDescription() </xsp:expr>
</description>
                <url> <xen:page-url>
"/application/portal/corenetwork/networkelement.html?Id=" +
<xsp:expr>ar.getRblt().getElement().getId() </xsp:expr> </xen:page-url>
</url> 
              </bsc>
              <bscport>
                <name> <xsp:expr>ar.getRblt().getName() </xsp:expr> </name>
                <url> <xen:page-url>
"/application/portal/corenetwork/port.html?Id=" +
<xsp:expr>ar.getRblt().getId() </xsp:expr> </xen:page-url> </url>
              </bscport> 
              <ddfposition>
                <name> <xsp:expr>ar.getRblt().getDdfPosition().getName()
</xsp:expr> </name>
                <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>ar.getRblt().getDdfPosition().getId() </xsp:expr> </xen:page-url>
</url> 
              </ddfposition>
            </node> 
          }
      }
    }  
     
    private void doSwitch(AccessRouteSwitch ars, AttributesImpl xspAttr)
throws Exception {
      if (ars.getHasDxxCluster()) {
        <node type="switch" hasDxxCluster="true">
          <name><xsp:expr>ars.getSwitch().getName()</xsp:expr></name>
 
<description><xsp:expr>ars.getSwitch().getDescription()</xsp:expr></descript
ion>
          <url> <xen:page-url>
"/application/portal/corenetwork/switch.html?Id=" +
<xsp:expr>ars.getSwitch().getId() </xsp:expr> </xen:page-url> </url>
          <networkelement type="DXX-CL">
            <name>
<xsp:expr>ar.getDxxClusterPortIn().getElement().getName()</xsp:expr> </name>
                <description>
<xsp:expr>ar.getDxxClusterPortIn().getElement().getDescription()</xsp:expr>
</description>
                <url> <xen:page-url>
"/application/portal/corenetwork/networkelement.html?Id=" +
<xsp:expr>ar.getDxxClusterPortIn().getElement().getName()</xsp:expr>
</xen:page-url> </url>
            <portin>   
              <name> <xsp:expr>ars.getDxxClusterPortIn().getName()
</xsp:expr> </name>
              <url> <xen:page-url>
"/application/portal/corenetwork/port.html?Id=" +
<xsp:expr>ars.getDxxClusterPortIn().getId() </xsp:expr> </xen:page-url>
</url> 
              <ddfposition> 
                <name> <xsp:expr>
ars.getDxxClusterPortIn().getDdfPosition().getName() </xsp:expr> </name>
                <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>ars.getDxxClusterPortIn().getDdfPosition().getId() </xsp:expr>
</xen:page-url> </url>
              </ddfposition> 
            </portin> 
            <portout>   
              <name> <xsp:expr>ars.getDxxClusterPortOut().getName()
</xsp:expr> </name>
              <url> <xen:page-url>
"/application/portal/corenetwork/port.html?Id=" +
<xsp:expr>ars.getDxxClusterPortOut().getId() </xsp:expr> </xen:page-url>
</url> 
              <ddfposition> 
                <name> <xsp:expr>
ars.getDxxClusterPortOut().getDdfPosition().getName() </xsp:expr> </name>
                <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>ars.getDxxClusterPortOut().getDdfPosition().getId() </xsp:expr>
</xen:page-url> </url>
              </ddfposition> 
            </portout> 
          </networkelement>
        </node>
      } 
        else if (!ars.getHasDxxCluster()) {
          <node type="switch" hasDxxCluster="false">
            <name><xsp:expr>ars.getSwitch().getName()</xsp:expr></name>
 
<description><xsp:expr>ars.getSwitch().getDescription()</xsp:expr></descript
ion>
            <url> <xen:page-url>
"/application/portal/corenetwork/switch.html?Id=" +
<xsp:expr>ars.getSwitch().getId() </xsp:expr> </xen:page-url> </url>
          </node>    
        } 
    }
   
    private void doRadioLink(Link link, AttributesImpl xspAttr) throws
Exception {
      <link type="microwave">
        <name> <xsp:expr>link.getName()</xsp:expr> </name>
        <radiolinkchannel> <xsp:expr>link.getRadioLinkChannel()</xsp:expr>
</radiolinkchannel>
        <url> <xen:page-url>
"/application/portal/accessnetwork/link.html?Name=" + <xsp:expr>
link.getName() </xsp:expr> </xen:page-url> </url>
        <ddf1>
          <name> <xsp:expr>link.getDdfPosition1().getName()</xsp:expr>
</name>
          <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>link.getDdfPosition1().getId()</xsp:expr> </xen:page-url></url>
 
        </ddf1> 
      </link>
    }
 
    private void doRing(Link link, AttributesImpl xspAttr) throws Exception
{
      <link type="ring">
        <name> <xsp:expr>link.getName()</xsp:expr> </name>
        <radiolinkchannel> <xsp:expr>link.getRadioLinkChannel()</xsp:expr>
</radiolinkchannel>
        <url> <xen:page-url>
"/application/portal/accessnetwork/link.html?Name=" + <xsp:expr>
link.getName() </xsp:expr> </xen:page-url> </url>
        <ddf1>
          <name> <xsp:expr>link.getDdfPosition1().getName()</xsp:expr>
</name>
          <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>link.getDdfPosition1().getId()</xsp:expr> </xen:page-url></url>
 
        </ddf1> 
      </link>
    }
    
    private void doLandLine(Link link, AttributesImpl xspAttr) throws
Exception {
      <link type="landline">
        <name> <xsp:expr>link.getName()</xsp:expr> </name>
        <url> <xen:page-url>
"/application/portal/accessnetwork/link.html?Name=" + <xsp:expr>
link.getName() </xsp:expr> </xen:page-url> </url>
        <ddf1>
          <name> <xsp:expr>link.getDdfPosition1().getName()</xsp:expr>
</name>
          <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>link.getDdfPosition1().getId()</xsp:expr> </xen:page-url></url>
 
        </ddf1>
      </link>
    }
    private void doCoax(Link link, AttributesImpl xspAttr) throws Exception
{
      <link type="coax">
        <name>Coax</name>
        <ddf1>
          <name><xsp:expr>link.getDdfPosition1().getName()</xsp:expr></name>
          <url><xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>link.getDdfPosition1().getId()</xsp:expr> </xen:page-url></url>
 
        </ddf1>
      </link>
    }
 
   private void doInterSwitch(Link link, AttributesImpl xspAttr) throws
Exception {
      <link type="isw">
        <name> <xsp:expr>link.getName()</xsp:expr> </name>
        <url> <xen:page-url>
"/application/portal/accessnetwork/link.html?Name=" + <xsp:expr>
link.getName() </xsp:expr> </xen:page-url> </url>
        <ddf1>
          <name> <xsp:expr>link.getDdfPosition1().getName()</xsp:expr>
</name>
          <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>link.getDdfPosition1().getId()</xsp:expr> </xen:page-url></url>
 
        </ddf1>
        <ddf2>
          <name> <xsp:expr>link.getDdfPosition2().getName()</xsp:expr>
</name>
          <url> <xen:page-url>
"/application/portal/corenetwork/ddfposition.html?Id=" +
<xsp:expr>link.getDdfPosition2().getId()</xsp:expr> </xen:page-url></url>
        </ddf2>
      </link>
    } 
 
   private void doNode(AccessRouteNode arn, AttributesImpl xspAttr) throws
Exception {
     if(arn.getIsSite()) {
         if(arn.getAccessRouteSite().getSite().getIsSwitchLocation()){
             doSiteOnSwitch(arn.getAccessRouteSite(), xspAttr);
         }
         if(!arn.getAccessRouteSite().getSite().getIsSwitchLocation()){
             doSite(arn.getAccessRouteSite(), xspAttr);
         }
              
     } else if(arn.getIsSwitch()) {
         doSwitch(arn.getAccessRouteSwitch(), xspAttr);
     }
   }  
   
   private void doSite(AccessRouteSite ars, AttributesImpl xspAttr) throws
Exception {
     <node type="site">
       <name> <xsp:expr>ars.getSite().getId() </xsp:expr> </name>
       <description> <xsp:expr>ars.getSite().getNameNice()</xsp:expr>
</description>
       <url><xen:page-url>"/application/portal/accessnetwork/site.html?Id="
+ <xsp:expr>ars.getSite().getId()</xsp:expr></xen:page-url></url>
     </node>
   }
 
   private void doSiteOnSwitch(AccessRouteSite ars, AttributesImpl xspAttr)
throws Exception {
     <node type="siteonswitch">
       <name> <xsp:expr>ars.getSite().getId() </xsp:expr> </name>
       <description> <xsp:expr>ars.getSite().getNameNice()</xsp:expr>
</description>
       <url> <xen:page-url>
"/application/portal/accessnetwork/site.html?Id=" +
<xsp:expr>ars.getSite().getId() </xsp:expr> </xen:page-url> </url>
     </node>
   }
 
  
   private AccessRoute ar;
   private double count;
   private double division;
   private String scale;
 
  </xsp:logic>
</xsp:page>

-----Original Message-----
From: Jones A [mailto:jones_a@sify.com]
Sent: 24 August, 2004 07:17
To: users@cocoon.apache.org
Subject: calling methods in xsp


is it possible to call another method frm a method in XSP?

Should the methoda be inside the same <xsp:logic> tag?

like 

<xsp:logic>



 public void method1()

   {

     method2(int,int);

     .................

     .................

     ................. 



   }



</xsp:logic>



<xsp:logic>

  public void method2(int ,int)

    {

       

     }

</xsp:logic>
 
<http://ads.sify.com/RealMedia/ads/click_nx.ads/mail.sify.com/sentmail@Botto
m>  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message