• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display Check Boxes & Dropdowns in Struts with search results

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JavaBean, which gets its properties populated through database table query. For example, this JavaBean has three properties; AccountNumber, Short Name, Portfolio, etc. I have a Collection of such a JavaBean because there are thousands of people in the database table.
Now, it gets to the JSP web page. I am going to display a table with fix columns:

First column: a check box
Second column: AccountNumber
Third column: Short Name
Fourth column: Portfolio
Fifth column: Drop Down
Six column: Radio Button

If client puts a check mark in a check box, radio button & selects from the dropdowm box, the values of all the selections from the form should carried forward when the form is posted. How will I handle some this like this in Struts ActionForm Bean? What do I need to have in my FormBean? Also, I should be able to carry these selections back and forth on the different screens with out putting the values into the session (e.g: like a wizard) is it possible?

Can any of you provide me any code examples or links on this issue? Any help is greatly appreciated.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Struts forum.

Thanks

Mark
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will need to use indexed properties in order to accomplish this. Please read the following two articles on this subject.

http://struts.apache.org/1.2.9/faqs/indexedprops.html
http://wiki.apache.org/struts/StrutsCatalogLazyList

If after reading these articles you have specific questions about how to apply these principles to your situation, let us know.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for the information provided. I will let you know if I have any further questions.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
Thanks a lot for your help. Below is what I am trying to do & having difficulty in displaying check boxes using <html:multibox. I get below error, what am I doing wrong?

[Servlet Error]-[Cannot find bean under name org.apache.struts.taglib.html.BEAN]: javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
at org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:236)
at org.apache.jsp._editRelationships._jspService(_editRelationships.java:207)sa

Here is the jsp code...i am able to print the list of results with out the check box.
<logic:iterate id='relationships' name='relationshipForm'
property='relationshipDTOList' indexId='ctr1'>
<TR>
<TD align='center'>
<!-- creates the check box list , need to pass in the account numbers as values when the check box are selected-->
<html:multibox property="accountIdArrays">
<bean:write name='relationships'/>
</html:multibox>
<bean:write name="relationships"/>

</TD>
<TD>
<bean:write name='relationships' property='accountNumber' />
</TD>
<TD align='center'>
<bean:write name='relationships' property='shortName' />
</TD>
</logic:iterate>
Here is the Form bean...
public class RelationshipForm extends ActionForm{
private String relationshipName = null;
private ArrayList relationshipDTOList = null; //relationshipDTOList contains all the results e.g accountNumber, accountstatus, acct value etc

public RelationshipForm()

{ super(); }

public ArrayList getRelationshipDTOList() {
return relationshipDTOList;
}
public void setRelationshipDTOList(ArrayList list) {
relationshipDTOList = list;
}
public String getRelationshipName() {
return relationshipName;
}
public void setRelationshipName(String string) {
relationshipName = string;
}
private String[] accountIdArrays = {"1824137000","824137001"};
public String[] getAccountIdArrays() {
return this.accountIdArrays;
}
public void setAccountIdArrays(String[] newValue) {
this.accountIdArrays = newValue;
}

}
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change

<bean:write name='relationships'/>

to

<bean:write name='relationships' property='accountNumber' />

Wherever it occurs.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still does not work below are my changes

<html:multibox property="accountIdArray">
<bean:write name='relationships' property='accountNumber'/></html:multibox>
<bean:write name="relationships" />

I get the same error.....
[Servlet Error]-[Cannot find bean under name org.apache.struts.taglib.html.BEAN]: javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
at org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:236)
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there an enclosing <html:form> stanza around your <html:multibox> tag? If not, that's the problem. If this is not the problem, please post your entire JSP.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

Thanks for help. Here is the jsp file, initially I did not have <html:form> tag, but after adding the <html:form> tag it still does not work. property='relationshipDTOList' - Is ArrayList & property='accountIdArrays'- Is String[] in my form bean. Now i get different error

