Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:41:08+00:00 2026-06-11T15:41:08+00:00

I have a typical struts2 form with a File selection field: <s:form action=%{#parameters.myAction} namespace=/

  • 0

I have a typical struts2 form with a File selection field:

<s:form action="%{#parameters.myAction}" namespace="/" method="post" name="myForm" enctype="multipart/form-data" focusElement="storeBrandNameId">
 <s:textfield name="storeBrandName" id="storeBrandNameId" size="40" maxlength="50" required="true" key="storeBrandName-label" tooltip="%{getText('storeBrandName-label-help')}" />
 <s:file name="storeImage" key="storeImage-label"/>
 /* ... Other fields removed for clarity ... */
 <s:submit key="submit" />
</s:form>

The form works fine, except when I have a validation error (using XML validation). In that case, all the fields values are preserved except the selected file (if any).

Why is the selected file cleared on validation error? Is it a bug on my side? a struts2 limitation? or a typical browser limitation? Is there a way around?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:41:09+00:00Added an answer on June 11, 2026 at 3:41 pm

    The value of a file input field cannot be changed or initialized for security reason.

    In your form, you have two fields, the text-field, and the file-field.
    I don’t think users will care if they loose the value of the input field when the file they selected was wrong. They will be annoyed only when the value in the text-field was wrong, and because of that they need to pick-up the file again.
    So you could just do an ajax validation for the text-field value before submitting the form (or better, as they type the value!). If there is a problem, the form is not submitted, user fixes it and don’t loose the file-field value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a typical User model (username, password, name, etc). I want to allow
I have the typical HTML "contact me" page, i.e. name, e-mail address and message.
I have a typical, Post model: class Post< ActiveRecord::Base validates_presence_of :user_id #Line 1 validates_presence_of
I have a typical GWT app, in my module.xml, I have, <inherits name='com.google.gwt.user.theme.standard.Standard' />
I have a typical SQL Server hierarchical query: WITH bhp AS ( SELECT name,
I have a typical ADO.NET EF-driven form that allows the user to input a
i have the typical cover page with the logining form that doesn't have the
I have a typical javascript function with some parameters my_function = function(content, options) {
I have a typical yearbook with photos and a name beneath each photo. Is
I have a typical ajax post type with a success function. I have tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.