[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    FieldErrors for a specific form ID
From:       struts.rgm () spamgourmet ! com
Date:       2011-07-19 16:08:50
Message-ID: 4ECE614F-955B-4948-A6F2-90F321F00079 () rgm ! nu
[Download RAW message or body]

After perusing the source code I don't feel like this is possible, but if y'all know \
otherwise please give me a heads-up even if just to confirm my suspicion. It appears \
that Struts2 does know the ID of the current form, but this information is not used \
for an xwork validation context -- which appears to be either at the action or method \
level.  Some thought would have to go into how best to put a solution on the \
ValueStack for backwards compatibility.

To refresh your memories (from yesterday) here's the situation I found myself in:

<#--
  tl;dr --   Is it possible to set a validation context specific to a form ID, or to \
add field errors  to a data structure representing one unique form?

  These three forms share an input with the same name, but could be distinct \
instances of domain objects.  If one is submitted and does not validate(), the \
FieldError is shown on all three  forms instead of just the one that was submitted.

  Furthermore, since each textfield is named "msg" then "getMsg()" is called via OGNL \
for all forms,  so all inputs have the same value after submission.  It'd be great if \
                the tags could first check a form-specific data structure for value \
                and error info.
-->
<#list [ 1, 2, 3 ] as idx >

  <@s.form id="ff${idx?c}">
    <#--
      Struts does not generate unique IDs automatically in this case,
      so for valid HTML you must provide the ID explicitly.  No action param is
      defined, so the form will submit to the same page.
    -->

    <@s.hidden name="msg.id" value="${idx?c}" />
    <@s.textfield name="msg" labelposition="left" label="Message ${idx?c}" />
    <@s.submit />
  </@s.form>

</#list>




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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic