Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8701447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:24:00+00:00 2026-06-13T02:24:00+00:00

Im using JQuery to move the elements (to & fro) between 2 select many

  • 0

Im using JQuery to move the elements (to & fro) between 2 select many list box. Here follows my JQuery code for the same.

<script type="text/javascript">

$(document).ready(function() {
    alert('inside function');
    $('#testForm\\:button_add').click(function(e) {
    var selectedOpts = $("#testForm\\:select_from option:selected");
    if (selectedOpts.length == 0) {
    alert("Nothing to move.");
    e.preventDefault();
    }
    $('#testForm\\:select_to').append($(selectedOpts).clone());
    $(selectedOpts).remove();
    e.preventDefault();
    });
    $('#testForm\\:button_remove').click(function(e) {
    var selectedOpts = $("#testForm\\:select_to option:selected");
    if (selectedOpts.length == 0) {
    alert("Nothing to move.");
    e.preventDefault();
    }                                               
    $('#testForm\\:select_from').append($(selectedOpts).clone());
    $(selectedOpts).remove();
    e.preventDefault();
    });
    });

</script>

And here follows my JSF code:

<td width="40%">
    <h:selectManyListbox value="#{testListBox.selectManyOptions}" id="select_from" size="5" >

    <f:selectItems value="#{testListBox.selectedOptions}" />
</h:selectManyListbox>
</td>
<td></td>
<td width="40%">
    <h:commandButton value="To" id="button_add"/><br/>
    <h:commandButton value="From" id="button_remove"/>
</td>
<td></td>
<td>
    <h:selectManyListbox id="select_to" size="5"
                        value="#{testListBox.selectedItems}">
    <f:selectItems />
</h:selectManyListbox>
</td> 
<td></td>

And in the page bean I’ve declared correcponding binding variables as below with respective getters/setters.

private Map<String, Object> selectedOptions;
private Map<String, Object> selectManyOptions;

private List<SelectItem> selectItems = new ArrayList<SelectItem>();
private List<String> selectedItems;

Now Im getting below error while Im submitting my page.
“Target model Type is no a Collection or Array”
Can any one suggest as it is blocking my navigation?
– Vamsi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:24:01+00:00Added an answer on June 13, 2026 at 2:24 am

    Your concrete problem is caused because you’re using Map instead of Collection or Object[] as value of <h:selectManyListbox>. That component doesn’t support a Map as value.

    If you replace

    private Map<String, Object> selectedOptions;
    private Map<String, Object> selectManyOptions;
    

    by

    private List<String> selectedOptions;
    private List<String> selectManyOptions;
    

    (or String[])

    then this particular problem should disappear.


    Unrelated to the concrete problem, after you’ve fixed this problem, you’ll undoubtely face a new problem. To save yourself from the effort asking another question again, here is then the answer: How to create a picklist in JSF? Tried moving items using JS/jQuery, but submit errors with "Validation Error: Value is not valid"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JQuery to select some elements on a page and then move them
I'm trying to move child div elements between two different parent divs using jQuery
I'm experimenting with using jQuery toggle to move between two functions. The results so
I using jquery sorting ( http://jqueryui.com/demos/sortable/ ). Is it possible to sort (move list)
Using jQuery Nearest Element , I would like to select elements in a circular
I'm using jQuery to move some elements on screen, however the animate function is
I'm using jquery sortable / serialize to reorder and move items between two lists,
I am using Jquery Drag and drop to move divs across a page and
I am using the jQuery DataTables plugin. I would like to move the search
using jquery's .post i send do my php code an object that with var_dump

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.