:-[] :-|| Vivek Khokhar rambles here :-O :-[]

March 20, 2006

WickEnable Sugar

Filed under: sugar, php — Vivek Khokhar @ 3:10 pm

The purpose of this patch is to provide Dropdowns just like Google suggest, capability of using Dropdowns defined in sugar language, and or from a specific field of some some table in the database(not dynamic yet I am working on it).

Is it ajax ??

No. Its not.. simply because there is no need of that here, and I believe in doing whats best. Most of the Language arrays are static(less frequently updated)
Yes, I am working on Ajax Part it.. for fetching data from database(more frequently updated). for now there is a workaround for that, not truly real-time, but can be used in most of the cases.(Serves my purpose right now)
How to use it?

Download the file(WickEnablePatch For Sugar 4.0.1e) and apply it to your sugar installation via Upgrade WIzard (not module loader).

After Applying the patch above, Go To admin panel -> Repair -> Rebuild Wick Collection . This will Rebuild the collection.js file by putting all language arrays (mostly Dropdowns) from Language files.

If you want to use a values from a database table, just edit the vardef.php of the corresponding module as follows:

for example: If you wish to use Accounts->name as a dropdown, just edit vardef.php of Accounts. to make following changes

$dictionary[‘Account’] =

array(‘table’ => ‘accounts’,
‘audited’=>true,
‘fields’ => array (

‘name’ =>
array (   ‘name’ => ‘name’,
‘type’ => ‘name’,
‘wickEnabled’=>true, //add this item to every fielddef for which you want a dropdown
‘dbType’ => ‘varchar’,
‘vname’ => ‘LBL_NAME’,
‘len’ => 150,
),

….

….

After this again run admin panel -> Repair -> Rebuild Wick Collection. This will create a collection(array) in collection .js with accounts_name (tablename_fieldname)

Ok Collection is made now.. How to use it in HTML.. Very simple..

Open the HTML file where you wish the dropdown to show up. Lets say EditView.html of Contacts module. Lets make a text field for demo… lets say
input type=”text” class=”wickEnabled” collection=”account_name”
Thats it.. your drop down is ready. Now Save this template, and fire your browser. Try typing something in the field you just created. If there are accounts in your database they will populate the drop down as you type

In case of dropdowns from language files just change the collection name to some existing dropdown array name for example document_category_dom: collection=”document_category_dom” class=”wickEnabled”

Go to AdminPanel and Browse DropDown Editor.. for more better examples.

Thats all.

Main poins to remember:

- dont forget to rebuild collection after making changes to vardefs/language dropdown files.

- dont forget to add collection=”ur_collection_name” class=”wickEnabled” to your text boxes.

Questions are welcome..

Navigation in JSF

Filed under: java — Vivek Khokhar @ 8:48 am

Navigation Rules are specified in faces-config.xml by default.
However, you can assign any other name and even use more than one file to store JSF configuration data. To specify configuration files, use lines like the following in your web.xml file:

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-config2.xml</param-value>
</context-param>

Navigation rules are just like switch case constructs.

For example :

<navigation-rule>
<from-view-id>/pages/input.jsp</from-view-id>
<navigation-case>
<from-outcome>sayHello</from-outcome>
<to-view-id>/pages/greeting.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>sayGoodbye</from-outcome>
<to-view-id>/pages/goodbye.jsp</to-view-id>
</navigation-case>
<navigation-case>
<to-view-id>/pages/default.jsp</to-view-id>
</navigation-case>
</navigation-rule>

is similar in semantics to following Switch case

Switch(output from input.jsp){
case “sayHello”:
jump to /pages/greeting.jsp
break;
case “sayGoodbye”:
jump to /pages/goodbye.jsp
break;
default:
jump to /pages/default.jsp
break;

}

The <from-action></from-action> adds another level of checking while matching Navigation rules.
for example snippet below.. tells to jump to /pages/hello.jsp if hello was returned from GetSomeBean.someAction
<navigation-case>
<from-action>#{GetSomeBean.someAction}</from-action>
<from-outcome>hello</from-outcome>
<to-view-id>/pages/hello.jsp</to-view-id>
</navigation-case>
Here’s an excellent tutorial for this: http://www.jsftutorials.net/jsf-navigation-by-examples.html

Facelets Explored

Filed under: java — Vivek Khokhar @ 8:46 am

JSF’s Application includes:
a default ActionListener, ELResolver, StateManager, NavigationHandler, and ViewHandler.
Facelets is used as the application’s ViewHandler, represented by the class com.sun.facelets.FaceletViewHandler.

An excellent tutorial for kickstart
https://facelets.dev.java.net/nonav/docs/dev/docbook.html#gettingstarted-dependencies

Points to remember :

1. First you create a template file that will decide the layout of your page in a broader sense. or you can call it default view. Mostly using <ui:insert> tags that can be inserted or overwritten upon by child templates. For example: <ui:insert name=”leftPane”> will define a default leftpane html for your page

2. Next you define Child templates that will override the layout as per their need.
The <ui:composition> uses the template attribute to reference main template for look and feel of the page. Its like inheriting look and feel from a Default layout. This is really a powerful way of reusing UI.
If a child template doesn’t override the insertion point with the specified name (title or body), then the default text from the original template is used.

<ui:define> tags are specified with names that match the <ui:insert> tags used in the parent-template.
<ui:define name=”leftpane”> will replace <ui:insert name=”leftPane”> html definition.
This means that when Facelets builds your page, those blocks of content will be placed appropriately in the template. Any text that happens to reside inside the <ui:composition> tag, but outside of the <ui:define> tags is not displayed in the rendered output.

For example a child template for registration page:

<ui:composition template=”/Path-to/parent-layout.xhtml”>
<ui:define name=”leftpane”>
HTML for how left pane will look like in registration page
</ui:define>

This text will not appear in output because this is outside define block, you cannot write outside define blocks, it will be ignored.
</ui:composition>
This text will not appear in output because this is outside composition block, you cannot write outside define blocks, it will be ignored

3. Ok what if you want to print some attribute value of a bean.
In JSF you refer to the Beans as follows :
#{GetNameBean.helloAction} where helloAction is either getter function or someother public member function

March 15, 2006

Mysql Rails Windows

Filed under: Ruby — Vivek Khokhar @ 10:16 am

Ok Lets try ruby on rails, lots of hype around.

First of all followed the link, and did as said here
http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html

Hour 2

Ruby installed, rails installed. But not working with mysql. I am getting lost connection problem everytime I try to run the application.
Hour 3

Mysql Lost connection problem is solved by copying mysql.so from the rar file I got from following link
http://wiki.rubyonrails.org/rails/pages/HowToUseMySQLRubyBindingsOnWin32/versions/28

OR try this one: I havent tried it though
http://seagecko.org/thoughts/in-the-past/2004/09/09/ruby-mysql-and-windows/

Just copied mysql.so in #path-to-ruby#\lib\ruby\site_ruby\1.8\i386-msvcrt, restarted webserver, and it worked. Didnt Used other dlls in rar, dont think i need in my case. I am using 4.1.9-nt version of mysql

Understanding Processes

Filed under: Linux — Vivek Khokhar @ 6:39 am

Process attributes

    • Kernel orderly assigns a unique no. to every process that it creates (known as PID)
    • PPID is the PID of the parent from which the process was cloned. Cloning is generally the result of fork.
    • UID is the user identification number.(mostly same as EUID of parent) this one is there for identifying the owner of the process.
    • EUID is effective user id number of the process. Mostly same as UID of the process except in the case of setuid processes.
    • similar is the case with GID and EGUID.
    • “nice value” or “niceness” tells how nice the process is planning to be to other users of the system. High nice value means low priority. Range of values (-20 to +19)

    Signals

    • Signals are process level interrupt requests. About 30 diff kinds are defined. Each process may or may not define Signal handlers in its code. When a signal is recieved, one of the two things can happen:
      • If the recieving process has designated a handler routine for that particular sgnal, that handler is called with information about the context in which the signal was delivered
      • Otherwise, the kernel takes some default action for that Signal

    Specifying a handler is similar to “catching” a signal. A process can request kernel to ignore or request blockage of certain signals. But with one exception:

    The signals named KILL and STOP cannot be blocked / caught / ignored.(You see now how you are able to kill processes).

    Kill command is used to send signals to process.(any signal defined on your architecture..not just kill )

    syntax: kill - signal-no PID

    Following is the list of must know signals(brief :-) along with there signal-no:

    • TSTP - generated by terminal driver when you type CTRL+z - request to stop- may be ignored (thats why sometimes CTRL+z doesnt work :-)
    • INT (Interrupt) - generated by terminal driver when you type CTRL+c - request to stop -process can choose to ignore it/block it.
    • KILL (signal-no 9) - terminates the process at OS level, process never actually gets this signal - process has no control over this(poor soul)
    • TERM (signal-no 15) - Termination request - Again the process has control over it.
    • HUP (signal-no 1) - HangUp - General behavior of this Signal is to clean up(kill) all child process, re-read configuration files and make adjustments accordingly(of course if process is capable of doing this)– though a process can handle this in its own non-conventional way.

    If you dont know the PID of the process you want to kill you will normally use ps to find out the PID. There is one alternative though, and that is killall killall will do the lookup for you given just the “command name”

    /proc

    Each time a new process is created, an entry in /proc is created. The name of the directory entry corresponds to the process identification number (PID) of the created process. These directories store information about the running processes. more

    to be continued….

March 3, 2006

Javascript Fake window

Filed under: javascript — Vivek Khokhar @ 3:48 am

Javascript window.open returns an object that points to the newly open window. this is how you can make fake window objects to fool some page reloads :
Function dummyWindow will return a Window object whose reload doesn’t do anything

function _location(){
this.reload=_reload;
function _reload(){
return;
}
}
function dummyWindow(){
this.location = new _location();
}

Its a Hack but usefull in some scenarios

To kill all processes of a given user

Filed under: Linux — Vivek Khokhar @ 3:48 am

kill -9 `ps -u username -o “pid=”`

March 2, 2006

Welcome

Filed under: Uncategorized — Vivek Khokhar @ 9:40 am

Hi all,

Welcome to my Place.. :)

I will be using this place to store my Notes,articles,Tools which ofcourse are open for public share.

About me:

I am a software guy by profession, and have to deal with multitude of technologies/ tools during my work. Its very important to keep track of what you are doing, and for that I found Blogging a simple and effective medium.
About Wordpress:

I heard about this tool from my friend Sanoop, and I found it really good. Quick setup,Clean interface, Simple But powerful.

to be continued….

Powered by WordPress