提问人:Hack-R 提问时间:3/26/2016 更新时间:3/26/2016 访问量:706
我在 Shiny 中调用消息处理程序 .js 有什么问题?
What's wrong with my call to message-handler.js in Shiny?
问:
我有一个运行良好的 Shiny 应用程序,除了通过 添加消息框失败。message-handler.js
我能想到一个明显的解释,那就是如果我需要先从某个地方下载这个消息处理程序.js文件,但我遵循的指南没有提到这一点,当我在谷歌上搜索该文件时,我从哪里下载它并不明显。因此,现在我假设它是内置于 Shiny 中的。
我遵循的示例是这样的(模式 1)。
我的服务器。R 脚本是:
# Set options
setwd("tableau_self_serve_portal")
# Connect to Access db
channel <- odbcConnectAccess2007("AD_Users.accdb")
shinyServer(function(input, output, session) {
# Value of user id
output$userid <- renderPrint({ input$userid})
# Value of workbook selection
output$value <- renderPrint({ input$select })
observeEvent(input$submission, {
session$sendCustomMessage(type = 'testmessage', message = 'Thank you for clicking')
sql <- paste("insert into self_serve_requests (user_name, workbook_to_access, request_date) values(",
input$userid,",", input$select,",", Sys.time(),");", sep ="'")
cat(sql)
sqlQuery(channel, sql)
})
})
我的用户界面。R 脚本是:
refresh <- F # T = re-pull the AD / Workbook lists from Access DB
# Load libraries
pacman::p_load(RODBC, shiny, shinythemes)
if(refresh){
users <- sqlQuery(channel , paste ("select * from aduserlist"))
workbooks <- sqlQuery(channel , paste ("select * from public__workbooks"))
saveRDS(users, "users.RDS")
saveRDS(workbooks, "workbooks.RDS")
} else{
users <- readRDS("users.RDS")
workbooks <- readRDS("workbooks.RDS")
}
# User Interface
shinyUI(
fluidRow(
tags$head(tags$script(src = "message-handler.js")),
column(4,img(src="leaf-icon.png", align = "top", width = 80)),
column(8,headerPanel("Tableau Self-serve Portal")),
fluidPage(
theme = shinytheme("united"), #"www/bootstrap.css",
# Copy the line below to make a select box
selectizeInput("userid", label = h4("Name of the Requestor"),
choices = paste(users$DisplayName), options = list(create = TRUE)
),
# Copy the line below to make a select box
selectizeInput("select", label = h4("Workbook(s) to Access"),
choices = paste(workbooks$name),
multiple = T
),
actionButton("submission", "Send Request", style="color: #fff; background-color: #F15C22; border-color: #2e6da4"),
hr(),
fluidRow(column(3, verbatimTextOutput("userid"))),
fluidRow(column(3, verbatimTextOutput("value")))
)
))
当我运行我的应用程序时,除了没有弹出消息框外,一切正常。没有警告或错误。
答: 暂无答案
评论