#1 2017-05-30 13:29:59

Guilherme
Member
Registered: 2017-01-09

Show a dadget by url

Hi Guys,
Is there any way to get a Static Html Dadget through the id and just show it through a url?

Last edited by Guilherme (2017-05-30 14:33:40)

Offline

#2 2017-05-30 15:02:23

Rodion
Member
Registered: 2017-05-17

Re: Show a dadget by url

Hello Guilherme,

Reportserver doesnt provide a url for the dadgets. Dadgets are bound with a Dashboard, and Dashboards with a Container, which the user-Object contains.
So, unfortunately, you cant open separate dadgets in separate windows.
Sure you can run multiple instances of reportserver on different windows. Maybe it putts off a bit.

Best regards,
Rodion

Offline

#3 2017-05-31 07:28:46

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Show a dadget by url

Hi Guilherme,

this is correct: reportserver doesn't provide urls for dadgets. but we are thinking on the possibility of indirectly calling a html dadget per script, which would be callable per url.
We will update here with more information, stay tuned.

It would also be interesting to know why do you need this, what are you trying to achieve ?

Cheers,
Eduardo

Offline

#4 2017-06-03 16:57:18

karolina
Member
Registered: 2014-08-09

Re: Show a dadget by url

Hi All,

As long as the dadget is defined in the dadget library, it is possible to get it and display its data via a script report. Then we can call the report via URL.

First we need to create a static HTML dadget in the dadget library. As the dadget ID cannot be obtained from a GUI, we need to use its node ID, which is visible at the top left corner of the dadget definition window.
Then we create a script report with:
- a text parameter of a java.lang.Long type and a key 'dadgetNodeId'. The parameter will pass the dadget node ID value to the script.
- a HTML output format

Then we can call the script report via url, like any other report. The url goes as follows:

http://HOST_IP:PORT/REPORTSERVER_BASE_FOLDER/reportserver/reportexport?id=SCRIPT_REPORT_ID&p_dadgetNodeId=DADGET_NODE_ID&format=HTML&download=false

The script for the script report:

package dadget

import net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledHtmlReportImpl
import net.datenwerke.rs.dashboard.service.dashboard.dagets.StaticHtmlDadget
import net.datenwerke.rs.dashboard.service.dashboard.entities.Dadget
import net.datenwerke.rs.dashboard.service.dashboard.entities.DadgetNode

String reportContent

Long dadgetNodeId = (Long) parameterMap["dadgetNodeId"]

DadgetNode dadgetNode =  GLOBALS.findEntity(DadgetNode.class, dadgetNodeId)

if (dadgetNode != null){

    Dadget dadget = dadgetNode.getDadget()

    if (dadget instanceof StaticHtmlDadget){      
        reportContent = dadget.getData()

    } else {
        reportContent = ErrorReport.notStaticHtmlDadget()
    }
  
} else {    
    reportContent = ErrorReport.noDadgetNodeWithGivenId()  
}

return new CompiledHtmlReportImpl(reportContent)


public class ErrorReport {
    
    public static String noDadgetNodeWithGivenId(){
        
        return """\
        <html>
            <head>
                <title>Error</title>
            </head>
            <body>
                <p>"Cannot find a dadget - nothing to show"</p>
            </body>
        </html>
    """
    }

    public static String notStaticHtmlDadget(){

        return """\
        <html>
            <head>
                <title>Error</title>
            </head>
            <body>
                <p>"This is not a HTML dadget - nothing to show"</p>
            </body>
        </html>
    """
    }
}

Comments:

1. The ErrorReport class is optional. If it is not there, users will see an error stack trace or error message in case node id is not found or when the dadget is not a static html dadget. I prefer displaying an error report.
2. The solution will work in ReportServer Enterprise Edition only

Hope it helps.

Karolina

Offline

#5 2017-06-05 14:06:38

Guilherme
Member
Registered: 2017-01-09

Re: Show a dadget by url

karolina wrote:

Hi All,

As long as the dadget is defined in the dadget library, it is possible to get it and display its data via a script report. Then we can call the report via URL.

First we need to create a static HTML dadget in the dadget library. As the dadget ID cannot be obtained from a GUI, we need to use its node ID, which is visible at the top left corner of the dadget definition window.
Then we create a script report with:
- a text parameter of a java.lang.Long type and a key 'dadgetNodeId'. The parameter will pass the dadget node ID value to the script.
- a HTML output format

Then we can call the script report via url, like any other report. The url goes as follows:

http://HOST_IP:PORT/REPORTSERVER_BASE_FOLDER/reportserver/reportexport?id=SCRIPT_REPORT_ID&p_dadgetNodeId=DADGET_NODE_ID&format=HTML&download=false

The script for the script report:

package dadget

import net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledHtmlReportImpl
import net.datenwerke.rs.dashboard.service.dashboard.dagets.StaticHtmlDadget
import net.datenwerke.rs.dashboard.service.dashboard.entities.Dadget
import net.datenwerke.rs.dashboard.service.dashboard.entities.DadgetNode

String reportContent

Long dadgetNodeId = (Long) parameterMap["dadgetNodeId"]

DadgetNode dadgetNode =  GLOBALS.findEntity(DadgetNode.class, dadgetNodeId)

if (dadgetNode != null){

    Dadget dadget = dadgetNode.getDadget()

    if (dadget instanceof StaticHtmlDadget){      
        reportContent = dadget.getData()

    } else {
        reportContent = ErrorReport.notStaticHtmlDadget()
    }
  
} else {    
    reportContent = ErrorReport.noDadgetNodeWithGivenId()  
}

return new CompiledHtmlReportImpl(reportContent)


public class ErrorReport {
    
    public static String noDadgetNodeWithGivenId(){
        
        return """\
        <html>
            <head>
                <title>Error</title>
            </head>
            <body>
                <p>"Cannot find a dadget - nothing to show"</p>
            </body>
        </html>
    """
    }

    public static String notStaticHtmlDadget(){

        return """\
        <html>
            <head>
                <title>Error</title>
            </head>
            <body>
                <p>"This is not a HTML dadget - nothing to show"</p>
            </body>
        </html>
    """
    }
}

Comments:

1. The ErrorReport class is optional. If it is not there, users will see an error stack trace or error message in case node id is not found or when the dadget is not a static html dadget. I prefer displaying an error report.
2. The solution will work in ReportServer Enterprise Edition only

Hope it helps.

Karolina

Thank you Karolina i'll test.

Offline

Board footer

Powered by FluxBB