Saturday, 25 July 2015

Selected CheckBox Deactivate Or Delete

FORM from Ekhub Project:




<aui:form method="post" name="fm" action="<%=studentAssignURL.toString() %>">
<aui:input name="studentIds" type="hidden" />
<liferay-ui:search-container delta="5"
emptyResultsMessage="Sorry. There are no students in the Course.."
iteratorURL="<%=iteratorURL%>"
rowChecker="<%=new RowChecker(renderResponse)%>">
<liferay-ui:search-container-results
results="<%=ListUtil.subList(courseStudents, searchContainer.getStart(), searchContainer.getEnd())%>"
total="<%=courseStudents.size()%>" />

<liferay-ui:search-container-row
className="com.ekhub.servicelayer.model.CoursePurchasedStudent"
modelVar="coursePurcahsedStudent" keyProperty="userId">
<liferay-ui:search-container-column-text property="userId"
name="Student Id" />
<%
User user1 = null;
if(coursePurcahsedStudent.getUserId() > 0){
user1 = UserLocalServiceUtil.getUser(coursePurcahsedStudent.getUserId());
System.out.println("user1>>>>>"+user1);

%>
<liferay-ui:search-container-column-text name="Student Name"
value="<%=user1.getFullName() %>" />
<liferay-ui:search-container-column-text name="Student Email"
value="<%=user1.getEmailAddress() %>" />
<%
long studentId = user1.getUserId();
studentAssignURL.setParameter("studentIds", String.valueOf(studentId));
System.out.println("studentId>>>>>>"+studentId);
}else{ %>
<liferay-ui:search-container-column-text name="Student Name"
value="<%=coursePurcahsedStudent.getEmail() %>" />
<liferay-ui:search-container-column-text name="Student Email"
value="<%=coursePurcahsedStudent.getEmail() %>" />
<%
studentAssignURL.setParameter("studentIds",  String.valueOf(coursePurcahsedStudent.getUserId()));
}

%>

<% if(EKHubUtil.hasPermissions(themeDisplay.getUserId(),themeDisplay.getCompanyId(),EKHubPropsValues.Ekhub_Assign_Students_to_Exam)){ %>
<liferay-ui:search-container-column-text name="Assign"
href="<%=studentAssignURL.toString()%>" value="Assign" /><%} %>
</liferay-ui:search-container-row>

<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
</liferay-ui:search-container>
<aui:button value="Assign Selected Students"
onClick='<%= renderResponse.getNamespace() + "assignStudents();" %>' />

</aui:form>









SCRIPT :


Liferay.provide(
window,
'<portlet:namespace />assignStudents',
function() {

var accepted = confirm('<%= UnicodeLanguageUtil.get(pageContext, "Are you sure you want to assign the selected students?") %>');

if (accepted) {
var frm = document.<portlet:namespace />fm;
 var hiddenField = frm.<portlet:namespace />studentIds;
 hiddenField.value = Liferay.Util.listCheckedExcept(frm, "<portlet:namespace />allRowIds") ;
 alert(hiddenField.value);
 submitForm(frm);
  }

},
['liferay-util-list-fields']
);

Tuesday, 7 July 2015

Liferay Tabs Search container pagination

question_list.jsp 

String tabNames = "Active Questions,InActive Questions";
String tabs1= ParamUtil.getString(request,"tabs1", "Active Questions");

    Object ob = request.getAttribute("selectedTab");
    String value ="Active Questions";
    if (ob != null) {
    value = (String) ob;
    tabs1 = value;
    }


PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("action", "questionlist");

<liferay-ui:tabs
   names="<%= tabNames %>"
   url="<%= iteratorURL.toString() %>"  
   param="tabs1"
   value="<%=tabs1 %>"
  >
    <liferay-ui:section>
     <c:if test='<%= tabs1.equalsIgnoreCase("Active Questions")%>'>

      <liferay-ui:search-container delta="10" emptyResultsMessage="Sorry" iteratorURL="<%= iteratorURL %>">
      .........
      .........
      </c:if>
      </liferay-ui:section>

      
     <liferay-ui:section>
     <c:if test='<%= tabs1.equalsIgnoreCase("InActive Questions")%>'>

      <liferay-ui:search-container delta="10" emptyResultsMessage="Sorry" iteratorURL="<%= iteratorURL %>">
      .........
      .........
      </c:if>
      </liferay-ui:section>


In controller QuestionController.java

@RenderMapping(params = "action=questionlist")  
    public String questionListMethod(RenderRequest request, RenderResponse response)
    { 
        String selectedTab= ParamUtil.getString(request,"tabs1");

        if(selectedTab!=null && !("".equalsIgnoreCase(selectedTab))){
        request.getPortletSession().setAttribute("selectedTab", selectedTab);
        request.setAttribute("selectedTab", selectedTab);
        }else{
        selectedTab = (String)request.getPortletSession().getAttribute("selectedTab");
        request.setAttribute("selectedTab", selectedTab);
        }
       
        return "question_list"; 
    }