How to get selected select2 value and use it in my java code


I’m coding a simple servlet plugin. I have a select2 list in my .vm which shows my project names. I want to get selected project name and show the issues inside it.

I need to get the project name and after that, I’ll find the project’s ID.

I wrote a code down below and I want to give project id as an function parameter. But I couldn’t figure it out how i can?

List<Long> currentIssueIds = projectManager.getIssueIdsForProject(PROJECTID);

Here is my select list.

<form id="admin" class="aui">
<label for="select2-example2">Choose a project:</label>
        placeholder="Select a project">
                #foreach( $pName in $pNames )
                    <option value="$pName"> $pName </option>

AJS.$("#select2-example2").auiSelect2({placeholder: "Select a project", allowClear: true});

Waiting for your help, thanks already.