RE: Exception:Cannot make a static reference to the non-static method

thumbnail
4620263, modifié il y a 16 années. Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
hey

any one has seen this exception :

Cannot make a static reference to the non-static method setParameter(String, String) from the type PortletURL

I guess this is the line that declached this exception:

<%PortletURL portletURL=renderResponse.createRenderURL();
PortletURL.setParameter("struts_action","/html/portlet/ext/library/view.jsp");%>

I will give you the code of my view.jsp:
&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%&gt;

&lt;%@ include file="/html/portlet/ext/library/init.jsp" %&gt;


<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>


hiiiiiiiiiiiiiiiiiiii

<br>
Add a book entry to the Library:
<br><br>
<form action="<portlet:actionURL windowState=" <%="WindowState.MAXIMIZED.toString()" %>"&gt;<portlet:param name="struts_action" value="/ext/library/add_book" />" method="post" name="<portlet:namespace />fm"&gt;
Book Title:
<input name="<portlet:namespace />book_title" size="20" type="text" value=""><br><br>
<input type="button" value="Submit" onClick="submitForm(document.<portlet:namespace />fm);">
</form>

&lt;%PortletURL portletURL=renderResponse.createRenderURL();
PortletURL.setParameter("struts_action","/html/portlet/ext/library/view.jsp");%&gt;
&lt;% BookSearch searchContainer = new BookSearch(renderRequest, portletURL);//renderRequest??????????????????????????????????? List headerNames = searchContainer.getHeaderNames(); %&gt; <liferay-ui:search-form page="/html/portlet/ext/library/serach.jsp" searchContainer="<%= searchContainer %>" /> &lt;% BookSearchTerms searchTerms = (BookSearchTerms)searchContainer.getSearchTerms(); int total = BookLocalServiceUtil.searchCount(searchTerms.getId(),searchTerms.getTitle()); searchContainer.setTotal(total); List results = BookLocalServiceUtil.search( searchTerms.getId(), searchTerms.getTitle()); searchContainer.setResults(results); List resultRows = searchContainer.getResultRows(); for (int i = 0; i &lt; results.size(); i++) { Book book = (Book)results.get(i); ResultRow row = new ResultRow(book, book.getPrimaryKey().toString(), i); PortletURL rowURL = renderResponse.createRenderURL(); row.addText(book.getBookId(), rowURL); row.addText(book.getTitle(),rowURL); resultRows.add(row); } %&gt; <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" /> <liferay-ui:search-paginator searchContainer="<%= searchContainer %>" /> <br>




thanks
thumbnail
380705, modifié il y a 16 années. Regular Member Publications: 138 Date d'inscription: 09/01/08 Publications récentes
Hi,

Java basics is very week!.you are trying to use this code


PortletURL.setParameter("struts_action","/html/portlet/ext/library/view.jsp");


instead of


portletURL.setParameter("struts_action","/html/portlet/ext/library/view.jsp");


Before posting issues, please make sure you at least a basic review.


Regards,
Faisal.K
thumbnail
4620263, modifié il y a 16 années. Regular Member Publications: 126 Date d'inscription: 17/02/10 Publications récentes
yes you are absolutly right
I didnot notice the P
stupid mistake
thx
thumbnail
380705, modifié il y a 16 années. Regular Member Publications: 138 Date d'inscription: 09/01/08 Publications récentes
Hey Mistakes always happens, but be pro active!. some time we spend lot of time for such Typo errors.

Enjoy!