Struts2 Select And if

Source: Internet
Author: User

<s:select name= "sel_%{#record. Onuid}" id= "sel_%{#record. Onuid}" value= "%{#record. Confirmed}" list= "#{' false ': ' Unconfirmed ', ' true ': ' Confirmed '} ' style= ' height:22px;width:70px;border:1px solid #BCD0DE; Border-right: #BCD0DE 1px solid; ' Onchange= ' Updateonu (%{#record. onuid}) '/>

="Label">

<s:if> usage
A: Direct Write expression
<s:set name= ' China ' value= ' China ' >
<s:if test= "${china== ' China '}" >show</s:if>
Result:show
<s:set name= "Count" value= ">"
<s:if test= "${count>0}" >bigger than 0</s:if>
<s:else>not</s:else>
Result:bigger than 0


B: Use judgment in traversal:
<s:iterator id= "id" value= "label" >
    <s:if test= "%{# Id.attrvalueid!=0} ">
        <s:property value=" #id. AttrValue "/>
                <s:property Value= "#id. Countall"/>                  <s:property value= "#id. Countrequest"/> 
    </s:if>
     <s:else>
        <s:property value= "#id. AttrValue"/ >
    </s:else>
</s:iterator>
Label is a list<attribu>  Attribu Contains properties Attrvalueid and Countall
within the S:iterator domain, which is the ID value of "id", and the way to traverse the object using OGNL Read is #id
test= "%{#id. attrvalueid!=0}" See if the child object's property Attrvalueid is 0
<s:property value= "#id. AttrValue/> Property of the print sub-object

C: Direct Read Object
<s:if test= "request.price==null| | Request.price<=0 ">
</s:if>
Read the object request to determine whether the price is less than 0;
How the request can be javabean, or it can be a basic property

D: Another way to read objects directly
<s:if test= "%{atransactionsummarybean!=null}" >
E: Judgment of multiple conditions
<s:if test= '%{isshowall== "Y" | | isshowall==null| | isshowall== ""} ' >
<li class= "Selected" >
</s:if>
<s:else>
<li>else
</s:else>
Isshowall is the string attribute inside the action

F: Take action directly inside the Boolean does not seem to Xing
Action inside
Private Boolean choosed = true;
public Boolean ischoosed () {
return choosed;
}
<s:if test= "choosed" ></s:if>
Found that this judgment does not work correctly, perhaps OGNL is to get the object through the Get method, if there is the following method in the action;
Public String getchoosed () {
Return "true";
}
The s:if above can be executed correctly.
Last note: OGNL and JSTL tags cannot be nested with each other

Struts2 Select And if

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.