highlight the text in multi-select list

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

highlight the text in multi-select list

pram0277
Hello All,

I am very new to DWR.
I have page which has 2 fields. One with user_ID as text field and other as a set of all available roles in multi-select list.
Now, suppose user is already having some roles. So, when I search the user using ajax, I want the roles, which is already associated to the user, to be highlighted in  multi-select list.
I tried but not able to do that. Could you please help me with the sample code which I can use.

Thanks in advance.

- Kumar
Reply | Threaded
Open this post in threaded view
|

Re: highlight the text in multi-select list

david@butterdev.com
You are posting to the incorrect mailing list.  The instructions on our
support page are pretty clear:
http://directwebremoting.org/dwr/support/index.html

This is not a good question as you are essentially telling us to write
code for you.

On 07/04/2012 01:37 AM, pram0277 wrote:

> Hello All,
>
> I am very new to DWR.
> I have page which has 2 fields. One with user_ID as text field and other as
> a set of all available roles in multi-select list.
> Now, suppose user is already having some roles. So, when I search the user
> using ajax, I want the roles, which is already associated to the user, to be
> highlighted in  multi-select list.
> I tried but not able to do that. Could you please help me with the sample
> code which I can use.
>
> Thanks in advance.
>
> - Kumar
>
> --
> View this message in context: http://dwr.2114559.n2.nabble.com/highlight-the-text-in-multi-select-list-tp7579780.html
> Sent from the DWR - Dev mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: highlight the text in multi-select list

cmontalvo
In reply to this post by pram0277
Hey kumar,

Why don't you provide the code you are using to see what you're doing wrong. This sounds like a very simple HTML case, you're probably missing something very small.

Chris

On Jul 4, 2012, at 12:37 AM, pram0277 <[hidden email]> wrote:

> Hello All,
>
> I am very new to DWR.
> I have page which has 2 fields. One with user_ID as text field and other as
> a set of all available roles in multi-select list.
> Now, suppose user is already having some roles. So, when I search the user
> using ajax, I want the roles, which is already associated to the user, to be
> highlighted in  multi-select list.
> I tried but not able to do that. Could you please help me with the sample
> code which I can use.
>
> Thanks in advance.
>
> - Kumar
>
> --
> View this message in context: http://dwr.2114559.n2.nabble.com/highlight-the-text-in-multi-select-list-tp7579780.html
> Sent from the DWR - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: highlight the text in multi-select list

pram0277
Hi Chris,

Sorry for the late reply.

In the JSP page, there is already roles displaying as "Senior Director, Director, Senior Manager, Manager, Senior Engineer,Engineer" etc in multi-select box.
Now, I am making a ajax call for the user. Based on the user role, I want the role ( can have more than one roles) to be selected (highlighted) for the user.

Thanks,
Kumar

Code details are as follows:
JSP Code:
    <tr>
        <td class="rightAligned"><fmt:message key="label.admin.search.for"/></td>
        <td colspan="3" id="userIdFaders">
            <input type="text" name="userId" id="userId" maxlength="20" size="50" class="form-autocomplete disableAutoComplete"/>
        </td>
    </tr>
    <tr>
        <td class="rightAligned"><fmt:message key="label.admin.assign.roles"/></td>
        <td id="rolesDiv">
            <select id="roles" name="roles" multiple="true" size="3" style="width:250">
                <jstl:forEach items="${roles}" var="role">
                    <option value="<jstl:out value="${role.key}"/>"><jstl:out value="${role.value}"/></option>
                </jstl:forEach>
            </select>
        </td>
    </tr>
   
    //ajax code...
    <ajax:autocomplete fieldId="userId" popupId="userNames" targetId="userId"
                       baseUrl="${pageContext.request.contextPath}/remoteViewer.view"
                       paramName="exec=getUsers&userName" className="autocomplete"
                       postFunc="selectUserData" progressStyle="throbbing" minimumCharacters="3"/>
                      
                      
Java Script Code:
    var selectUserData = function() {
        remoteAgent.selectUser(loadUser, DWRUtil.getValue("userId"));
    }

    var loadUser = function(userData) {
        DWRUtil.setValues("roles", userData.roles);
        Fat.fade_element("rolesDiv");
    }

Java Code:

AdminImpl.java

    public UserBean selectUser(String userId) throws DataAccessException {
        UserBean userBean = (UserBean) getSqlMapClientTemplate().queryForObject("selectUser", userId);
        userBean.setRoles(getRoles(userId));
        return userBean;
    }
    public List getRoles(String userId) throws DataAccessException {
        return getSqlMapClientTemplate().queryForList("getUserRoles", userId);
    }

admin.xml

    <select id="getUserRoles" resultClass="mappingHolder" parameterClass="java.lang.String">
        select
            rm.role_id key, rm.role_name value         
        from
            ROLE_MASTER rm, ALLOWED_ROLES ar       
        where
             rm.role_id = ar.role_id
             and ar.TXN_END is null
             and ar.user_id = #value#
        order by rm.role_id
    </select>

=============================


On Wed, Jul 4, 2012 at 9:28 PM, cmontalvo [via DWR] <[hidden email]> wrote:
Hey kumar,

