This content has been marked as final. Show 7 replies
adf0994 wrote:To me it looks you're getteng the last one since you return <tt>usrw</tt> rather than <tt>co</tt>.
my problem is am only geting first selected users and the rest is not been passed,i can select 3 users but only the first user i select is been passed
Move the declaration of <tt>usrw</tt> to the place where it gets assigned its value. Then you cannot return it (wrongly) at the end...
adf0994 wrote:Yes, because you don't want to return the intermediate variable <tt>usrw</tt> holding a single user name. You want to return the collection of all user names stored in <tt>co</tt>.
i put it inside my for loop
but is not able to be recognise when i do the
String usrw = (String)r.getAttribute("name");
I even decalre global but still not able to recive all pass valuesDon't try random solutions! Understand the problem!
but am geting Error(606,16): incompatible types,i what to pass the value as string as the reciving method is define as string,how can i return the collection of all user names stored in co.how can i return co arraylist and pass it as string
Edited by: adf0994 on 2012/12/12 9:47 AM
Edited by: adf0994 on 2012/12/12 9:57 AM
Edited by: adf0994 on 2012/12/12 9:59 AM
Edited by: adf0994 on 2012/12/14 11:25 AM
adf0994 wrote:This is the wrong way. Createing a String from the list just to satisfy the methods interface is not a good idea.
am trying to use this but with no luck, i what to take arraylist define method and pass it to string define mathod,but first what to convert it to string
String asString = ArrayList.toString(orgDetails.getusername());
but am geting Error(606,16): incompatible types,i what to pass the value as string as the reciving method is define as string,how can i return the collection of all user names stored in co.howSimply change the methods signature to return your collection type
And yes, after this change your entire code will not be compilabe yet. You have to change all places calling <tt>getusername()</tt> to handle the output as a <tt>List</tt>.
public String getusername() // should be changed to public List<String> getusernames()
adf0994 wrote:Looks like you have a design flaw.
You have to change all places calling getusername() to handle the output as a List.
but my method is define as string i cannot just change it to list as is been used in diffirent class for diffirent purpose
When I'd see the method <tt>getusername()</tt> I'd expect it to return a single users name as a string (as it does at the beginning).
If I get you right you're currently expending it to return a string containing several userids.
I would not do this.
If you need a list of usernames you should create a new method with an appropriate name eg: <tt>List<String> getUsernames()</tt>.
Also you should define for yourself how to uniquely identify the username queried in your current implementation. In your OP you return the a random username that happens to be the last returnd by the query.