[Servlet Error]-[No getter method available for property accountIdArrays for bean under name org.apache.struts.taglib.html.BEAN]: javax.servlet.jsp.JspException: No getter method available for property accountIdArrays for bean under name org.apache.struts.taglib.html.BEAN
at org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:247)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ page import="java.util.*" %>
<html:html>
<HEAD>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" %>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<TITLE></TITLE>
</HEAD>
<BODY>
<h3>EDIT Existing relationship</h3>
<html:form action="/FormAction" name="testForm" type="test.CheckboxTestForm">

<TABLE border='1' cellpadding='5' cellspacing='1' width='100%'>
<TR>
<TD align='center'><b>Check Box</b></TD>
<TD align='center'><b>Account Number</b></TD>
<TD align='center' nowrap><b>Short Name</b></TD>
<TD align='center' nowrap><b>Portfolio</b></TD>
</TR>

<logic:iterate id='relationships' name='relationshipForm'
property='relationshipDTOList' indexId='ctr1'>
<TR>
<TD align='center'>
<!-- creates the check box list -->
<html:multibox property='accountIdArrays'>
<bean:write name='relationships' property='accountNumber'/>
</html:multibox>
<bean:write name='relationships' property='accountNumber'/>
</TD>
<TD>
<bean:write name='relationships' property='accountNumber' />
</TD>
<TD align='center'>
<bean:write name='relationships' property='shortName' />
</TD>
<TD align='center'>
<bean:write name='relationships' property='portfolio' />
</TD>
</TR>
</logic:iterate>

</TABLE>
</html:form>