Why don't you provide the code you are using to see what you're doing wrong. This sounds like a very simple HTML case, you're probably missing something very small.

Chris

On Jul 4, 2012, at 12:37 AM, pram0277 <[hidden email]> wrote:

> Hello All,
>
> I am very new to DWR.
> I have page which has 2 fields. One with user_ID as text field and other as
> a set of all available roles in multi-select list.
> Now, suppose user is already having some roles. So, when I search the user
> using ajax, I want the roles, which is already associated to the user, to be
> highlighted in  multi-select list.
> I tried but not able to do that. Could you please help me with the sample
> code which I can use.
>
> Thanks in advance.
>
> - Kumar
>
> --
> View this message in context: http://dwr.2114559.n2.nabble.com/highlight-the-text-in-multi-select-list-tp7579780.html
> Sent from the DWR - Dev mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://dwr.2114559.n2.nabble.com/highlight-the-text-in-multi-select-list-tp7579780p7579782.html
To unsubscribe from highlight the text in multi-select list, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: highlight the text in multi-select list

david@butterdev.com
As I previously mentioned - please do NOT use the dev list for these types of questions.  Secondly, this is a DWR list not a generic JavaScript/HTML list.  In the future please ask these types of generic questions on appropriate mailing lists.   

On Thu, Jul 26, 2012 at 10:55 PM, pram0277 <[hidden email]> wrote:
Hi Chris,

Sorry for the late reply.

In the JSP page, there is already roles displaying as "Senior Director, Director, Senior Manager, Manager, Senior Engineer,Engineer" etc in multi-select box.
Now, I am making a ajax call for the user. Based on the user role, I want the role ( can have more than one roles) to be selected (highlighted) for the user.

Thanks,
Kumar

Code details are as follows:
JSP Code:
    <tr>
        <td class="rightAligned"><fmt:message key="label.admin.search.for"/></td>
        <td colspan="3" id="userIdFaders">
            <input type="text" name="userId" id="userId" maxlength="20" size="50" class="form-autocomplete disableAutoComplete"/>
        </td>
    </tr>
    <tr>
        <td class="rightAligned"><fmt:message key="label.admin.assign.roles"/></td>
        <td id="rolesDiv">
            <select id="roles" name="roles" multiple="true" size="3" style="width:250">
                <jstl:forEach items="${roles}" var="role">
                    <option value="<jstl:out value="${role.key}"/>"><jstl:out value="${role.value}"/></option>
                </jstl:forEach>
            </select>
        </td>
    </tr>
   
    //ajax code...
    <ajax:autocomplete fieldId="userId" popupId="userNames" targetId="userId"
                       baseUrl="${pageContext.request.contextPath}/remoteViewer.view"
                       paramName="exec=getUsers&userName" className="autocomplete"
                       postFunc="selectUserData" progressStyle="throbbing" minimumCharacters="3"/>
                      
                      
Java Script Code:
    var selectUserData = function() {
        remoteAgent.selectUser(loadUser, DWRUtil.getValue("userId"));
    }

    var loadUser = function(userData) {
        DWRUtil.setValues("roles", userData.roles);
        Fat.fade_element("rolesDiv");
    }

Java Code:

AdminImpl.java

    public UserBean selectUser(String userId) throws DataAccessException {
        UserBean userBean = (UserBean) getSqlMapClientTemplate().queryForObject("selectUser", userId);
        userBean.setRoles(getRoles(userId));
        return userBean;
    }
    public List getRoles(String userId) throws DataAccessException {
        return getSqlMapClientTemplate().queryForList("getUserRoles", userId);
    }

admin.xml

    <select id="getUserRoles" resultClass="mappingHolder" parameterClass="java.lang.String">
        select
            rm.role_id key, rm.role_name value         
        from
            ROLE_MASTER rm, ALLOWED_ROLES ar       
        where
             rm.role_id = ar.role_id
             and ar.TXN_END is null
             and ar.user_id = #value#
        order by rm.role_id
    </select>

=============================


On Wed, Jul 4, 2012 at 9:28 PM, cmontalvo [via DWR] <[hidden email]> wrote:
Hey kumar,

Why don't you provide the code you are using to see what you're doing wrong. This sounds like a very simple HTML case, you're probably missing something very small.

Chris

On Jul 4, 2012, at 12:37 AM, pram0277 <[hidden email]> wrote:

> Hello All,
>
> I am very new to DWR.
> I have page which has 2 fields. One with user_ID as text field and other as
> a set of all available roles in multi-select list.
> Now, suppose user is already having some roles. So, when I search the user
> using ajax, I want the roles, which is already associated to the user, to be
> highlighted in  multi-select list.
> I tried but not able to do that. Could you please help me with the sample
> code which I can use.
>
> Thanks in advance.
>
> - Kumar
>
> --
> View this message in context: http://dwr.2114559.n2.nabble.com/highlight-the-text-in-multi-select-list-tp7579780.html
> Sent from the DWR - Dev mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://dwr.2114559.n2.nabble.com/highlight-the-text-in-multi-select-list-tp7579780p7579782.html
To unsubscribe from highlight the text in multi-select list, click here.
NAML



View this message in context: Re: highlight the text in multi-select list
Sent from the DWR - Dev mailing list archive at Nabble.com.