Comparing two string value values ​​in JSP - struts2

Thank you in advance for your time.

I need to pre-select the switch if it has a saved value. I need to compare 2 lines in the evaluation to determine this.

(I cannot use <s:radioat the moment because of some business rules that I need to attach based on other input elements in the form).

I tried to make the <s:setvalue of the stored identifier inside s:iterate, as shown below, and then compare them as shown below, but obviously I did not understand it.

<s:set var="savedId" value="%{flag.problemId}"/> 
              <s:iterator value="problemIdList"> 
                    <s:set var="currentId" value='<s:property value="id"/>' />                   
                        <s:if test="%{#currentId.equals(#savedId)}" >
                                <input checked="checked" type="radio" name="problemId" id="problemId" value='<s:property value="id"/>'/> <s:property value="description"/> <br/>
                        </s:if>
                <s:else>
                    <input type="radio" name="problemId" id="problemId" value='<s:property value="id"/>'/> <s:property value="description"/> <br/>
                </s:else>                       
             </s:iterator>

Basically, I need to compare two lines, my code is below. I know that I can not compare with equals (), as I have below - any ideas?

Thank!

<s:set var="savedId" value="%{flag.problemId}"/>  <s:iterator value="problemIdList">                                 
<s:if test=' <s:property value="id"/>.equals(<s:property value="savedId"/>) '>
    <input checked="checked" type="radio" name="problemId" id="problemId" value='<s:property value="id"/>'/>            <s:property value="description"/> <br/>
</s:if>
<s:else>
    <input type="radio" type="radio" name="problemId" id="problemId" value='<s:property value="id"/>'/>                     <s:property value="description"/> <br/>
</s:else>                       

Regards, VeeCan

+3
source share
2

:

<s:if test='id.equals(savedId)'>

"id" - , OGNL String.

+8

<s:iterator> <s:if> (ognl <s:if> <s:iterator>)

: , loadUserList - ( UserName Address) jsp,

     UserName:<s:property escape="false" value="userName" />
     Address:<s:property escape="false" value="address" />
     <s:if test='userName.equals("Admin")'>This is admin User</s:if>
     <s:else>This is not an admin user!</s:else>

OGNL s: if s: iterator

+1

Source: https://habr.com/ru/post/1792082/


All Articles