TextField.java contents: /* * $Id: TextField.java 651946 2008-04-27 13:41:38Z apetrelli $ * 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.components; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.views.annotations.StrutsTag; import org.apache.struts2.views.annotations.StrutsTagAttribute; import com.opensymphony.xwork2.util.ValueStack; /** * <!-- START SNIPPET: javadoc --> * Render an HTML input field of type text</p> * <!-- END SNIPPET: javadoc --> * * <p/> <b>Examples</b> * <p/> * <!-- START SNIPPET: exdescription --> * In this example, a text control for the "user" property is rendered. The label is also retrieved from a ResourceBundle via the key attribute. * <!-- END SNIPPET: exdescription --> * <pre> * <!-- START SNIPPET: example --> * <s:textfield key="user" /> * <!-- END SNIPPET: example --> * </pre> * * <pre> * <!-- START SNIPPET: example2 --> * <s:textfield name="user" label="User Name" /> * <!-- END SNIPPET: example --> * </pre> */ @StrutsTag( name="textfield", tldTagClass="org.apache.struts2.views.jsp.ui.TextFieldTag", description="Render an HTML input field of type text", allowDynamicAttributes=true) public class TextField extends UIBean { /*** The name of the default template for the TextFieldTag */ final public static String TEMPLATE = "text"; protected String maxlength; protected String readonly; protected String size; public TextField(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); } protected String getDefaultTemplate() { return TEMPLATE; } protected void evaluateExtraParams() { super.evaluateExtraParams(); if (size != null) { addParameter("size", findString(size)); } if (maxlength != null) { addParameter("maxlength", findString(maxlength)); } if (readonly != null) { addParameter("readonly", findValue(readonly, Boolean.class)); } } @StrutsTagAttribute(description="HTML maxlength attribute", type="Integer") public void setMaxlength(String maxlength) { this.maxlength = maxlength; } @StrutsTagAttribute(description="Deprecated. Use maxlength instead.", type="Integer") public void setMaxLength(String maxlength) { this.maxlength = maxlength; } @StrutsTagAttribute(description="Whether the input is readonly", type="Boolean", defaultValue="false") public void setReadonly(String readonly) { this.readonly = readonly; } @StrutsTagAttribute(description="HTML size attribute", type="Integer") public void setSize(String size) { this.size = size; } } --------TextFieldTag.java /* * $Id: TextFieldTag.java 651946 2008-04-27 13:41:38Z apetrelli $ * * 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.views.jsp.ui; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.components.Component; import org.apache.struts2.components.TextField; import com.opensymphony.xwork2.util.ValueStack; /** @see TextField */ public class TextFieldTag extends AbstractUITag { private static final long serialVersionUID = 5811285953670562288L; protected String maxlength; protected String readonly; protected String size; public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) { return new TextField(stack, req, res); } protected void populateParams() { super.populateParams(); TextField textField = ((TextField) component); textField.setMaxlength(maxlength); textField.setReadonly(readonly); textField.setSize(size); } /*** @deprecated please use {...@link #setMaxlength} instead */ public void setMaxLength(String maxlength) { this.maxlength = maxlength; } public void setMaxlength(String maxlength) { this.maxlength = maxlength; } public void setReadonly(String readonly) { this.readonly = readonly; } public void setSize(String size) { this.size = size; } } -----------end TextFieldTag.java as I dont see required attribute (but I do see dynamic attributes=true) do you want a required attribute in TextField ? Martin ______________________________________________ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. > Subject: Required attribute > Date: Fri, 13 Mar 2009 20:11:27 -0400 > From: hienthuc_p...@merck.com > To: user@struts.apache.org > > > Is there a way to change the required attribute value in textfield, > textarea, etc. from asterisk (*) to some other value like (required)? > I'm using Struts 2.1.6 > > -Hien > Notice: This e-mail message, together with any attachments, contains > information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, > New Jersey, USA 08889), and/or its affiliates (which may be known > outside the United States as Merck Frosst, Merck Sharp & Dohme or > MSD and in Japan, as Banyu - direct contact information for affiliates is > available at http://www.merck.com/contact/contacts.html) that may be > confidential, proprietary copyrighted and/or legally privileged. It is > intended solely for the use of the individual or entity named on this > message. If you are not the intended recipient, and have received this > message in error, please notify us immediately by reply e-mail and > then delete it from your system. _________________________________________________________________ Windows Live⢠Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009