Foren
Pop Up in a New Window
Ranen Das, geändert vor 11 Jahren.
Pop Up in a New Window
Regular Member Beiträge: 137 Beitrittsdatum: 06.04.11 Neueste Beiträge
Hello All,
I am trying to do a pop up edit in a portlet- I was able to do it using LR MVCPortlet, but in Spring Portlet, I am facing problem- problem is the row which I want to edit in a pop up window inside a Portlet is coming 2 times, here is the image file which will give you a clear idea and I appended the code also. Can someone suggest where am I wrong plz?
My env is LR 6.1+Tomcat
Regards,
RD
I am trying to do a pop up edit in a portlet- I was able to do it using LR MVCPortlet, but in Spring Portlet, I am facing problem- problem is the row which I want to edit in a pop up window inside a Portlet is coming 2 times, here is the image file which will give you a clear idea and I appended the code also. Can someone suggest where am I wrong plz?
My env is LR 6.1+Tomcat
Regards,
RD
view.jsp
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<%@page import="java.util.*"%>
<%
List<book> books = (List)request.getAttribute("BookList");
if(books !=null)
System.out.println("<<<<<< Books size >>>>>>>>>>>>>>>>> " + books.size());
%>
<%
PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/WEB-INF/jsp/view.jsp");
%>
<liferay-ui:search-container delta="4" iteratorurl="<%= iteratorURL %>" emptyresultsmessage="Sorry. There are no items to display.">
<liferay-ui:search-container-results total="<%= books.size() %>" results="<%= ListUtil.subList(books, searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row modelvar="book" classname="com.library.Book">
<liferay-ui:search-container-column-text name="Book Title" property="bookTitle" />
<liferay-ui:search-container-column-text name="Author" property="bookAuthor" />
<liferay-ui:search-container-column-jsp name="Actions" path="/WEB-INF/jsp/actions.jsp" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
</liferay-ui:search-container>
<br><a href="<portlet:renderURL/>">« Return to Previous Page</a>
actions.jsp
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.kernel.dao.search.ResultRow"%>
<%
Book book = new Book("Heat - How to play BB", "Lebron James", 1234);
PortletURL viewBookURL = renderResponse.createRenderURL();
viewBookURL.setWindowState(LiferayWindowState.POP_UP);
viewBookURL.setParameter("jspPage", "/WEB-INF/jsp/update.jsp");
viewBookURL.setParameter("bookId", String.valueOf(book.getBookId()));
viewBookURL.setParameter("showHeader", "false");
String popup = "javascript:popup('"+ viewBookURL.toString()+"');";
%>
<liferay-ui:icon-menu>
<liferay-ui:icon image="view" message="Popup in a New Window" url="<%= popup %>" />
</liferay-ui:icon-menu>
<aui:script>
Liferay.provide(
window,'popup',
function(url) {
var A = AUI();
var data = {};
var dialog = new A.Dialog(
{
centered: true,
destroyOnClose: true,
draggable: true,
height: 330,
width: 343,
resizable: false,
modal: true,
title: 'Book Details'
}
).render();
dialog.plug(
A.Plugin.IO,
{
data: data,
uri: url
}
);
},
['aui-dialog', 'aui-io']
);
</aui:script>
update.jsp
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<%
PortletURL updateBookURL = renderResponse.createActionURL();
updateBookURL.setParameter(ActionRequest.ACTION_NAME, "updateBook");
Book book = new Book("Thunder - How to play BB", "Durrant", 789);
%>
<aui:form name="fm" method="POST" action="<%= updateBookURL.toString() %>" onsubmit="<%= updateBookURL.toString() %>">
<aui:input type="hidden" name="redirectURL" value="<%= renderResponse.createRenderURL().toString() %>" />
<aui:input type="hidden" name="bookId" value="<%= String.valueOf(book.getBookId()) %>" />
<aui:input name="bookTitle" label="Book Title" value="<%= book.getBookTitle() %>" />
<aui:input name="bookAuthor" value="<%= book.getBookAuthor() %>" />
<aui:button type="submit" value="Save" />
</aui:form>
LibraryController.java
@Controller
@RequestMapping(value="/jsp/*")
public class LibraryController{
@RenderMapping
public ModelAndView render(RenderRequest request, RenderResponse response) throws IOException{
String jspPage= request.getParameter("jspPage");
List<book> books = new ArrayList<book>();
Book book0 = new Book("Heat - How to play BB by Lebron", "Lebron James", 1234);
Book book1 = new Book("Heat - How to play BB by Wade", "Dawyne Wade", 2345);
Book book2 = new Book("Heat - How to play BB by Chris Bosh", "Chris Bosh", 3456);
books.add(book0);
books.add(book1);
books.add(book2);
Map<string, object> model = new HashMap<string, object>();
model.put("BookList", books);
String jspName = null;
if(jspPage != null){
PortletRequestDispatcher dispatcher = request.getPortletSession().getPortletContext().getRequestDispatcher(jspPage);
try {
dispatcher.include(request, response);
//dispatcher.forward(request, response);
} catch (PortletException e) {
e.printStackTrace();
}
if(jspPage.equals("/WEB-INF/jsp/update.jsp"))
jspName= "update";
return new ModelAndView(jspName , model);
} else{
return new ModelAndView("view" , model);
}
}
</string,></string,></book></book></book>
Anhänge:
Ranen Das, geändert vor 11 Jahren.
RE: Pop Up in a New Window
Regular Member Beiträge: 137 Beitrittsdatum: 06.04.11 Neueste Beiträge
Here is the solution - Liferay Pop up in a new window with editable option using Spring API.....
Anhänge: