本文整理了Java中org.kohsuke.stapler.StaplerRequest.setAttribute()
方法的一些代码示例,展示了StaplerRequest.setAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.setAttribute()
方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:setAttribute
暂无
代码示例来源:origin: jenkinsci/jenkins
/**
* @param pre
* If true, the message is put in a PRE tag.
*/
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp, boolean pre) throws ServletException, IOException {
req.setAttribute("message",message);
if(pre)
req.setAttribute("pre",true);
rsp.forward(this,"error",req);
}
代码示例来源:origin: jenkinsci/jenkins
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
req.setAttribute("message",message);
req.setAttribute("pre",true);
rsp.forward(Jenkins.getInstance(),"error",req);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Displays the error in a page.
*/
protected final void sendError(Exception e, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
req.setAttribute("exception", e);
sendError(e.getMessage(),req,rsp);
}
代码示例来源:origin: jenkinsci/jenkins
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node, @CheckForNull Throwable throwable) throws IOException, ServletException {
if (throwable != null) {
req.setAttribute("exception", throwable);
}
generateResponse(req, rsp, node);
}
代码示例来源:origin: jenkinsci/jenkins
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
req.setAttribute("message",message);
rsp.forward(this,"error",req);
}
代码示例来源:origin: jenkinsci/jenkins
public void doProgressiveHtml(StaplerRequest req, StaplerResponse rsp) throws IOException {
req.setAttribute("html",true);
doProgressText(req,rsp);
}
代码示例来源:origin: jenkinsci/jenkins
public static void restoreCurrentDescriptorByNameUrl(String old) {
Stapler.getCurrentRequest().setAttribute("currentDescriptorByNameUrl", old);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Handles the form submission from the "/computer/new" page, which is the first form for creating a new node.
* By default, it shows the configuration page for entering details, but subtypes can override this differently.
*
* @param name
* Name of the new node.
*/
public void handleNewNodePage(ComputerSet computerSet, String name, StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
computerSet.checkName(name);
req.setAttribute("descriptor", this);
req.getView(computerSet,"_new.jelly").forward(req,rsp);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Sends the RSS feed to the client.
*
* @param title
* Title of the feed.
* @param url
* URL of the model object that owns this feed. Relative to the context root.
* @param entries
* Entries to be listed in the RSS feed.
* @param adapter
* Controls how to render entries to RSS.
*/
public static <E> void forwardToRss(String title, String url, Collection<? extends E> entries, FeedAdapter<E> adapter, StaplerRequest req, HttpServletResponse rsp) throws IOException, ServletException {
req.setAttribute("adapter",adapter);
req.setAttribute("title",title);
req.setAttribute("url",url);
req.setAttribute("entries",entries);
req.setAttribute("rootURL", Jenkins.getInstance().getRootUrl());
String flavor = req.getParameter("flavor");
if(flavor==null) flavor="atom";
flavor = flavor.replace('/', '_'); // Don't allow path to any jelly
req.getView(Jenkins.getInstance(),"/hudson/"+flavor+".jelly").forward(req,rsp);
}
}
代码示例来源:origin: jenkinsci/jenkins
public static String setCurrentDescriptorByNameUrl(String value) {
String o = getCurrentDescriptorByNameUrl();
Stapler.getCurrentRequest().setAttribute("currentDescriptorByNameUrl", value);
return o;
}
代码示例来源:origin: jenkinsci/jenkins
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
req.setAttribute("message",getMessage());
if(pre)
req.setAttribute("pre",true);
if (node instanceof AbstractItem) // Maintain ancestors
rsp.forward(Jenkins.getInstance(), ((AbstractItem)node).getUrl() + "error", req);
else
rsp.forward(node instanceof AbstractModelObject ? node : Jenkins.getInstance() ,"error", req);
}
}
代码示例来源:origin: jenkinsci/jenkins
public void doCommand(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
final Jenkins jenkins = Jenkins.getActiveInstance();
jenkins.checkPermission(Jenkins.READ);
// Strip trailing slash
final String commandName = req.getRestOfPath().substring(1);
CLICommand command = CLICommand.clone(commandName);
if (command == null) {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND, "No such command");
return;
}
req.setAttribute("command", command);
req.getView(this, "command.jelly").forward(req, rsp);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* @since 1.509.1
*/
public static void _doScript(StaplerRequest req, StaplerResponse rsp, RequestDispatcher view, VirtualChannel channel, ACL acl) throws IOException, ServletException {
// ability to run arbitrary script is dangerous
acl.checkPermission(RUN_SCRIPTS);
String text = req.getParameter("script");
if (text != null) {
if (!"POST".equals(req.getMethod())) {
throw HttpResponses.error(HttpURLConnection.HTTP_BAD_METHOD, "requires POST");
}
if (channel == null) {
throw HttpResponses.error(HttpURLConnection.HTTP_NOT_FOUND, "Node is offline");
}
try {
req.setAttribute("output",
RemotingDiagnostics.executeGroovy(text, channel));
} catch (InterruptedException e) {
throw new ServletException(e);
}
}
view.forward(req, rsp);
}
代码示例来源:origin: jenkinsci/jenkins
public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException {
WebApp webApp = WebApp.getCurrent();
final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view);
if (s!=null) {
JellyFacet facet = webApp.getFacet(JellyFacet.class);
request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us
request.setAttribute("mode","side-panel");
// run sidepanel but ignore generated HTML
facet.scriptInvoker.invokeScript(request,response,new Script() {
public Script compile() throws JellyException {
return this;
}
public void run(JellyContext context, XMLOutput output) throws JellyTagException {
Functions.initPageVariables(context);
s.run(context,output);
}
},self,new XMLOutput(new DefaultHandler()));
} else
if (self instanceof Actionable) {
// fallback
this.addAll(((Actionable)self).getAllActions());
}
return this;
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
SignupInfo si = new SignupInfo(identity);
si.errorMessage = Messages.HudsonPrivateSecurityRealm_WouldYouLikeToSignUp(identity.getPronoun(),identity.getIdentifier());
req.setAttribute("data", si);
super.generateResponse(req, rsp, node);
}
};
代码示例来源:origin: jenkinsci/jenkins
si.errors.put("fullname", hudson.model.Messages.User_IllegalFullname(si.fullname));
req.setAttribute("data", si); // for error messages in the view
return si;
代码示例来源:origin: jenkinsci/jenkins
req.setAttribute("it", this);
List<Path> parentPaths = buildParentPath(base,restSize);
req.setAttribute("parentPath",parentPaths);
req.setAttribute("backPath", createBackRef(restSize));
req.setAttribute("topPath", createBackRef(parentPaths.size()+restSize));
req.setAttribute("files", filteredGlob);
req.setAttribute("icon", icon);
req.setAttribute("path", path);
req.setAttribute("pattern",rest);
req.setAttribute("dir", baseFile);
req.getView(this,"dir.jelly").forward(req, rsp);
return;
代码示例来源:origin: jenkinsci/jenkins
if(ze.getCode()==ErrorCode.EZFS_PERM) {
req.setAttribute("message",log.toString());
rsp.forward(this,"askRootPassword",req);
return;
req.setAttribute("pre",true);
sendError(log.toString(),req,rsp);
return;
代码示例来源:origin: jenkinsci/jenkins
/**
* Deletes the build when the button is pressed.
*/
@RequirePOST
public void doDoDelete( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(DELETE);
// We should not simply delete the build if it has been explicitly
// marked to be preserved, or if the build should not be deleted
// due to dependencies!
String why = getWhyKeepLog();
if (why!=null) {
sendError(Messages.Run_UnableToDelete(getFullDisplayName(), why), req, rsp);
return;
}
try{
delete();
}
catch(IOException ex){
req.setAttribute("stackTraces", Functions.printThrowable(ex));
req.getView(this, "delete-retry.jelly").forward(req, rsp);
return;
}
rsp.sendRedirect2(req.getContextPath()+'/' + getParent().getUrl());
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
req.setAttribute("message",message);
req.setAttribute("pre",true);
rsp.forward(Jenkins.getInstance(),"error",req);
}
内容来源于网络,如有侵权,请联系作者删除!