1 package org.apache.maven.archiva.web.tags;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import com.opensymphony.xwork2.util.ValueStack;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25 import org.apache.struts2.components.Component;
26 import org.apache.struts2.views.jsp.TagUtils;
28 import javax.servlet.jsp.JspException;
29 import javax.servlet.jsp.tagext.TagSupport;
30 import org.apache.struts2.views.jsp.ComponentTagSupport;
37 public class DownloadArtifactTag
38 extends ComponentTagSupport
40 private String groupId_; // stores EL-based groupId property
42 private String groupId; // stores the evaluated groupId object.
44 private String artifactId_; // stores EL-based artifactId property
46 private String artifactId; // stores the evaluated artifactId object.
48 private String version_; // stores EL-based version property
50 private String version; // stores the evaluated version object.
52 private String mini_; // stores EL-based mini property
54 private boolean mini; // stores the evaluated mini object.
57 public Component getBean(ValueStack valueStack, HttpServletRequest request, HttpServletResponse response) {
58 return new DownloadArtifact(valueStack, pageContext);
65 evaluateExpressions();
67 DownloadArtifact download = (DownloadArtifact)component;
68 download.setGroupId( groupId );
69 download.setArtifactId( artifactId );
70 download.setVersion( version );
71 download.setMini( mini );
73 return super.doEndTag();
76 private void evaluateExpressions()
79 ExpressionTool exprTool = new ExpressionTool( pageContext, this, "download" );
81 // Handle required properties.
82 groupId = exprTool.requiredString( "groupId", groupId_ );
83 artifactId = exprTool.requiredString( "artifactId", artifactId_ );
84 version = exprTool.requiredString( "version", version_ );
86 // Handle optional properties
87 mini = exprTool.optionalBoolean( "mini", mini_, false );
90 public void setArtifactId( String artifactId )
92 this.artifactId_ = artifactId;
95 public void setGroupId( String groupId )
97 this.groupId_ = groupId;
100 public void setVersion( String version )
102 this.version_ = version;