How to implement Save As Draft functionality in liferay 7 - java

I have a one HTML JSP form with accordion. I w want to implement a "Save as draft" feature in that form. Can any body help me?

Thanks I got the solution for this and thanks to you for response.
for this we have to set the status flag in the database. and liferay give the by default this method WorkflowConstant.STATUS_DRAFT by default it will take 2 check your status value if it is same then it will store in db as draft otherwise submitted.enter image description here

"Save as draft" simply means the workflow status is assigned the value of DRAFT. Portlets like WebContentDisplay know to only show journal articles that have APPROVED (published) status.
Correspondingly when you go to edit the article, it will pull the DRAFT version instead of starting a new edit.
So there is nothing magical here, it is just regular code to do the appropriate thing based upon the status of the entity.

Related

How can i get page URL in single-approver-definition.xml in Kaleo workflow in Liferay?

How can i get the page URL in single-approver-definition.xml in the e-mail template that is used to send an e-mail to the content creator once the reviewer approves or rejects the submission. The existing xml is as follows:
<template>
Your submission has been reviewed and the reviewer has applied the following:
${taskComments}.
</template>
I tried ${serviceContext.getAttribute("contentURL")} and it didn't work.
I want to be able to do - Your submission for ${pageURL} has been reviewed and the reviewier has applied the following: \n ${taskComments}.\n
Any suggestions will be appreciated.
I don't get what variable exactly you want to process in your notification. As I can only assume, you are using it for Web Contents and all interesting variables are stored in two places.
Workflow context variables - they are available directly. Few examples like:
${taskComments}
${entryType}
${userId}
${userName}
...
ServiceContext variables - they are available using $serviceContext. Few examples:
$serviceContext.getAttributes().get("version")
$serviceContext.getAttributes().get("articleId")
${serviceContext.getPortalURL()}
...
For all interesting variables check this url https://www.liferay.com/web/igor.beslic/blog/-/blogs/workflow-in-action-kaleo-workflow-context-variables Some could change already, however most of them is working fine for current version.
Content changes might be made on a page, they can also be triggered through Control Panel (or the API for that matter). When you're in a workflow, you typically don't have this context any more - if you find it somehow I'd not rely on it to be there. A workflow is unrelated to the UI and pages.
Also, an article might be submitted on one page, where it might be replaced/removed before it's even approved. In that case the link wouldn't help.
What might work is to check the concept behind "Web Content Display Pages" (if your article has them configured and you deal with web content). But the mechanics will vary depending on the actual content type you're dealing with. And content that goes through workflow might not be displayed on any page at all (e.g. when submitted through Control Panel) or on many different pages (either explicitly - Web Content Display - or implicitly - Asset Publisher).
#tomic basically provides pointers to what you have, I'm only reasoning why your initial problem is problematic to solve at best - it's not fully specifiable.

Push data from Servlet to webpage

Ok .. I think this question is dumb but its something I need so asking.
I have a servlet that checks health status of about 20-50 servers depending on situations.
I am trying to reduce the time to as low as possible but it still takes me 15-20 seconds to respond.
I am printing stuff on console for my satisfaction that the servlet isnt stuch but a user cant see that.
Is there any way I could print data on the requesting or a new page so that user knows that server isnt stuck - I dont wanna pass the request as there is still some processing to do.
I just want to print like I do in console. I checked System.setOut(PrintStream) but this also caries the data only after I pass request dispatcher - not good for me.
I am sorry if its a dumb question. I couldn't find a solution for my problem. Any help will be appreciated. Thanks in advance.
UPDATE: I am currently displaying a picture that says loading. But even if the server crashes the picture is still there. In my case its not true indication of servers state.
I think what you are looking for is supported by WebSockets, https://www.google.com/search?q=websockets.
You'll have to update your javascript, assuming your browser supports it, and then update your servlet code, and container to support. Jetty supports it, I'm not sure about the other containers.
Or alternatively, you could save your progress to a table or something and poll that data.
With the first request you could show a page with some kind of "please wait" indicator and do a second request that actually fetches the data (eg. via JavaScript).
Show a loading bar using javascript . This would tell the user that something is happening in the background .

Java - Dynamic dropdown to country/state

In my web-application I have a the following requirement.
I need to have a dropdown for country.
Based on the country selected I need to display the corresponding states.
I need to fetch both the country and state from database.
I cant use javascript since in production(live), javascript will be disabled.
I guess I have to use ajax to implement this?
Can anyone please tell if there is any better way to implement the above requirement?
I have seen the following link.
Populating cascading dropdown lists in JSP/Servlet
But I dont like to use javascript (since my client will disable javascript in Production environment)
I cant use javascript since in production(live), javascript will be disabled.
Can't use javascript than you would have to refresh the page i.e.:
Select Country from drop-down
Provide a link or button to submit this value (click on this)
Server call, which will retrieve the Country values and also the State values for the country selected
display the JSP with the values retrieved and make the Country which was submitted pre-selected in the drop-down.
I guess I have to use ajax to implement this?
Now my friend you are contradicting your own self, because ajax (I am sorry to say this) is nothing but javascript, it is not some different language than javascript.

Action in fb:request form is always null

UPDATE: this has just started happening again, would appreciate any help.
I am using server fbml to render an Invite Friends iframe and it was working fine up until two days ago. Basically, after submitting the form, a java action should be invoked where I get all the id's of the user's invited.
However, I now notice that an "invite by email" popup is showing up and, most importantly, my java action isn't being hit at all. When I inspect the form in firebug, I notice that the action is always empty (though all other parameters are preserved correctly).
I've tried setting email_invite=false on the multi-friend-selctor but to no avail.
My code looks like the following:
<fb:fbml>
<fb:request-form action="http://localhost:8080/myAction.do?method=someAction" method="POST" invite="false" target="_top" type="invite" content="CONTENT_GOES_HERE" >
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use our app." target="_top" email_invite="false">
</fb:request-form>
</fb:fbml>
</script>
Any help would be greatly appreciated on this.
UPDATE: this has just started happening again, would appreciate any help.
Thanks, gearoid.
Facebook have recently added an extra step into the multi-friend selector process, which is what you're seeing. There isn't, as far as I know, any way to stop this from appearing.
However, you should still be getting the result of the selector sent to you once the user navigates away from the "invite by email" popup.
Facebook's latest update can be seen in this status post.
To prevent that popup appearing add this attribute to the multi friend selector
import_external_friends="false"
Turns out this can happen a lot of different ways.
A) You can call FB.init multiple times
B) Call FB.init with the wrong key
C) You can supply a action that doesn't map to your current application on facebook
D) You or your staff can accidentially supply the same canvas/app url for two apps.
Most of of the solutions online point at A-C. When someone accidentally creates a second dev app pointing at localhost or 127.0.0.1 as the canvas url for multiple apps you admin you will get hosed. Took me hours upon hours to think to search our other apps. So i hope this saves someone a truck load of time. Cheers
I had an incorrect appId set in the fb-root javascript. This caused the error.

Clear HTTP Session

I am trying to clear everything on my HTML form when I visit it from a hyperlink entry.
Any ideas? My development language is java.
are you using session-scoped data? if so, close your browser and open it again.
I'm not sure the application is, but one way to accomplish this would be to use JavaScript. For example, if it is acceptable to clear the form every time that page is visited you could write a quick function that clears the form when the page is loaded (i.e., using the onload event).
If you only want to clear the form when the page is hit from that link you could add a param to the URL (e.g., clearForm=true) and use JavaScript to pick up the query string and clear the form when that parameter is present.
This is, of course, a purely client-side solution. For a server-side solution it would be helpful to know what framework you are using.

Categories