Bookmark Topic Watch Topic
  • New Topic

Request scope in struts  RSS feed

 
Aarthi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Currently our application works fine on Scope Session, now due to client requirement we need to change the scope from session to request. When changing the scope of the application as request(in struts-config.xml), the value of an array of checkboxes(used to display checkboxes depending on no. of policies) is not passed from one action to the other.

The code that I have written:

Action Form:
SearchForm.java

public String getPolicyHolderChecked(final int index) {
int numberOfPolicyHolders = selectPolicyHolders.size();

if (!selectPolicyHolders.isEmpty()) {
if (policyHolderChecked == null || numberOfPolicyHolders != policyHolderChecked.length) {
this.policyHolderChecked = new String[numberOfPolicyHolders];

for (int i = 0; i < numberOfPolicyHolders; i++) {
this.policyHolderChecked[i] = String.valueOf(false);
}
}
}

return policyHolderChecked[index];
}


public void setPolicyHolderChecked(final int index, final String policyHolderChecked) {
this.policyHolderChecked[index] = policyHolderChecked;
}




Strutsconfig.xml:

<action path="/searchPoliciesAdvanced" type="com.landg.oacr.web.search.action.SearchPolicyOptionsAction" name="searchFormBean" scope="request" input=".direct.search.policy" parameter="dispatch" validate="true">
<forward name="back" path=".direct.search.options">
</forward>
<forward name="display" path=".direct.search.policy">
</forward>
</action>


Action class:

public class SearchPolicyOptionsAction extends SearchCoreAction {
private GCDDelegate gcdDelegate;


public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
ActionMessages actionMessages;
ActionForward forward = super.execute(mapping, form, request, response);
SearchForm searchForm = (SearchForm) form;
searchForm.setSearchType(WebConstants.POLICY_SEARCH);

return forward;
}
}
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate of:
http://www.coderanch.com/t/55392/Struts/request-scope

kalai,
Please add any additional information that you have to offer to the original thread instead of asking it again.
Having multiple thread with the same conversion creates confusion and wastes people's time.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!