zwwcn

Just another WordPress.com site

Monthly Archives: May 2015

Zip4J bad crc error

I’m using Zip4J to compress images. The compression went properly but when I try to extract the images,  winrar gives me bad crc error. The problem is solved by changing the compression method to “store”:

parameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FAST);

Cannot delete or update a parent row: foreign key constraint fails

I had problem to delete a record, got the “foreign key constraint fails” error. We could temporately disable the foreign key check on MySQL, delete the wrong data, then change it back.

SET FOREIGN_KEY_CHECKS=0; — to disable foreign key check
SET FOREIGN_KEY_CHECKS=1; — to re-enable foreign key check

JSF execute javascript after ajax call

To Execute js script after the f:ajax call

<h:selectOneMenu id="checklist" value="#{checklistReportAction.checklist}" required="true">
      <s:selectItems value="#{checklistReportAction.checklists}" var="_checklist"
        label="#{_checklist.name}" noSelectionLabel="Select Checklist..."/>
        <s:convertEntity />							 	
	<f:ajax  render="filterPanel checklistFieldPanel" listener="#{checklistReportAction.selectListener}" event="change" execute="@this" onevent="showCheckBox"/>
	</h:selectOneMenu>

The above code will call showCheckbox function after user change value for the dropdown list