Added orderable=true to Liferay search container, controls appeared but order does not change - liferay-6.2

I have written a Liferay search container, it works great.
Now I want columns to be sortable by alphabetical order, so I added orderable="true":
<liferay-ui:search-container
<liferay-ui:search-container-results
results="<%= BicycleLocalServiceUtil.getBicyclesByCompanyId(
themeDisplay.getCompanyId()) %>"
total="<%= BicyleLocalServiceUtil.getBicyclesCount() %>" />
<liferay-ui:search-container-row
className="com.example.portal.portlet.navigation.model.Bicycle"
keyProperty="bicycleId"
modelVar="bicycle"
escapedModel="<%= true %>">
<liferay-ui:search-container-column-text
name="name"
property="name"
value="<%= bicycle.getName() %>"
orderable="<%= true %>"
/>
<liferay-ui:search-container-column-text
name="nickname"
property="nickname"
orderable="<%= true %>"
/>
<liferay-ui:search-container-column-jsp
align="right"
path="/html/bicycle/bicycle_actions.jsp" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
The results looks good: but when I click on the name or any of the small arrows, the order of the rows below does not change.
Am I missing something?
I don't need any custom comparator as the value are simple Strings such as "Bob" and "Joe".

You need to specify the oderableProperty:
<liferay-ui:search-container-column-text
name="nickname"
property="nickname"
orderableProperty="nickname"
orderable="<%= true %>"
/>

Related

Conditional rendering in Spring in Action 4

