---------- Forwarded message ---------- From: jun hua <wwwwar3...@gmail.com> Date: 2009/8/18 Subject: Re: Why submit didn't support param To: Martin Gainty <mgai...@hotmail.com>
Hi, Gainty Thanks! But there is a problem in my case. Like I have 10 textfields generated by iterator. user can input and remove any one of them by a link/button near each one of them. ##############################The link way####################################### <s:iterator value="requestTypeList" status="rtStatus"> <tr> <td colspan=2 class="fieldCaption"> <s:text name="Field%{#rtStatus.index+1}" /> <s:textfield name="Field%{#rtStatus.index+1}" /> <a href='<s:url action="RemoveTextField" ><s:param name="fieldid" value="%{#rtStatus.index}" />' >Remove</a> </td> </tr> </s:iterator> ##############################End of the link way####################################### If the remove is a link. the iterator can remove the textfield I specified. But the users' input in other 9 textfields will get lost after the returning!(requestTypeList will be empty) Submit however, Can send all the user input along to struts, so those value can be maintained after the returning. But so far it seems there is no way to send the param along with submit .:-( Frank 2009/8/18 Martin Gainty <mgai...@hotmail.com> /person/editPerson.jsp > <%@ taglib prefix="s" uri="/struts-tags" %> > > <html> > <head> > <title>Edit Persons (batch-edit)</title> > </head> > > <body> > <s:form action="editPerson" theme="simple" validate="false"> > > <table> > <tr> > <th>ID</th> > <th>First Name</th> > <th>Last Name</th> > </tr> > > <s:iterator value="availableIds"> > <tr> > <td><a href="<s:url action="edit-%{empId}" />"><s:property > value="empId"/></a></td> > <td> > <s:property value="%{id}" /> > </td> > <td> > <s:textfield label="First Name" name="%{firstName}" > value="%{firstName}" theme="simple" /> > </td> > <td> > <s:textfield label="Last Name" name="%{lastName}" > value="%{lastName}" theme="simple"/> > </td> > </tr> > </s:iterator> > </table> > > <s:submit method="save" value="Save all persons"/> > </s:form> > > </body> > </html> > > where WEB-INF/classes/struts.xml contains: > <action name="save" > class="org.apache.struts2.showcase.action.SkillAction" method="save"> > <result name="input">/empmanager/editPerson.jsp</result> > <result > type="redirect">edit.action?skillName=${currentSkill.name}</result> > </action> > > > /* > * $Id: SkillAction.java 476710 2006-11-19 05:05:14Z mrdon $ > * 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.showcase.action; > > import org.apache.log4j.Logger; > import org.apache.struts2.showcase.dao.Dao; > import org.apache.struts2.showcase.dao.SkillDao; > import org.apache.struts2.showcase.model.Skill; > import com.opensymphony.xwork2.Preparable; > > /*** SkillAction. **/ > public class SkillAction extends AbstractCRUDAction implements Preparable { > > private static final Logger log = Logger.getLogger(SkillAction.class); > private String ID; > private String skillName; > protected SkillDao skillDao; > private Skill currentSkill; > private String firstName; > private String lastName; > > //called by the jsp inside the iterator > public String getID() { > return ID; > } > public void setID(String id) > { > this.ID=id; > } > public String getFirstName() > { > return firstName; > } > public void setFirstName(String name) > { > this.firstName=name; > } > public String getSkillName() { > return skillName; > } > public String getLastName() > { > return this.lastName; > } > public void setLastName(String name) > { > this.lastName=name; > } > public void setSkillName(String skillName) { > this.skillName = skillName; > } > > protected Dao getDao() { > return skillDao; > } > > public void setSkillDao(SkillDao skillDao) { > if (log.isDebugEnabled()) { > log.debug("SkillAction - [setSkillDao]: skillDao injected."); > } > this.skillDao = skillDao; > } > > public Skill getCurrentSkill() { > return currentSkill; > } > > public void setCurrentSkill(Skill currentSkill) { > this.currentSkill = currentSkill; > } > > /** > * This method is called to allow the action to prepare itself. > * @throws Exception thrown if a system level exception occurs. > */ > public void prepare() throws Exception { > Skill preFetched = (Skill) fetch(getSkillName(), > getCurrentSkill()); > if (preFetched != null) { > setCurrentSkill(preFetched); > } > } > > public String save() throws Exception { > if (getCurrentSkill() != null) { > setSkillName((String) skillDao.merge(getCurrentSkill())); > } > return SUCCESS; > } > } > > BTW: all of this is available in 2.1.6 distro under apps folder > > HTH > Martin Gainty > ______________________________________________ > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > dient lediglich dem Austausch von Informationen und entfaltet keine > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le > destinataire prévu, nous te demandons avec bonté que pour satisfaire informez > l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci > est interdite. Ce message sert à l'information seulement et n'aura pas > n'importe quel effet légalement obligatoire. Étant donné que les email > peuvent facilement être sujets à la manipulation, nous ne pouvons accepter > aucune responsabilité pour le contenu fourni. > > > > > > > > Date: Tue, 18 Aug 2009 12:17:24 -0400 > > From: wwwwar3...@gmail.com > > To: user@struts.apache.org > > Subject: Why submit didn't support param > > > > > Hi, > > > > Just currious y struts didn't support <s:param> in <s:submit> > > > > I am having a problem: > > > > A list of controls are produced using iterator, user can remove each of > > them by clicking submit near each of them. > > > > If i use <s:url>, i can send the id of the row via <param>, but the data > > user has inputed will be lost! Also the iterator will be empty! > > > > If I use <s:submit> I have no way to know which row the control is > located! > > > > Are trying to modify the struts2 source code! but it's really really a > > mess for a beginer like me!! > > > > Any suggestions?! > > > > > > > > > > Frank > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > ------------------------------ > With Windows Live, you can organize, edit, and share your photos. Click > here. <http://www.windowslive.com/Desktop/PhotoGallery> >