mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
WW-2136 Missing tag TextArea on dojo plugin
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@571253 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.struts2.dojo.components;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* Render Dojo Editor2 widget
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="textarea", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.TextareaTag", description="Renders Dojo Editor2 widget")
|
||||
public class TextArea extends org.apache.struts2.components.TextArea {
|
||||
|
||||
public TextArea(ValueStack stack, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
super(stack, request, response);
|
||||
}
|
||||
|
||||
public void evaluateExtraParams() {
|
||||
super.evaluateExtraParams();
|
||||
|
||||
boolean generateId = !(Boolean)stack.getContext().get(Head.PARSE_CONTENT);
|
||||
addParameter("pushId", generateId);
|
||||
if ((this.id == null || this.id.length() == 0) && generateId) {
|
||||
Random random = new Random();
|
||||
this.id = "widget_" + Math.abs(random.nextInt());
|
||||
addParameter("id", this.id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTheme() {
|
||||
return "ajax";
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import org.apache.struts2.dojo.views.velocity.components.DivDirective;
|
||||
import org.apache.struts2.dojo.views.velocity.components.HeadDirective;
|
||||
import org.apache.struts2.dojo.views.velocity.components.SubmitDirective;
|
||||
import org.apache.struts2.dojo.views.velocity.components.TabbedPanelDirective;
|
||||
import org.apache.struts2.dojo.views.velocity.components.TextAreaDirective;
|
||||
import org.apache.struts2.dojo.views.velocity.components.TreeDirective;
|
||||
import org.apache.struts2.dojo.views.velocity.components.TreeNodeDirective;
|
||||
import org.apache.struts2.views.TagLibrary;
|
||||
@@ -60,7 +61,8 @@ public class DojoTagLibrary implements TagLibrary {
|
||||
TreeDirective.class,
|
||||
TreeNodeDirective.class,
|
||||
HeadDirective.class,
|
||||
BindDirective.class
|
||||
BindDirective.class,
|
||||
TextAreaDirective.class
|
||||
};
|
||||
return Arrays.asList(directives);
|
||||
}
|
||||
|
||||
+9
@@ -33,6 +33,7 @@ public class DojoModels {
|
||||
protected SubmitModel submit;
|
||||
protected BindModel bind;
|
||||
protected HeadModel head;
|
||||
protected TextAreaModel textarea;
|
||||
|
||||
private ValueStack stack;
|
||||
private HttpServletRequest req;
|
||||
@@ -52,6 +53,14 @@ public class DojoModels {
|
||||
return bind;
|
||||
}
|
||||
|
||||
public TextAreaModel getTextarea() {
|
||||
if (textarea == null) {
|
||||
textarea = new TextAreaModel(stack, req, res);
|
||||
}
|
||||
|
||||
return textarea;
|
||||
}
|
||||
|
||||
public HeadModel getHead() {
|
||||
if (head == null) {
|
||||
head = new HeadModel(stack, req, res);
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.struts2.dojo.views.freemarker.tags;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.dojo.components.TextArea;
|
||||
import org.apache.struts2.views.freemarker.tags.TagModel;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* @see TextArea
|
||||
*/
|
||||
public class TextAreaModel extends TagModel {
|
||||
public TextAreaModel(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
super(stack, req, res);
|
||||
}
|
||||
|
||||
protected Component getBean() {
|
||||
return new TextArea(stack, req, res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.struts2.dojo.views.jsp.ui;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.dojo.components.TextArea;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
|
||||
/**
|
||||
* @see TextArea
|
||||
*
|
||||
*/
|
||||
public class TextareaTag extends org.apache.struts2.views.jsp.ui.TextareaTag{
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new TextArea(stack, req, res);
|
||||
}
|
||||
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
TextArea textArea = ((TextArea) component);
|
||||
textArea.setCols(cols);
|
||||
textArea.setReadonly(readonly);
|
||||
textArea.setRows(rows);
|
||||
textArea.setWrap(wrap);
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.apache.struts2.dojo.views.velocity.components;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.components.Component;
|
||||
import org.apache.struts2.dojo.components.TextArea;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* @see TextArea
|
||||
*/
|
||||
public class TextAreaDirective extends DojoAbstractDirective {
|
||||
public String getBeanName() {
|
||||
return "textarea";
|
||||
}
|
||||
|
||||
protected Component getBean(ValueStack stack, HttpServletRequest req,
|
||||
HttpServletResponse res) {
|
||||
return new TextArea(stack, req, res);
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return BLOCK;
|
||||
}
|
||||
}
|
||||
@@ -59,4 +59,7 @@
|
||||
<#if parameters.nameValue?exists>
|
||||
<@s.property value="parameters.nameValue"/><#t/>
|
||||
</#if>
|
||||
</textarea>
|
||||
</textarea>
|
||||
<#if parameters.pushId>
|
||||
<script language="JavaScript" type="text/javascript">djConfig.searchIds.push("${parameters.id?html}");</script>
|
||||
</#if>
|
||||
Reference in New Issue
Block a user