I've been working on an example on conditional rendering from Spring in Action 4.
The code looks this way:
<sec:authorize access="hasRole('ROLE_SPITTER')">
<s:url value="/spittles" var="spittle_url" />
<sf:form modelAttribute="spittle" action="${spittle_url}">`
<sf:label path="text"><s:message code="label.spittle" text="Enter spittle:"/> </sf:label>
<sf:textarea path="text" rows="2" cols="40" />
<sf:errors path="text" />
<br/>
<div class="spitItSubmitIt">
<input type="submit" value="Spit it!" class="status-btn round-btn disabled" />
</div>
</sf:form>
</sec:authorize>
The question is what does the code attribute, namely label.spittle refers to? Does it refer to the modelAttribute from the form? Or does it mean that there should be message bundle with key label.spittle?
It means a key in a resource bundle (documentation):
<s:message code="label.spittle" text="Enter spittle:"/>

Allowing only digits in aui:form, with Liferay portlet-model-hints.xml

My portlet-model-hints.xml below stipulates that quantity is required, that works fine.
Now I also want to stipulate that quantity must be made of digits:
<model-hints>
<model name="com.example.model.MyEntity">
[...]
<field name="order" type="long">
<validator name="required" />
<validator name="digits" /> <----- Does not work
</field>
[...]
</model>
</model-hints>
PROBLEM: Adding <validator name="digits" /> makes the text field disappear.
Is there a problem in my syntax? Should I do the validation in the JSP instead? By the way here is the JSP form to add/edit my entity:
<aui:form action="<%= editMyEntityURL %>" method="POST" name="fm">
<aui:fieldset>
[...]
<aui:input name="quantity" />
[...]
</aui:fieldset>
[....]
</aui:form>
[Workaround, I am still looking for a better solution]
Not elegant at all, but moving digits validation to the JSP works:
<aui:form action="<%= editMyEntityURL %>" method="POST" name="fm">
<aui:fieldset>
[...]
<aui:input name="quantity">
<aui:validator name="digits"/>
</aui:input>
[...]
</aui:fieldset>
[....]
</aui:form>
It must be done in all JSP forms that use the entity.

Extraction Rule configuration in Visual Studio 2013 web performance tests

I've been following this guide to create my web performance tests in VS 2013 and I found interesting thing, which I am not sure how to understand.
I have a web application. On certain request this application returns me a page, where I have a span element which has style attribute, which is equal to "color:Blue;". In my performance test I go to that page and I have "Extract Attribute Value" extraction rule to get a value of style attribute of that span tag. When I configure my rule to get attribute style1 for that tag, the rule fails (which I expect to happen), but when I create a rule with match attribute value "c#l#r-BBBB", it doesn't fail (although, I expect it to fail).
Does anybody know why?
Here is the page source:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
<form method="post" action="Blue.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="QG+BA5tJt9bUUKK/SNJvCYaITvz71sZMdjWwNGygbhGjjs6Vy/29qy+kskbo3g4Vaz2Zfpi8hlr2F4g366EChHwtM2N676WWg0LBR3+9hc0=" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="D66C0198" />
</div>
<div>
<span id="Label1" style="color:Blue;">Blue</span>
</div>
</form>
</body>
</html>
These is the extraction rule in .webtest, that I expect to fail:
<ExtractionRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ExtractAttributeValue, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" VariableName="ExtractionTest" DisplayName="Extract Attribute Value" Description="Extract the value of an attribute from a specified HTML tag.">
<RuleParameters>
<RuleParameter Name="TagName" Value="span" />
<RuleParameter Name="AttributeName" Value="style" />
<RuleParameter Name="MatchAttributeName" Value="" />
<RuleParameter Name="MatchAttributeValue" Value="c#l#r-BBBB" />
<RuleParameter Name="HtmlDecode" Value="True" />
<RuleParameter Name="Required" Value="True" />
<RuleParameter Name="Index" Value="0" />
</RuleParameters>
</ExtractionRule>
I believe you need to specify vales for both the MatchAttributeName and the MatchAttributeValue properties. The documentation for the ExtractAttributeValue rule is not clear about what combinations of its properties are supported. However, I interpret the rule as saying: look for a TagName tag TagName where the attribute MatchAttributeName has the value MatchAttributeValue and from that tag return the value in AttributeName. Using that interpretation has always worked for me.
The documentation for AttributeName says that it "is used to identify the attribute whose value you want to extract", it does not say it is used to match any values. This documentation goes on to say that MatchAttributeName and (my emphasis) MatchAttributeValue are used in some cases.

sopt value to ignore case sensitivity

In my struts2jquery grid I've given
<sj:gridColumn name="processName" index="processName" title="Process Name" search="true" searchoptions="{sopt: ['bw','cn']}"/>
For sopt we've values like
{sopt:['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']}
Now I want to get the data in grid by ignoring the letter case. But it is filtering data if we search in the same way we stored. i.e; (say) If I stored data starting with 'D' it won't filter data starting with 'd'. How can I solve this. Is there any option for doing that?
this link should help you struts2 jquery plugin wiki grid.
you should define your own search action class to do the search. btw, it should be <sjg:gridColumn/> o_O
i found the solution with the JavaScript:
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<%# taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>
<div id="prije">Prije</div>
<s:url var="remoteurl" action="jsontable" />
<sjg:grid id="gridtableID"
caption="Primjer JSON TABELE"
dataType="json"
href="%{remoteurl}"
gridModel="gridModel"
viewrecords="true"
pager="true"
pagerPosition="centar"
navigator="true"
navigatorSearch="true"
filter="true"
filterOptions="{stringResult:true}"
loadonce="true"
>
<sjg:gridColumn name="id"
index="id" title="ID"
formatter="integer"
search="false"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"
editable="false" />
<sjg:gridColumn name="name" index="name" title="Name" sortable="true"
search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}" />
<sjg:gridColumn name="country" index="country" title="Country"
search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"/>
<sjg:gridColumn name="city" index="city" title="City" search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}" />
<sjg:gridColumn name="creditLimit" index="creditLimit"
title="Credit Limit" formatter="currency" search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"/>
</sjg:grid>
<script>
$(document).ready(function(){
$("#gridtableID").jqGrid('setGridParam', { ignoreCase: true});
});
</script>

Obtaining stray text adjacent to selected radio button using xpath in watir

I have some stray text next to radio buttons in a radio button group. I tried to obtain it using xpath and watir, but I had no luck with it. Here's some sample HTML for it
<html>
<head></head>
<body>
<input type="radio" name="options" value="No">No <br />
<input type="radio" name="options" value="Yes">Yes <br />
<input type="radio" name="options" value="Maybe">Maybe <br />
</body>
</html>
I can obtain the selected radio button using xpath by
selectedRadio = browser.radio(:xpath,"//input[#checked and #name='options']")
How can I obtain say Yes, No, Maybe if the corresponding radio buttons are selected? I also tried to obtain it using Watir, but the .text method would not work on the Watir::RadioButton object which would be true since the texts are stray texts.
Thanks in advance.
That HTML given is not well-formed XML, so I think the expression will depend on how Waitr parses the input. If it thinks that the text is a child of the input elements, like this:
<input type="radio" name="options" checked="checked" value="No">No </input><br />
<input type="radio" name="options" value="Yes">Yes </input><br />
<input type="radio" name="options" value="Maybe">Maybe </input><br />
Then use this expression:
//input[#checked and #name='options']/text()
If, on the other hand, it automatically closes the input and treats the text as a sibling, like this:
<input type="radio" name="options" checked="checked" value="No"/>No <br />
<input type="radio" name="options" value="Yes"/>Yes <br />
<input type="radio" name="options" value="Maybe"/>Maybe <br />
Then use the following expression:
//input[#checked and #name='options']/following-sibling::text()[1]
My guess is that this second one is the correct one, since you already said that .text did not work.
Ask the developer to make the page more testable by putting the text associated with the radio button inside a label associated with the button via an ID value
<form>
<input type="radio" name="sex" id="male" />
<label for="male">Male</label>
<br />
<input type="radio" name="sex" id="female" />
<label for="female">Female</label>
</form>
Then you can get the ID for the selected button, and find the associated label text fairly easily.
Seriously, it's a likely a lot easier for them to do that than it is for you to have to deal with sloppy page code. It also offers them a lot more formatting options (via CSS) to have that text inside a label container. Win all around.

Resources