</BODY>
</html:html>
[ October 23, 2006: Message edited by: Sara Smith ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something's not right here. The ActionForm class you posted above is called RelationshipForm, and yet the one specified in your <html:form> tag is CheckboxTestForm. Please review your Action mapping and correct any errors. If you're unable to find the errors, please post the ActionForm definition as well as the Action mapping from your struts-config.xml file.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not submitting the page yet, I am rendering the page when I click the url with /editrelations.do
My page should display all the results with the check boxes next to the result. Then upon selections I will submit the page.
Below are the config file
<form-beans>
<form-bean name="relationshipForm"
type="com.cewizard.beans.RelationshipForm"/>
</form-beans>
<action-mappings>
<action path="/editrelation"
type="com.cewizard.actions.RelationshipAction"
name="relationshipForm"
scope="request"
input="/jsp/cewizard/editRelationships.jsp">
<forward name="editrelationship" path="/jsp/cewizard/editRelationships.jsp" />
<forward name="error-page" path="/jsp/cwrError.jsp" />
</action>
</action-mappings>

jsp file made changes to
<html:form action="editrelation" name="relationshipForm" type="com.cewizard.beans.RelationshipForm">
[ November 01, 2006: Message edited by: Sara Smith ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't matter if you've submitted the page yet. Struts gets its information on how to match up your <html:text> tag with its corresponding ActionForm bean from the <html:form> tag. if it's coded incorrectly, Struts can't do the correct match-up.

Your <html:form> tag looks correct now except for one thing. You should include the initial slash on the action. Also, remove the name and type attribues. If your action is correct, Struts will find the rest of the information. Your <html:form> tag should look like this:

<html:form action="/editrelation" >
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,
Sorry to bother you again & again, I fixed all the errors and corrections. Still can't display the page with checkboxes. What am I doing wrong? Atill get the same error...
No getter method available for property accountIdArrays for bean under name org.apache.struts.taglib.html.BEAN]
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,

Thanks for your help. Now, i am able to make it work.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Glad to hear it. Good luck on your project
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,

Thanks a lot for all your input & help. Now my question is how will I pass these request values back & forth in my wizard application? As I am dealing with the same Form Bean across all my pages (Edit, Select, Define, Review, Finish). Can I pass my FormBean back & forth in request scope with out sending any hidden parameters from page to page in struts?

I am not saving any data in to the database until I hit the Finish page & can�t use sessions because we don�t have session persistent mechanism.
User can go from Edit step to Review make changes & go back to Select etc; I have to make sure all these selections are set to my Form Bean each time user makes any changes? Can accomplish this by using my Form Bean in request scope? I really need you input?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can I pass my FormBean back & forth in request scope with out sending any hidden parameters from page to page in struts?


The short answer to this question is no. However, you can do it if you are willing to pass data through hidden fields on the form. Hidden fields have their drawbacks, though. For one thing, they can be easily spoofed.

Any way you look at it, HTTP is a stateless protocol, which means if you want to persist state between requests, you have to store it either on the client (browser) or the server. By using hidden fields, you are essentially saving state on the browser. Another way to save state on the browser would be with cookies. If you want to save state on the server without using the HttpSession, you could simply save it to a relational database using some unique key generated for each user.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By putting into session scope, it should work-right? Can you provide any Wizard kind of Struts application examples? I am trying to use session scope & having difficulty going back & forth too. It will be really helpful if you can provide with any wizard code samples or links? I have been searching & not very fortunate to find good samples. Again thanks for your help.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. If you put the ActionForm in session scope, all the information is saved on the server until you're ready to write it to the database.

This link provides some good suggestions for creating a "wizard" workflow.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, thanks for your help. I did have a look at this link before (one & only link I found so far). If I put my Action Form Bean in Session scope, I have a method in my Form bean called get/set EventType(different events will be tracked for page navigation). If i put the form bean in session its Event Type is also be saved into session & page navigation does not work correctly.
Below is my struts-config file. Any suggestions on how can I go about page navigation, when user clicks Previous, Next, Finish?
<action-mappings>
<action path="/step1"
type="com.cwrwizard.actions.RelationshipAction"
name="relationshipForm"
scope="session"

input="/jsp/cwrwizard/step1.jsp">
<forward name="step1" path="/jsp/cwrwizard/step1.jsp" />
<forward name="error-page" path="/jsp/cwrError.jsp" />
</action>
<action path="/step2"
type="com.cwrwizard.actions.RelationshipAction"
name="relationshipForm"
scope="session"
input="/jsp/cwrwizard/step2.jsp">
<forward name="step2" path="/jsp/cwrwizard/step2.jsp" />
<forward name="step1" path="/jsp/cwrwizard/step1.jsp" />
<forward name="error-page" path="/jsp/cwrError.jsp" />
</action>
<action path="/step3"
type="com.cwrwizard.actions.RelationshipAction"
name="relationshipForm"
scope="session"
input="/jsp/cwrwizard/step3.jsp">
<forward name="step3" path="/jsp/cwrwizard/step3.jsp" />
<forward name="step2" path="/jsp/cwrwizard/step2.jsp" />
<forward name="error-page" path="/jsp/cwrError.jsp" />
</action>
<action path="/step4"
type="com.cwrwizard.actions.RelationshipAction"
name="relationshipForm"
scope="session">
<forward name="step4" path="/jsp/cwrwizard/step4.jsp" />
<forward name="step3" path="/jsp/cwrwizard/step3.jsp" />
<forward name="error-page" path="/jsp/cwrError.jsp" />
</action>
<action path="/step5"
type="com.cwrwizard.actions.RelationshipAction"
name="relationshipForm"
scope="session">
<forward name="step5" path="/jsp/cwrwizard/step5.jsp" />
<forward name="step4" path="/jsp/cwrwizard/step4.jsp" />
<forward name="error-page" path="/jsp/cwrError.jsp" />
</action>
[ November 01, 2006: Message edited by: Sara Smith ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't quite understand how your eventType property works, but if you need it to be a different value for each page, that's easy enough to do. Just put a hidden field with that name in each page, and specify a value attribute. Example:

in step1.jsp:

<html:hidden property="eventType" value="page1" />

in step2.jsp:

<html:hidden property="eventType" value="page2" />
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

in step2.jsp:

<html:hidden property="eventType" value="page2" />



In step2.jsp i have 2 submit buttons Next & Previous, when i hit "Next" my hidden parameter is "page2" & step3 page will be displayed, but when i hit Previous i want it to go to page1 & step1.jsp? How can i do this in struts?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's how I'd do it:


Then, in your Action class the following code will work regardless of what page you're on:


The above assumes you coded your buttons as follows:

<html:submit property="next" value="Next"/>
<html:submit property="previous" value="Previous" />
<html:submit property="finish" value="Finish" />

Also, since the Actionform is in session scope, you will have to override the ActionForm's reset method and put in the following code:

setNext(null);
setPrevious(null);
setFinish(null);
[ October 27, 2006: Message edited by: Merrill Higginson ]
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. It does work.
[ October 27, 2006: Message edited by: Sara Smith ]
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

Thanks a lot for all your help. As I can't use session, I will be using request scope to pass my data back & forth. Any suggestions on how this can be handled efficiently in struts?

How can I send list of (selected acct numbers, drop down etc) hidden parameters from step1 -step2 -step3-step4 or any steps in struts?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just add <html:hidden> tags to every page such that every property of your ActionForm that is not displayed on the current page is defined in an <html:hidden> tag. Example:

<html:hidden property="abc" />
<html:hidden property="def" />

<html:text property="xyz" />

In the above examples, abc and def are properties of the ActionForm that are not displayed on the current page, while xyz is a property that is displayed on the current page.

If you use this technique, all the properties will get passed from one page to the next.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is Jsp code which is renderring the page with the check boxes.

<logic:iterate id='relationships' name='relationshipForm'
property='relationshipDTOList' indexId='ctr1'>
<TR>
<TD>
<!-- creates the check box list -->
<html:multibox property='selectedAccountIds'>
<bean:write name='relationships' property='accountNumber' />
</html:multibox>

<bean:write name='relationships' property='accountNumber' />
</TD>
<TD align='center'>
<bean:write name='relationships' property='shortName' />
</TD>
</TR>
</logic:iterate>


On submit, below is what I am doing, how will I sent the selections to different pages using hidden parms? I am not getting it right? Should I have new set of get/set methods in the ActionForm bean for all the hidden fields I am passing through? Also, how can I pass the list of check boxes selections? By adding this <html:hidden property="selectedAccountIds " /> it does not work.


<html:form action="/step2" name="relationshipForm" type="com.cwrwizard.beans.RelationshipForm">
<html:hidden property="selectedAccountIds " />


[ November 01, 2006: Message edited by: Sara Smith ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Should I have new set of get/set methods in the ActionForm bean for all the hidden fields I am passing through?


No, you don't have to create new getter/setter methods on your ActoinForm except in the case where the returned value is an array.

The checkboxes will have to be handled a little differently because they return an array of values. Since you can't store an array in a single <html:hidden> field, you will have to do the following:

Create an indexed getter and setter for a single element of the selectedAccountIds array like this:


The above code assumes you have a constant MAX_SELECTED_ACCOUNT_IDS which contains the maxiumum number of elements that could possibly be in selectedAccountIds.

Then in your JSP, code as follows:


<html:hidden property="selectedAccountId[0]" />
<html:hidden property="selectedAccountId[1]" />
<html:hidden property="selectedAccountId[2]" />
<html:hidden property="selectedAccountId[3]" />

You may want to substitute a loop for the above, but the point is to have as many entries as there are possible elements in the selectedAccountIds array.
[ October 30, 2006: Message edited by: Merrill Higginson ]
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
Thanks again, for your great help.
Here are the methods in Form Bean; I have getSelectedAccountIds & setSelectedAccountIds to display my check boxes on the screen.
As, you mentioned, I have additional two methods,
1. Which take the array & converts to String - getSeletctedAccountsString()
2. Which takes the String & converts to Array -
setSeletctedAccountsString(String acctIds)


public String[] getSelectedAccountIds() {
return selectedAccountIds;
}
public void setSelectedAccountIds(String[] stringArray) {
selectedAccountIds = (String[]) stringArray;
}
public String getSeletctedAccountsString(){
String accountsIds = null;
StringBuffer acct = new StringBuffer();
if ( getSelectedAccountIds() != null && getSelectedAccountIds().length > 0 ){
for (int i=0; i<getSelectedAccountIds().length ; i++){
accountsIds = selectedAccountIds[i];
acct.append(accountsIds);
acct.append(",");
System.out.println("acct = " + acct);
}
}
return acct.toString();
}
public void setSeletctedAccountsString(String acctIds){
StringTokenizer st = new StringTokenizer(acctIds, ",");
ArrayList selectedAccounts = new ArrayList();
try{ while (st.hasMoreTokens()) {
System.out.println("Tokens " + st.nextToken());
} }catch (Exception e){
}
}


1. Now what do i do? How do I pass my hidden parameters back & forth? Please correct me if I am doing wrong.

2. Also, I need to have my checkboxes checked when I display the page,
I am setting the setSelectedAccountIds(stringArray) in my action,
but my page does not display the check boxes as "CHECKED" ? But, if i have my ActionForm in session scope i have these check boxes as "CHECKED" on the page.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your getSelectedAccountsString method looks good, except I'd add the following just before the return statement:

acct.deleteCharAt(acct.length()-1);

This removes the unnecessary last comma.

Your setSelectedAccountsString method won't work, however. Here's how I'd write it:



You don't have to call these getters and setters: Struts calls them. All you have to do is supply <html:hidden> tags for them. So, for all JSPs that do not show the list of accounts with checkboxes, you will have the following tag:

<html:hidden property="selectedAccountsString" />
[ October 31, 2006: Message edited by: Merrill Higginson ]
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't use split function - it�s not specified.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's available in JDK 1.4 and above. Are you using a lower version of the JDK than that?

Also, I'd add the following to the method:

[ October 31, 2006: Message edited by: Merrill Higginson ]
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its 1.3 - i made below changes.

public void setSeletctedAccountsString(String acctIds){
//selectedAccountIds = acctIds.s
StringTokenizer st = new StringTokenizer(acctIds, ",");
try{
if (acctIds == null || acctIds.length() == 0) {
selectedAccountIds = new String[0];
}
for (int i=0; i < st.countTokens(); i++){
selectedAccountIds[i] = st.nextToken();
System.out.println("Tokens values" + selectedAccountIds[i]);
}
}catch (Exception e){
}
}


Also, I need to have my checkboxes checked when I display the page,
I am setting the setSelectedAccountIds(stringArray) in my action,
but my page does not display the check boxes as "CHECKED" ? But, if i have my ActionForm in session scope i have these check boxes as "CHECKED" on the page.


[ October 31, 2006: Message edited by: Sara Smith ]
[ October 31, 2006: Message edited by: Sara Smith ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sara,

The check boxes should show as checked automatically as long as the selectedAccountIds array has values in it.

If you're unable to figure it out, zip the project and email it to me. I'll take a look at it.

Merrill
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

I did send you the zip file of the src code.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The biggest problem I saw was in your struts-config.xml file. You had defined step 1 with a scope of session, and all the other steps with a scope of request. All the steps must be in the same scope, whether it's session or request. This would have caused the problem you were experiencing. Go ahead and make that change and see if that fixes it.

Merrill



1. I did make changes from session to request - Still does not work, Also, restarted my server.

2. I am having really tough time passing the hidden parameters back & forth. I am able to access Hidden parameters till next page(step2). I am not able to access these values in other pages.
I have include below line of in all my jsp files.

<html:hidden property="seletctedAccountsString" />

 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Merrill for all your help & input. You are just a genius.
 
Sara Smith
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,

Was able to display the list of check box & able to pass values of the check box's back & forth with your help. Now, I need to add a drop down next to these results & carry all the selections for every check box & drop down.

e.g, if the user "CHECKED" 2 check boxes & made selections to the drop down � I have check box values & drop down selection values. How will I know which drop down values belongs to which check box?

In my Form bean, I have a get/set String[] method for the drop down. Any suggestions on how will I handle this?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all you need to very carefully read this article, particularly the section entitled Hand Cranking lazyList in the ActionForm.

You then need to create an indexed getter and setter for the individual elements in the RelationshipDTOList in your ActionForm that follow the above example. Something like this:


You would then use the indexed="true" attribute in your <html:xxx> tags to indicate that you want to access the indexed getter and setter that you've created, using the index of the enclosing <logic:iterate> tag as the value to pass to those methods. Note that any data that is displayed, but is not input needs to have a <html:hidden> tag along with the displayed data. Otherwise, this data won't get passed from page to page.

On a page where the list of relationships isn't displayed at all, you still need to have a <logic:iterate> tag that includes all <html:hidden> tags for each of the fields. Otherwise the values won't be passed from page to page.

Here is an example of some of the tags you would include in your first page:


[ November 03, 2006: Message edited by: Merrill Higginson ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic