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 8541039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:44:12+00:00 2026-06-11T11:44:12+00:00

Have implemented an edit functionality in struts2. After i click submit button, the bean

  • 0

Have implemented an edit functionality in struts2. After i click submit button, the bean value that i ‘ve displayed in JSP is obtained correctly in action class.

But the other values of bean that i ‘ve not mentioned in JSP is returning null.

If i display all values of bean in JSP, then i can get all values in Action.

This is the way to fix this issue. Or else , there is any other way.

The code for Action class is

 UserForm userForm = new UserForm();

public String edit(){
    String result = ActionSupport.ERROR;
    HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get( ServletActionContext.HTTP_REQUEST);
        HttpSession session = request.getSession(false);
        if (null != session
                && null != (UserAccount) session.getAttribute(USER)) {
            String editUser = (String) request
            .getParameter(RequestAttributes.EDIT_USER);
            UserAccount userAccount = userForm.getUserAccount();
        if (null != editUser) {
                    //invoked when edit user page is submitted
            userUtils.updateUserAccount(userAccount);

        } else {
                    // invoked when edit user page gets loaded
            String userAccSID = (String) request
                    .getParameter(USER_ACC_SID);
            String roleSID = (String) request.getParameter(ROLE_SID);
            if (null != userAccSID && null != roleSID) {
                Long userAccSIDVal = Long.valueOf(userAccSID);
                Long roleSIDVal = Long.valueOf(roleSID);
                userAccount = userUtils
                        .loadUserAccount(userAccSIDVal);
                userForm.setUserAccount(userAccount);
            }
        }
    } 

    return result;
}

public UserForm getUserForm() {
    return userForm;
}

public void setUserForm(UserForm userForm) {
    this.userForm = userForm;
}

And the code for JSP page is

<s:form action="edit?editUser=edit">
<table align="center">
                    <s:hidden name="userForm.userAccount.createdBy"/>
        <tr align="center">
            <th>Edit User</th>
        </tr>
        <tr>
            <td><s:textfield name="userForm.userAccount.firstName" label="First Name"/></td>
        </tr>
        <tr>
            <td><s:textfield name="userForm.userAccount.lastName" label="Last Name"/></td>
        </tr>

        <tr>
            <td><s:submit value="Save" /><s:reset value="Cancel" /></td>
        </tr>
</table>

Now if i put the createdBy as hidden, then i can get value of createdBy in Action.
It’s value is already set by the action class.
Then, why should i set in jsp page also?

Any help would be highly appreciated . Thanks

  • 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-11T11:44:13+00:00Added an answer on June 11, 2026 at 11:44 am

    If you are not returning values from your JSP, how can they be available to the Action class on form submit.
    One solution is to create hidden fields and set values which you don’t want to show to the user on your JSP page, in this way those values will going to get submitted to the action when you hit submit button.

    Other option is to store data in the Session or fetch the values in your action class but they are not preferable solutions until we have no other options.

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

Sidebar

Related Questions

I have implemented the following functionality that connects to webservice and downloads a favicon
I have implemented Facebook into my app but now I find that whenever I
I have implemented a UISearchDisplayController that allows users to search a table. Currently the
I have implemented remember me functionality in Symfony2. When I log in with remember
OK, so I have a .NET project that uses plugins. The plugins are implemented
I am trying to display a page that uses jQuery. The AJAX functionality implemented
I implemented an authentication system using authlogic, and have added password reset functionality as
i starter in jqgrid, i want implement inline edit in jqgrid i have this
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented pagination to my data, but the problem is I only have

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.