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

  • Home
  • SEARCH
  • 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 6940627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:46:37+00:00 2026-05-27T12:46:37+00:00

This question can have different answers because everyone would do it his own way.

  • 0

This question can have different answers because everyone would do it his own way. But I guess a good discussion could help me find mine.

First I will explain the scenario that I am trying to execute. Please be patient, its gonna be long (even though I have tried to keep it short). And since I am not very experienced please be kind.

I need to control access of users to various pages and functionality of the web app I am building. The web pages are grouped into various modules. And each module has different type of access options. For example, module 1 can have only read & write access options but module 2 can have read, write, modify & delete access options. I have my database built up as I need, I just need help in building up the front end for controlling it.

I have something like the following in my mind (All the variables and lists are set in an action class that was called before displaying this page):

<s:form id="form1" name="form1" action="savePermissions">
    <s:select name="module" label="Select Module" list="moduleList" onchange="dojo.event.topic.publish('getPermissions');"/>
    <table>
        <s:iterator id="iter" value="emplList" var="emplVar">
        <tr>
            <td><s:textfield name="empl" value="%{<s:property value='emplName'/>}" readonly="true"/></td>
            <td><s:select name="perm" value="%{<s:property value='permission'}" list="perList"/></td>
        </tr>
    </s:iterator>
    </table>
    <s:submit value="save"/>
</s:form>

Here when a module is selected from 1st drop down, a list of users and corresponding access options is listed. Now I should be able to select access option for each user and then communicate to action class with these values so that I can update the database.

But here I have 2 problems:

1.) The employee text fields do not get populated with the values.

2.) In the action class, that will be called when this form is submitted, how can I make sure that I get correct values corresponding to correct username. I mean that if ‘read’ is selected for ‘user1’ and ‘view’ for ‘user2’ on the jsp page, I should get the same in the action class.

Please advise.

Thanks!!

If something is unclear please comment.

EDIT

public class getPermissions1Action extends ActionSupport {
private List<String> moduleList;
public List<String> getModuleList() {
    return moduleList;
}
public void setModuleList() {
    this.moduleList = Arrays.asList("module1","module2","module3");
}


private empl emplVar;
private List<empl> emplList;
public List<empl> getEmplList() {
    return emplList;
}
public void setEmplList(List<empl> emplList) {
    this.emplList = emplList;
}
public empl getEmplVar() {
    return emplVar;
}
public void setEmplVar(empl emplVar) {
    this.emplVar = emplVar;
}

private List<String> perList;
public List<String> getPerList() {
    return perList;
}
public void setPerList() {
    this.perList = Arrays.asList("enter","view","edit","delete","nothing");
}

public getPermissions1Action() {

}

@Override
public String execute(){
empl var = new empl();
List<empl> empl = new ArrayList<empl>();
try{
    for(int i=0;i<3;i++){
        var.setEmplName("name");
        var.setSelPer("view");
        empl.add(var);
    }
    }catch(Exception e){
        System.out.println(e.getMessage());
    }
    setEmplList(empl);
    setModuleList();
    setPerList();
    return SUCCESS;
}
}

empl class:

public class empl {

    private String emplName;
    private String selPer;
    public String getEmplName() {
        return emplName;
    }
    public void setEmplName(String emplName) {
        this.emplName = emplName;
    }
    public String getSelPer() {
        return selPer;
    }
    public void setSelPer(String selPer) {
        this.selPer = selPer;
    }

}
  • 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-05-27T12:46:38+00:00Added an answer on May 27, 2026 at 12:46 pm
    The employee text fields do not get populated with the values.
    

    you need to tell/show what iter is composed of in your action class? or are you expecting that moment you select some value in your first select component it should fill the value of iterator and the fields should come up with the corresponding iterator values?

    if this is the case than i am afraid it will not work as you need some short of ajax functionality like either you need to refresh that area and update its contents or you need to parse that data from your ajax call and need to fill the respected fields.

    Regarding second part.What if you need to provide more than one permission to a user,in that case though you can enable multiple select option but i would prefer a list of check-boxes in front of each user and i can select as per my options/choice.

    Personaly, for providing role based access to an application i will choose some other way around e.g Spring security which has been developed taking in account all such type of use cases.

    Here is working copy for you.

    <s:form id="form1" name="form1" action="savePermissions">
    
        <table>
            <s:iterator value="emplList" var="emplVar">
            <tr>
                <td><s:textfield name="empl" value="%{emplName}" readonly="true"/>
                </td>
    
            </tr>
        </s:iterator>
        </table>
        <s:submit value="save"/>
    </s:form>
    

    when iterator will iterate over the emplList it will place the object in your case empl on top of value stack and we can directly access its properties

    FYI:Class name should always be start from capital letter as per naming convention

    And in Action class there are lot is problems

    @Override
    public String execute(){
    empl var = new empl();
    List<empl> empl = new ArrayList<empl>();  
    // Ther is no need to define this instead you can add directly to emplList
       like emplList.add(object);
    try{
        for(int i=0;i<3;i++){
            var.setEmplName("name");
            var.setSelPer("view");
            empl.add(var);
        }
        }catch(Exception e){
            System.out.println(e.getMessage());
        }
        setEmplList(empl);
        setModuleList();
        setPerList();
        return SUCCESS;
    }
    

    Action name getPermissions1Action should always start with capital letter (GetPermissions1Action) though get/set should be used for methods and not for class name

    and i am not sure why you defining Action Constructor

    public getPermissions1Action() {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not been able to find any definitive answers to this question: Can
I have a feeling this is a stupid question but I can't find the
this question can create a misunderstanding: I know I have to use CSS to
Following on from this question I now have code that can attach to a
I have a corollary question to This one. How can you change the spacing
I asked a question about different testing frameworks yesterday. This question can be found
We are using SQL Server 2005, but this question can be for any RDBMS
<hyperbole> Whoever answers this question can claim credit for solving the world's most challenging
This question may have been asked already - but unfortunately, I could not find
I hardly know how to state this question, let alone search for answers. But

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.