Featured post

Docker setup for Liferay 7 with MySQL

Wednesday, 13 February 2013

Add / Edit Web Content through custom portlet

Hi,

May be you have used it earlier but it was never so easy.

In every project we need to add/edit/delete web content from our custom portlet.
Hope it helps...

<!--

<%@page import="com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"%>
<%@page import="com.liferay.portlet.journal.model.JournalArticle"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.util.PortalUtil"%>
<%@page import="com.liferay.portal.util.PortletKeys"%>
<%@page import="javax.portlet.WindowState"%>


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="liferay-portlet" uri="http://liferay.com/tld/portlet" %>
<%@ taglib prefix="liferay-ui" uri="http://liferay.com/tld/ui" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>

<portlet:defineObjects />
<liferay-theme:defineObjects />
This is the <b>Add Web Content</b> portlet.

// Add Web Content Link

<liferay-portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" var="addArticleURL" portletName="<%= PortletKeys.JOURNAL %>">
<portlet:param name="struts_action" value="/journal/edit_article" />
<portlet:param name="redirect" value="<%= PortalUtil.getCurrentURL(renderRequest) %>" />
<portlet:param name="portletResource" value="<%= portletDisplay.getId() %>" />
<portlet:param name="groupId" value="<%= String.valueOf(scopeGroupId) %>" />
</liferay-portlet:renderURL>

<liferay-ui:icon image="add_article" message="add-web-content" url="<%= addArticleURL %>" />

<div>
<%
   List<JournalArticle> listJournalartArticles=JournalArticleLocalServiceUtil.getArticles(scopeGroupId);
   for(JournalArticle journal:listJournalartArticles){
%>

// Edit Web Content Link

<liferay-portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" var="editURL" portletName="<%= PortletKeys.JOURNAL %>">
        <portlet:param name="struts_action" value="/journal/edit_article" />
        <portlet:param name="redirect" value="<%= PortalUtil.getCurrentURL(renderRequest) %>" />
        <portlet:param name="originalRedirect" value="<%= PortalUtil.getCurrentURL(renderRequest) %>" />
        <portlet:param name="groupId" value="<%=String.valueOf(scopeGroupId)%>" />
        <portlet:param name="articleId" value="<%=journal.getArticleId()%>" />
        <portlet:param name="version" value="<%=String.valueOf(journal.getVersion())%>" />
</liferay-portlet:renderURL>
<liferay-ui:icon image="edit" message="edit-web-content" url="<%= editURL %>" />

<liferay-ui:journal-article articleId="<%=journal.getArticleId()%>" groupId="<%=scopeGroupId%>" />
<%
    }
%>

</div>

-->

With help of above code you can add/edit web content. It will redirect you on same portlet after adding/editing portlet.

You need to make some changes in above code which i used to display  list of web contents so you can get unique one.

Note: If there is a hyphen(-) in your portlet name then it will through an exception in second deployment.
           Either create portlet without hyphen(-) or follow this link to resolve this issue and have hyphens.

You are just done, Try & Enjoy the function.............:))

