开发者

problem between selected s tag default value and chosen value

I have a OrganisationName select box in Edit/Add User Page.

<s:select key="user.organisationname" name="entity.or开发者_JAVA百科ganisationId" list="organisationList" listKey="organisationId" listValue="organisationName"></s:select>

I have two situations for Two Login User Type (System Admin & Organisation Admin).

1)Existing User, OrgnisationName will be displayed accordingly to his/her organisationId.

2)For New User, Login user can select any desired OrganisationName from the select box.

for System Admin, select box will display all Organisation Name. but for Organisatoin Admin, select box will display only his related Organisation Name.

My problem is I use if else to check whether the login user is System Admin or Org Admin.And I disabled the select box if the login user is Org Admin.

The problem starts from this point. When I disabled the select box, I can see the correct OrganisationName. but When I save the edited user, the organisationId returned from select box always become 0.

How can I pass the correct value even I disable the select box?

Another Question: Is there any way that to visible = "false" , similar property for select tag?

Thanks.


Make the <s:select /> readonly/unchangeable by

<s:select

    onfocus="this.defaultIndex = this.selectedIndex;"
    onchange="this.selectedIndex = this.defaultIndex;"
/>

OR

Enable a <s:select disabled="true" /> when the form is submit

<s:form onsubmit="document.getElementById('sltOrgAdmin').disabled = false">
    <s:select id="sltOrgAdmin" disabled="true" />
</s:form>

visible = "false" equivalent to visibility: hidden; in css

<s:select cssStyle="visibility: hidden;" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