azizkhani.net

I know that I know nothing

tinymce Editor

clock June 20, 2015 21:00 by author Administrator

if you use tinyMCE  in ajax you will use mce api to get content and set content 

this example show how can use it 

function loadComplete(entity){

       if(tinyMCE.get('editor')!=null)

             tinyMCE.get('editor').setContent(entity.informationText); 

}

function beforeSave(entity){

        tinyMCE.triggerSave();

        entity.informationText=$('#txt_editor').val();

         return entity;

 

}

<form id="frm_main" data-options="onLoadComplete:loadComplete,beforeSave:beforeSave'">

    <textareaid="editor"data-bind="informationText"  class="editor"style="height: 200px;direction: rtl" ></textarea>

</form>



remote debug in tomcat

clock May 9, 2015 19:12 by author Administrator

add this line jvm args

-agentlib:jdwp=transport=dt_socket,address=1499,server=y,suspend=n"



create jndi in tomcat

clock May 9, 2015 18:55 by author Administrator

Create META-INF/context.xml

<Context  docBase="appName" path="/" reloadable="true" >

    <Resource name="develop" auth="Container" type="javax.sql.DataSource" maxActive="50        
          maxIdle="30" maxWait="10000" username="test"    password="test"

        driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@192.168.36.250:1521:XE" />

</Context>

 

web.xml configuration

 

<resource-ref>
        <description>jdbc Datasource example</description>
        <res-ref-name>develop</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>



The value of attribute "formula" must not contain the '<' character.

clock May 8, 2015 12:43 by author Administrator

hibernate formula dosenot allow user < in select for example i use this formula and get this exception

  <property name="debitPrice"  not-null="true"   formula="(  select nvl(sum(d.cost_price),0) from ihs_flat_cost_assign d where d.flat_id=Id  and d.cost_price <=0   )  "   />

 

and i change that to this

        <property name="debitPrice"  not-null="true"   formula="(  select nvl(sum(d.cost_price),0) from ihs_flat_cost_assign d where d.flat_id=Id  and 0>=d.cost_price    )  "   />

and problem solve

crazyyyyy bug i dont know whyyyyy



send email after commit using spring transaction

clock May 6, 2015 21:22 by author Administrator

Sometimes you want a little more control over transaction but at the same time you don't want to switch to programmatic transaction management. I'm talking about cases when you want to execute some activities only when transaction was completed successfully. For example: send an email with registration details, update a cache, send a message over network, etc. The tricky part here is that you want to perform these activities from a transactional method (a method marked with @Transactional which automatically will start and end the transaction).

 

@Component
public class AfterCommitExecutorImpl extends TransactionSynchronizationAdapter implements AfterCommitExecutor {
    private static final Logger LOGGER = LoggerFactory.getLogger(AfterCommitExecutorImpl.class);
    private static final ThreadLocal<List<Runnable>> RUNNABLES = new ThreadLocal<List<Runnable>>();

    @Override
    public void execute(Runnable runnable) {
        LOGGER.info("Submitting new runnable {} to run after commit", runnable);
        if (!TransactionSynchronizationManager.isSynchronizationActive()) {
            LOGGER.info("Transaction synchronization is NOT ACTIVE. Executing right now runnable {}", runnable);
            runnable.run();
            return;
        }
        List<Runnable> threadRunnables = RUNNABLES.get();
        if (threadRunnables == null) {
            threadRunnables = new ArrayList<Runnable>();
            RUNNABLES.set(threadRunnables);
            TransactionSynchronizationManager.registerSynchronization(this);
        }
        threadRunnables.add(runnable);
    }

    @Override
    public void afterCommit() {
        List<Runnable> threadRunnables = RUNNABLES.get();
        LOGGER.info("Transaction successfully committed, executing {} runnables", threadRunnables.size());
        for (int i = 0; i < threadRunnables.size(); i++) {
            Runnable runnable = threadRunnables.get(i);
            LOGGER.info("Executing runnable {}", runnable);
            try {
                runnable.run();
            } catch (RuntimeException e) {
                LOGGER.error("Failed to execute runnable " + runnable, e);
            }
        }
    }

    @Override
    public void afterCompletion(int status) {
        LOGGER.info("Transaction completed with status {}", status == STATUS_COMMITTED ? "COMMITTED" : "ROLLED_BACK");
        RUNNABLES.remove();
    }

}

 

example:

final String email = user.getEmail();
            afterCommitExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    mailService.sendMail(email, "CreateUser", params, "templates/email/CreateUser.ftl");
                }
            });



Socrates

clock May 2, 2015 22:09 by author Administrator

“I’m the smartest man in Athens because I know that I know nothing.” —Socrates 470-399 BC



jsoup: Java HTML Parser like jquery

clock May 2, 2015 19:01 by author Administrator

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.

example

String userURL = "http://azizkhani.net/admin/Posts/Add_entry.aspx";

content of this request contain this tag

 

<input type="text" id="txt_title" value="title"  />
Document doc = Jsoup.connect(userURL).get();

doc.getElementById("txt_title").val();



 http://jsoup.org/cookbook/extracting-data/selector-syntax

 



What's the difference between <%@ include file="header.html" %> and <jsp:include page="header.jsp" />

clock April 9, 2015 21:18 by author Administrator

 

 

1) The include directive: <%@ include file="header.html" %>

Static: adds the content from the value of the file attribute to the current page at translation time. The directive was originally intended for static layout templates, like HTML headers.
2) The <jsp:include> standard action <jsp:include page="header.jsp" />

Dynamic: adds the content from the value of the page attribute to the current page at request time. Was intended more for dynamic content coming from JSPs.
3) The <c:import> JSTL tag: <c:import url=”http://www.example.com/foo/bar.html” />

Dynamic: adds the content from the value of the URL attribute to the current page, at request time. It works a lot like <jsp:include>, but it’s more powerful and flexible: unlike the other two includes, the <c:import> url can be from outside the web Container!

 

ref :http://stackoverflow.com/questions/14580120/whats-the-difference-between-including-files-with-jsp-include-directive-jsp-in

 



get Locale in java

clock April 9, 2015 20:24 by author Administrator

   System.out.println(Locale.getDefault());

   en-us



create custom dependency in maven

clock April 9, 2015 18:33 by author Administrator

mvn install:install-file -Dfile=/azizkhani/font.jar -DgroupId=org.roshan  -DartifactId=font -Dversion=1 -Dpackaging=jar



About the author

 Welcome to this web site . This page has two purposes: Sharing information about my professional life such as articles, presentations, etc.
This website is also a place where I would like to share content I enjoy with the rest of the world. Feel free to take a look around, read my blog


Java,J2EE,Spring Framework,JQuery,

Hibernate,NoSql,Cloud,SOA,Rest WebService and Web Stack tech...

RecentPosts

Month List

Sign In