GeeCON Prague 2014*
The moose likes JSP and the fly likes proble in converting ArrayList<String> to ArrayList<Object> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "proble in converting ArrayList<String> to ArrayList<Object>" Watch "proble in converting ArrayList<String> to ArrayList<Object>" New topic
Author

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

rahulj rjagtap
Ranch Hand

Joined: Oct 20, 2010
Posts: 39
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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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?


Mohamed Sanaulla | My Blog
rahulj rjagtap
Ranch Hand

Joined: Oct 20, 2010
Posts: 39
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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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

Joined: Oct 20, 2010
Posts: 39
Thank you for youe help....
rahulj rjagtap
Ranch Hand

Joined: Oct 20, 2010
Posts: 39
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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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

 
GeeCON Prague 2014
 
subject: proble in converting ArrayList<String> to ArrayList<Object>