• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

proble in converting ArrayList<String> to ArrayList<Object>

 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tahnk you for your help in advance

But i am getting difficulty in converting ArrayList<String> to ArrayList<Object> ???




In above code....Domain is my class name. and "x1" is checked checkboxes from previous pages whih are stored in session.

i Am getting error as "Cannot cast from ArrayList<String> to ArrayList<Domain>".....please help me...
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly- Please dont use JSP for processing- its only used for View. You can use a Servlet to all the processing and send the final results to the JSP.

And coming back to your doubt- You cannot cast- ArrayList<String> to ArrayList<Domain>. An alternative is to loop through the List and then create each Domain instance and set it to the ArrayList. By the way- How does the Domain class look like?
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.....and sorry for not using servlets. I am new to this field i.e java

Domain.jsp

and DomainDAO.jsp



will you please,tell how to iterate through loop and take in ArrayList<Domain>.....
please, help me out...i am new to jsp...please , please help me
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We dont know your requirement well- You get the Checked Values form the JSP and I assume that You want the domainName attribute in Domain class to hold this value?

Getting the checked values from JSP:


You other Java source files- seem to complicate your doubt. I have tried to understand your requirement and helped you with the above pseudocode.
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for youe help....
 
rahulj rjagtap
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want some more help from you ........



after running this code, it gives me two outputs on my consoles: these are as:

domainlist is :: [Domain [categoryId=1, domainId=9, domainName=Supporting Business Collaboration], Domain [categoryId=1, domainId=8, domainName=Multi Location], Domain [categoryId=1, domainId=6, domainName=Bulk Processing]]

MyDomainList:: [Domain [categoryId=0, domainId=0, domainName=Bulk Processing,Multi Location]]


so, i want to output in such a following type:

domainlist is :: [Domain [categoryId=1, domainId=9, domainName=Supporting Business Collaboration], Domain [categoryId=1, domainId=8, domainName=Multi Location], Domain [categoryId=1, domainId=6, domainName=Bulk Processing]]

MyDomainList:: Domain [categoryId=1, domainId=8, domainName=Multi Location], Domain [categoryId=1, domainId=6, domainName=Bulk Processing]]

I am waiting for your reply.....please help me out...

Thank you for your help in advance

 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your code from lines- 32 to 37.

You got to be creating One Domain object for each checked value. So the code at line 32 would move into the loop. And there should be some way to get the associated categoryId and domainId for that domainName. For that you can iterate through the domainList and obtain the required values and then

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic