struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel <miguel...@gmail.com>
Subject Re: input Map
Date Thu, 28 Aug 2008 17:58:59 GMT
I've also read:

http://struts.apache.org/2.x/docs/type-conversion.html

but I don't understand how to use a Map


Si quieres ser más positivo, pierde un electrón
Miguel Ruiz Velasco S.



On Thu, Aug 28, 2008 at 12:14, Miguel <miguelrvs@gmail.com> wrote:
> Hi,
>
> I'm currently writing a form based on a set, and each object of the
> set has it's own textfield and it's own id/name.
> The question is the way i read the returned value in the action.
> I've tried using a map, but puting the varname[key] doesn't work; How
> can I acomplish this using struts2?
> The goal is to have the map filled with the keys and values simultaneously.
>
> <s:form id="questedit_form" name="form1" method="post"
> action="questionaire/questionaire.action" cssClass=""
> targets="#editor">
>        <s:iterator value="metrics">
>           <s:set id="description" value="description" />
>           <s:set id="id" value="id" />
>           <s:set id="value" value="value" />
>           <s:textfield name="resp[%{id}]" label="%{description}"
> value="%{value}" /><br/>
>        </s:iterator>
>        <s:submit type="button" name="ButtonF" id="Submit" value="Salvar"
> method="save" cssClass="textc" />
> </s:form>
>
> I also tried:
> <s:textfield name="resp.[%{id}]" label="%{description}" value="%{value}" /><br/>
> <s:textfield name="resp.{%{id}}" label="%{description}" value="%{value}" /><br/>
> <s:textfield name="resp{%{id}}" label="%{description}" value="%{value}" /><br/>
>
> to fill:
>
> package org.unam.mcic.gqm.web;
>
> import java.util.HashMap;
> import java.util.HashSet;
> import java.util.Iterator;
> import java.util.List;
> import java.util.Map;
> import java.util.Set;
>
> import org.hibernate.Hibernate;
> import org.unam.mcic.metrics.gqm.Metric;
> import org.unam.mcic.metrics.gqm.Questionaire;
> import org.unam.mcic.metrics.gqm.RespondedQuestionaire;
> import org.unam.mcic.metrics.repos.MetricDAO;
> import org.unam.mcic.metrics.repos.QuestionaireDAO;
>
> import com.ervacon.bitemporal.TimeUtils;
> import com.opensymphony.xwork2.ActionSupport;
> import com.opensymphony.xwork2.Preparable;
>
> public class ResponseAction extends ActionSupport implements Preparable {
> ...
>
>        protected Map<Long,Double> resp = new HashMap<Long,Double>();
>
>        public void prepare() throws Exception {
> ...
>        }
>
>        public String browse(){
> ...
> }
>
>        public Map<Long, Double> getResp() {
>                return resp;
>        }
>
>        public void setResp(Map<Long, Double> resp) {
>                this.resp = resp;
>        }
> }
>
>
>
> Si quieres ser más positivo, pierde un electrón
> Miguel Ruiz Velasco S.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message