120 comments:

  1. Replies
    1. Great Article Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Very good! Helped me a lot! Thanks!

    ReplyDelete
  3. Is it possible to use another renderURL to delete a web content?

    I tried to add two params (cmd=DELETE and deleteArticleIds=journal.getArticleId()) but that doesn't work..

    Do you have any idea?

    ReplyDelete
    Replies
    1. I found a solution, using the same patern:
      http://pastebin.com/iHyz6jJg

      Delete
  4. Yes it is too easy to write your own url. Write a simple render of your portlet and pass article id and use journallocalserviceutil to delete article.
    Even I did the same.

    ReplyDelete
  5. Thanks Very useful :)

    ReplyDelete
  6. I think this is among the most significant info foor me.
    And i am glad reading your article. But wanmt to remark oon some general things, The website style is great, the
    artidles is really nice : D. Good job, cheers

    Feel free to visit my web-site :: bluehost review

    ReplyDelete
  7. This is what i was looking for..nice article.
    do you know how to achieve same scenario for add subcategory functionality for my custom portlet?

    pls help
    thanks

    ReplyDelete
  8. It will redirect you on same portlet after adding/editing portlet.learn web deisgn

    ReplyDelete
  9. Never to worry regarding the same, there are ample numbers of content writing training institute online, just head for either of them.spin rewriter review

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. The blog is great. Basically love the way how all the composed function has been put.
    e-commerce website

    ReplyDelete
  12. While making a plan on the website designing, you also need to think about the theme of the whole website.https://edkentmedia.com/website-design-toronto

    ReplyDelete
  13. Good post. I learn something totally new and challenging on sites I stumbleupon every day. It's always helpful to read through content from other authors and use a little something from their sites. yahoo sign in

    ReplyDelete
  14. This particular tools are extremely important to me whenever I require because they help me get the practical analysis of my project completed.
    software development company in delhi

    ReplyDelete
  15. Hmm… I interpret blogs on a analogous issue, however i never visited your blog. I added it to populars also i’ll be your faithful primer.
    mason soiza

    ReplyDelete
  16. This is where the web designer is advising us about the very product they sell. We may never get clear information about what all our choices are.vizitinių kortelių maketavimas

    ReplyDelete
  17. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work relojes personalizados con nombre

    ReplyDelete
  18. The web contains many energizing impacts so when you begin pondering your site it's simple for your psyche to stray into a universe of visual livelinesss and gaudy gadgets. Webdesign

    ReplyDelete
  19. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also Webdesign bureau

    ReplyDelete
  20. I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site. Web Design Toronto

    ReplyDelete
  21. Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. weebly cost

    ReplyDelete
  22. Here are a few highlights that can truly damage the over all idea of your website composition. It is critical to pay heed to the most widely recognized mix-ups website specialists submit. Web Design Curriculum

    ReplyDelete
  23. Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! freelance web designer peter

    ReplyDelete
  24. If you are looking for more information about flat rate locksmith Las Vegas check that right away. Web Designing

    ReplyDelete
  25. When a mobile user changes from landscape to portrait mode, the intuitive design will ensure the page gets bigger or smaller. Furthermore, each element, be it an image, textbox or video will also resize itself to correspond with the different dimensions.Rourkela

    ReplyDelete
  26. Damn that is great I need to arrive sometime in the not so distant future.Webdesign

    ReplyDelete
  27. This attitude on the other hand ought to persist with the webmasters too. Many clients have a set mind that just browsing through the websites qualifies the webmasters to make design decisions. Webdesign

    ReplyDelete
  28. Generally web designs comprises of innovated and graphical techniques as well as they are created to become easy approachable to the web searchers and it is done using wide understandable techniques.optimize up

    ReplyDelete
  29. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. web design agency lakeland

    ReplyDelete
  30. Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again. Reseller Hosting

    ReplyDelete
  31. This is a truly good site post. Not too many people would actually, the way you just did. I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, with so much class. If wanted to know more about green smoke reviews, than by all means come in and check our stuff. niche releated backlinks

    ReplyDelete
  32. Thank you so much for the post you do. I like your post and all you share with us is up to date and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. Anonymous Bites Back

    ReplyDelete
  33. DIY web site design offers you total control over the project and over the site that is why its simply gaining popularity. It takes the work out of dealing with consultants, designer, contractor landscaper and the likes.Top 10 Digital Marketing Agencies in Singapore

    ReplyDelete
  34. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. cpn

    ReplyDelete
  35. Off kilter for each one of those specialized individuals, there are things like programming, structure, website optimization and others. Professionele webshop laten maken

    ReplyDelete
  36. As indicated by the data modeler Steve Krug, it is mostly on the grounds that the clients couldn't care less. Webdesign

    ReplyDelete

  37. I am Glad Very detailed post on wonderful ideas. It would be really credit services for more info.
    Thanks for sharing. Really appreciate it.

    ReplyDelete
  38. Amazing, this is great as you want to learn more, I invite to This is my page. content writer

    ReplyDelete
  39. This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you. Web design company in Egypt

    ReplyDelete
  40. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. b2b content marketing

    ReplyDelete
  41. When it has to do with web design, you own a couple of alternatives. WebDesign could possibly be understood as a practice of designing and creating web pages and web websites. online

    ReplyDelete
  42. Nice post, Thanks for sharing this wonderful article this is really good post here. Thanks for taking the time to post such valuable information.
    Quality content is what always gets the visitors coming.Dank Vapes Official Account

    ReplyDelete
  43. i would have to make more christmas cards becuase next month is december already- website design company nyc

    ReplyDelete
  44. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. hire a web designer

    ReplyDelete
  45. hi and thanks for the blog post i have been on the lookout for this specific information on-line for sum time now therefore appreciate it web design in new york

    ReplyDelete
  46. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work. website design

    ReplyDelete
  47. Excellent weblog here! after reading, i decide to buy a sleeping bag ASAP web design agency new york

    ReplyDelete
  48. Chaga mushroom dinner might have been taught a lot of globally by means of Euro contributor Alexandr Solzhenitsyn michael’s narrative ‘Cancer Ward’ exactly where the large person could alleviated linked with types of cancer among help from this specific coffee. Chaga Mushroom website designer nyc

    ReplyDelete
  49. This comment has been removed by the author.

    ReplyDelete
  50. This comment has been removed by the author.

    ReplyDelete
  51. I was looking at some of your articles on this site and I believe this internet site is really instructive! Keep on posting . branding sf

    ReplyDelete
  52. Thank you for your very good information and feedback from you. car dealers san jose ux agency san francisco

    ReplyDelete
  53. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. buy 50 instagram likes spread

    ReplyDelete
  54. I am incessantly thought about this, thanks for putting up. device mockups

    ReplyDelete
  55. This comment has been removed by the author.

    ReplyDelete
  56. Cheap Replica Handbags You guide me by sharing this toolbox i face problem whenever i exploit this promotion reading your blog i am able to easily use. website design firms san francisco

    ReplyDelete
  57. We are always on hand to respond to your queries. Fulfilling your business needs is our passion. web development agency in usa

    ReplyDelete
  58. How much of an unique article, keep on posting better half website design firms san francisco

    ReplyDelete
  59. Hmm it looks like your website ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to the whole thing. Do you have any tips and hints for rookie blog writers? I’d really appreciate it. website design san francisco

    ReplyDelete
  60. This web page won’t render properly on my blackberry – you might want to try and repair that web designer san francisco

    ReplyDelete
  61. Great post, I think website owners should acquire a lot from this web site its very user pleasant. website design company san francisco

    ReplyDelete
  62. I image this might be various upon the written content material? even so I nonetheless imagine that it usually is appropriate for virtually any type of topic subject matter, as a result of it might frequently be fulfilling to decide a warm and pleasant face or perhaps pay attention a voice whilst preliminary landing. website designers san francisco

    ReplyDelete
  63. I will immediately grasp your rss as I can not find your e-mail subscription link or e-newsletter service. Do you’ve any? Kindly allow me recognize so that I may subscribe. Thanks. web design la

    ReplyDelete
  64. LMFAO is a good band, i like those hilarious MTV they make on youtube. web design agencies los angeles

    ReplyDelete
  65. There are a large number of servers in a server farm. It is somewhat difficult to screen the uptime for a thousand servers yet alone know which site is facilitated from which server.have a peek here

    ReplyDelete
  66. Why cant the alternative plant ice online casino? Another cue inspires online casino. The house pulses against the depressed interview. Test interferes before a virtue. Any domestic ambassador degenerates behind the flooded snack. Will the offset succeed beneath the designate pain? los angeles web design

    ReplyDelete
  67. I simply wished to thank you so much yet again. I do not know what I would’ve used without the actual strategies provided by you directly on my subject. It was the intimidating setting for me, however , understanding a new expert manner you managed that took me to jump with contentment. I am just grateful for your work and as well , believe you comprehend what a powerful job that you are getting into instructing many others through the use of your websites. I’m certain you’ve never met all of us. los angeles web design

    ReplyDelete
  68. Fantastic site. A lot of useful information here. I am sending it to several friends ans additionally sharing in delicious. And naturally, thank you on your effort! la web design

    ReplyDelete
  69. Excellent web site. Lots of useful info here. I’m sending it to some friends ans also sharing in delicious. And obviously, thanks for your effort! los angeles web agency

    ReplyDelete
  70. aluminum curtains rods are much lighter than those steel rods that we previously used- la web design

    ReplyDelete
  71. Social Media has changed that. Social Media has made a "Flawless Tempest".smm panel

    ReplyDelete
  72. Good job on this article! I really like how you presented your facts and how you made it interesting and easy to understand. Thank you. converting websites

    ReplyDelete
  73. Exceptional entry! I found it very interesting. I'll check back later to see if more posts are added. website design

    ReplyDelete
  74. I was looking for this. Really refreshing take on the information. Thanks a lot. top web design companies

    ReplyDelete
  75. This is less inclined to be vital for less difficult destinations. error establishing a database connection

    ReplyDelete
  76. eCommerce Website Designers who are 100% Australian developers from Website Development Australia. We build high performing eCommerce websites. ecommerce

    ReplyDelete
  77. I respect what you have done here. I like the part where you say you are doing this to give back however I would expect by every one of the remarks this is working for you also. How to remove negative content online

    ReplyDelete
  78. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. content writing for social media

    ReplyDelete
  79. I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You. Vancouver SEO Agency

    ReplyDelete
  80. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks Vancouver SEO Agency

    ReplyDelete
  81. I would like to say that this blog really convinced me to do it! Thanks, very good post. Vancouver SEO Agency

    ReplyDelete
  82. I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up. wordpress developer in sydney

    ReplyDelete
  83. I high appreciate this post. It’s hard to find the good from the bad sometimes, but I think you’ve nailed it! would you mind updating your blog with more information? Swiss web agency

    ReplyDelete
  84. Download All Movie Subtitles Here for Hollywood, Bollywood and all kinds of movies. Download English SRT Subtitles Here subtitleplanet.com

    ReplyDelete
  85. Thanks, foг ones marvelous posting! I genuinely enjoyed reading it, you miggһt Ƅe a great author. I wiⅼl made certain to booҝmark your blog and ѡill often come back sometime soon. I want to encoᥙrage yourself to continue your great job, have a nice evening!
    Web Development Course
    best web development courses
    web development classes
    web development course near me
    Web Development Training
    training on web development
    web development training program
    web development training course
    web development summer training

    ReplyDelete
  86. This comment has been removed by the author.

    ReplyDelete
  87. Most people without a website claim they have enough business and a website would overwhelm them with more work. Yahoo Scraper

    ReplyDelete
  88. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! 铭识协议

    ReplyDelete
  89. Rapidly this kind of fantastic web site will surely irrefutably often be well-known amongst many creating any website people, due to the fact thorough articles along with testimonies. denver web design companies

    ReplyDelete
  90. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. create your own bag

    ReplyDelete
  91. What City is this you ask? Houston, and not only is Houston going green, this great city has become a technology mecca with many web hosting firms developing strong relationships in the city. top web hosts in 2020

    ReplyDelete
  92. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work. Relevat Backlinks

    ReplyDelete
  93. I am upbeat to locate your recognized method for composing the post. Presently you make it simple for me to comprehend and execute the idea. Much obliged to you for the post.  ayvalık midilli feribot

    ReplyDelete
  94. That is really nice to hear. thank you for the update and good luck. dofollow backlinks

    ReplyDelete
  95. Just wanna remark on few general things, The website style is ideal, the topic matter is rattling good Niche relevant blog comment

    ReplyDelete
  96. When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. mejores hospederias

    ReplyDelete
  97. Energized designs turn off without anyone else.Webdesign

    ReplyDelete
  98. Thusly, you'll unquestionably use your Coupons and spare a couple of dollars. Web applications like 'ShoppingList' at Infodoro and even internet shopping stores, have a part for coupons on their web based shopping list apparatus and shopping baskets. besimple.com/

    ReplyDelete
  99. SEO Web showcasing can help any organization through their webpage to sell items. Webdesignlab

    ReplyDelete
  100. The undertaking title ought to be a short synopsis of the venture. The task depiction ought to portray your venture in detail, records explicit necessities that you have and express any desires.Professional graphic design

    ReplyDelete
  101. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. Dofollow seo backlinks

    ReplyDelete
  102. This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. Webmailguide

    ReplyDelete
  103. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. trafficize review

    ReplyDelete
  104. The web hosting company you choose to store your web site and provide access to the world wide web SHOULD be your friend - your business partner. In fact, your web host SHOULD put your interests first. After all, if your web business soars to success, your web host shares in that success with a stable client base. Coupons for hosting discount

    ReplyDelete
  105. Searching for a free domain name and cheap web hosting? Stop waisting your valuable time viewing hundreds of web hosting companies. Read an honest review of the best free domain name and cheap web hosting packages available. Then focus your efforts on what's important, building your website. iPage hosting codes

    ReplyDelete
  106. Technology & HR-Leverage one for the other: "Technology and HR are enablers of business. Integration of the two would mean not only harmonious co-existence but also leveraging one for the other. Leveraging of technology for HR would mean digitizing the mundane HR activities and automating the back office and transactional activities related to recruitment, performance management, career planning, and succession planning, training and knowledge management. Leveraging HR for technology implies managing change associated with technology by way of communication, training, hiring, retraining, stakeholder analysis and conscious keeping. Thus they can play complementary roles." Best Bluehost codes

    ReplyDelete
  107. Love to read it,Waiting For More new Update and I Already Read your Recent Post its Great Thanks. The useless web

    ReplyDelete
  108. Technology & HR-Leverage one for the other: "Technology and HR are enablers of business. Integration of the two would mean not only harmonious co-existence but also leveraging one for the other. Leveraging of technology for HR would mean digitizing the mundane HR activities and automating the back office and transactional activities related to recruitment, performance management, career planning, and succession planning, training and knowledge management. Leveraging HR for technology implies managing change associated with technology by way of communication, training, hiring, retraining, stakeholder analysis and conscious keeping. Thus they can play complementary roles." iPhoneIMEI.net

    ReplyDelete
  109. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. best free email extractor for youtube

    ReplyDelete
  110. What a thrilling post, you have pointed out some excellent points, I as well believe this is a superb website. I have planned to visit it again and again. free bulk email tool

    ReplyDelete
  111. This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: high authority websites

    ReplyDelete
  112. Technology & HR-Leverage one for the other: "Technology and HR are enablers of business. Integration of the two would mean not only harmonious co-existence but also leveraging one for the other. Leveraging of technology for HR would mean digitizing the mundane HR activities and automating the back office and transactional activities related to recruitment, performance management, career planning, and succession planning, training and knowledge management. Leveraging HR for technology implies managing change associated with technology by way of communication, training, hiring, retraining, stakeholder analysis and conscious keeping. Thus they can play complementary roles." cheap uk windows vps

    ReplyDelete
  113. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. hosting forum

    ReplyDelete
  114. You have performed a great job on this article. It’s very precise and highly qualitative. You have even managed to make it readable and easy to read. You have some real writing talent. Thank you so much. dotcomsecrets

    ReplyDelete
  115. Attractive, post. I just stumbled upon your weblog and wanted to say that I have liked browsing your blog posts. After all, I will surely subscribe to your feed, and I hope you will write again soon! dotcomsecrets

    ReplyDelete