Skip to main content

Posts

Showing posts from May, 2016

IOS Swift2 push view up when showing keyboard and prevent black screen while navigating inside keyboard panel

override func viewDidLoad() {         super.viewDidLoad()         NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.keyboardWillShow), name: UIKeyboardWillShowNotification, object: nil)         NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.keyboardWillHide), name: UIKeyboardWillHideNotification, object: nil)     }     func keyboardWillShow(notification: NSNotification) {         if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() { // below condition will prevent black screen             if self.view.frame.origin.y >= 0{                self.view.frame.origin.y -= keyboardSize.height             }         }     }     func keyboardWillHide(notification: NSNotification) {         if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {             self.view.frame.origin.y += keyboardSize.heigh

Liferay JSF pdf downloading from stream best practice

    in  the java class public StreamedContent getPdfFile() throws Exception { FacesContext facesContext = FacesContext.getCurrentInstance();    PortletResponse portletResponse= (PortletResponse)facesContext.getExternalContext().getResponse();    ResourceResponse portletResourceResponse = (ResourceResponse) portletResponse;    portletResourceResponse.setContentType("application/pdf"); /*the following line is very important */    portletResourceResponse.flushBuffer();    OutputStream out = portletResourceResponse.getPortletOutputStream();    out.write(PdfGenerator.pdfFromHtmlContent(content);    out.flush();    facesContext.responseComplete(); return null } --------------------------------------------------------------------------------------------------------- in the xhtml page <p:commandButton value="download PDF" ajax="false">    <p:fileDownload value="#{ph.pdfFile}" /> </p: