vrijdag 9 december 2011

Dynamic quick picks

Quick picks are those little red links with predefined values you see under (mostly) listboxes in the APEX builder.


They offer the user a flexibilty because the user can fill an item with a single click.Since APEX 4.0, you can easily add quick picks to your items by selecting "Yes" in the Show quick picks listbox in the Quick picks section of the item.


However, you can only add static data to the quick picks. Sometimes it would be very handy to make the quick picks dynamic. Let's say you have a CV application where you can add language skills to employees and suppose you want to have a language selectlist with quick picks of the 4 most used languages.

In 2008, long before APEX 4.0 was released, Anthony Rayner already wrote a blogpost about creating your own dynamic quick picks. Now, since APEX 4.0, you can create a plug-in for these kind of user-interface enhancements. In this blogpost I will show you how to do that.

Preparations:

We are going to use the following tables:

Table CBR_LANGUAGES:

LNG_ID           NUMBER(5)
LANG_DESCRIPTION VARCHAR2(20)

Table CBR_EMP_LANG:

ELG_ID NUMBER(5)
LNG_ID NUMBER(5)
SPEAK  VARCHAR2(30)
WRITE  VARCHAR2(30)
EMP_ID NUMBER(5)

sequence CBR_ELG_SEQ

Steps:

- Go to your application
- click on shared components
- in the user interface section, click plug-ins
- click the create button
- in the name section, enter a name for the plug-in, ie Dynamic quick pick, in the name text field
- in the internal name text field, enter a unique name, ie com.ciber.dynamic.quick.pick. This will be used internally by APEX
- in the type selectlist, make sure item is selected
- in the source section, enter the following code:

function render_quickpick (p_item                in apex_plugin.t_page_item
                          ,p_plugin              in apex_plugin.t_plugin
                          ,p_value               in varchar2
                          ,p_is_readonly         in boolean
                          ,p_is_printer_friendly in boolean )
return apex_plugin.t_page_item_render_result
is
  TYPE query_type  is REF CURSOR;
  TYPE query_type1 is REF CURSOR;
  c_query_cursor query_type;
  c_topn_query   query_type1;
  l_result       apex_plugin.t_page_item_render_result;
  l_query        apex_application_page_items.attribute_01%type := p_item.attribute_01;
  l_topn_query   apex_application_page_items.attribute_02%type := p_item.attribute_02;
  l_return       varchar2(20);
  l_display      varchar2(20);
  l_name         varchar2(30);
begin
  --
  -- get an APEX input name
  l_name := apex_plugin.get_input_name_for_page_item (p_is_multi_value => true );
  sys.htp.p('<select name="'||l_name||'" id="'||p_item.name||'" size="1" class="selectlist">');
  --
  -- create the selectlist
  open c_query_cursor for l_query;
  loop
    fetch c_query_cursor into l_display, l_return;
    exit when c_query_cursor%notfound;
    if l_return = p_value
    then
      sys.htp.p('<option value="'||l_return||'" selected="selected">'||l_display||'</option>');
    else
      sys.htp.p('<option value="'||l_return||'">'||l_display||'</option>');
    end if;
  end loop;
  sys.htp.p('</select>');
  sys.htp.p('<br/>');
  --
  -- The top-n query is optional, if empty, use the l_query
  if l_topn_query is null
  then
    l_topn_query := l_query;
  end if;
  --
  -- create the quick picks
  open c_topn_query for l_topn_query;
  loop
    fetch c_topn_query into l_display, l_return;
    exit when c_topn_query%notfound;
    sys.htp.p('<a href="javascript:$s('||''''||p_item.name||''''||','||''''||l_return||''''||','||''''||l_display||''''||');" class="itemlink">'||'['||l_display||']'||'</a>');
  end loop;
  --
  return l_result;
end render_quickpick;



- in the callbacks section, enter render_quickpick in the render function name text field
- in the standard attributes check the following attributes:

is visible
has element attributes
session state changeable
has source attributes
has width attributes

- click the create button but stay in the page.
- in the custom attributes section, click the add attribute button
- fill in the items with the following data:

scope: component
attribute: 1
display sequence: 10
Label: query
type: sql query
required: yes
minimum columns: 2, maximum columns:2


- click create and create another
- enter the following data:

scope: component
attribute: 2
display sequence: 20
Label: Top-N query
type: sql query
required: no
minimum columns: 2, maximum columns:2

- click create

The plug-in is ready. Now we will create a page that makes use of the plug-in.

- Go to the application builer and click the create page button.
- select form
- select form on a table or view
- in the table/view name selectlist, select cbr_emp_lang. click next
- click next
- select do not use tabs and click next
- click the radio button "select primary key" and in the primary key column 1 selectlist, select elg_id. click next
- select existing sequence and in the sequence selectlist, select cbr_elg_seq. click next
- transfer all columns to the right and click next
- click next
- enter pagenumber where APEX should navigate to when submitting or cancelling. You can also enter the same pagenumbers you are creating. click next
- click finish
- click edit page

Now we will include the plug-in into the application

- Click on the PXX_LNG_ID item (where XX is the page number)
- In the display as selectlist, select Dynamic quick pick [Plug-in]
- In the query text area (in the settings section), enter the following query:

SELECT LANG_DESCRIPTION D
,      LNG_ID R
FROM   CBR_LANGUAGES


- In the top-N query text area, enter the following query:

SELECT LNG.LANG_DESCRIPTION D
,      TOP_LNG.LNG_ID R
FROM   (SELECT LNG_ID
        ,      COUNT(LNG_ID) ORDERING
        FROM   CBR_EMP_LANG
        GROUP BY LNG_ID
        ORDER BY 2 DESC) TOP_LNG
,      CBR_LANGUAGES LNG
WHERE  TOP_LNG.LNG_ID = LNG.LNG_ID
AND    ROWNUM < 5


- click apply changes.

The page and the plug-in are ready. Click run to see the result.

47 opmerkingen:

  1. Very cool! Excellent plugin example too.

    BeantwoordenVerwijderen
  2. Everything is fine, am happy about your blog. Thanks admin for sharing the unique content, you have done a great job I appreciate your effort and I hope you will get more positive comments from the web users.
    Hadoop Training in Chennai
    Hadoop Training
    Best Hadoop Training in Chennai
    Best Hadoop Training Institute in Chennai

    BeantwoordenVerwijderen
  3. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    iOS Training in Chennai

    BeantwoordenVerwijderen
  4. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
    Digital Marketing Company in India
    seo Company in India

    BeantwoordenVerwijderen
  5. Very nice post here and thanks for latest smartphone applications it .I always like and such a super colors of phone for these post.Excellent and very cool idea and great models and different kinds of the more information's.

    Digital Marketing Course in Chennai

    BeantwoordenVerwijderen
  6. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Android App Development Company

    BeantwoordenVerwijderen
  7. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    iOS App Development Company
    iOS App Development Company

    BeantwoordenVerwijderen
  8. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text
    Mobile Marketing Services
    mobile marketing companies
    Sms API

    BeantwoordenVerwijderen
  9. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Mobile Marketing Service
    Mobile Marketing Companies
    Sms API
    Texting API

    BeantwoordenVerwijderen
  10. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Texting API
    Text message marketing
    Digital Mobile Marketing
    Mobile Marketing Services
    Mobile marketing companies
    Fitness SMS

    BeantwoordenVerwijderen
  11. Thank you for this article. I’m glad accesses the net this stuff works and your article has really helped me from beginning to end. And to share with you my thoughts.
    ECommerce Website developers in bangalore
    Outsource magento ecommerce services india

    BeantwoordenVerwijderen
  12. It is a great job that you are working and offer our necessary need to your posts. We like your job and wish you all the best.
    digital marketing company in india

    BeantwoordenVerwijderen


  13. In the last few months we've seen a lot of Health Care Reform rules and regulations being introduced by the Health and Human Services Department. Every time that happens, the media gets hold of it and all kinds of articles are written in the Wall Street Journal, the New York Times, and the TV network news programs talk about it. All the analysts start talking about the pros and cons, and what it means to businesses and individuals. Health is God

    BeantwoordenVerwijderen
  14. I think this is a real great article post.Really looking forward to read more. Visit at
    Crazy Video Hub

    BeantwoordenVerwijderen
  15. Nutra Trials defines personal characteristics of different health products including skincare, weight loss, muscle and male enhancement. The study presented here is briefly described for reader convenience and to deliver them assurance with health standards. The best possible answers are given here regarding the selection of an ideal supplement or cream or serum that possibly remains to be safe for health and do not cause any side effects.

    BeantwoordenVerwijderen
  16. It is a great job, I like your posts and wish you all the best. and I hope you continue this job well.
    NutraT line

    BeantwoordenVerwijderen
  17. This is a great post ! it was very informative. I look forward in reading more of your work. Also, I made sure to bookmark your website so I can come back later. I enjoyed every moment of reading it..
    kim kardashian sex tape
    porn sex video hd
    mia khalifa sex video
    sunny leone sexy movie

    BeantwoordenVerwijderen
  18. Hello, I am thomus jons thank you for this informative post. That is a great job. Wish you more success.Thank you so much and for you all the best. Takes Down
    123movies

    BeantwoordenVerwijderen
  19. It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.
    Java training in Pune

    Java interview questions and answers

    Java training in Chennai | Java training institute in Chennai | Java course in Chennai

    Java training in Bangalore | Java training institute in Bangalore | Java course in Bangalore

    BeantwoordenVerwijderen
  20. Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
    Best Devops Training in pune
    Devops interview questions and answers
    Devops interview questions and answers

    BeantwoordenVerwijderen
  21. Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
    python course in pune
    python course in chennai
    python Training in Bangalore

    BeantwoordenVerwijderen
  22. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read  about their market situation nowadays.
    python course in pune
    python course in chennai
    python Training in Bangalore

    BeantwoordenVerwijderen
  23. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.

    rpa training in chennai |best rpa training in chennai|
    rpa training in bangalore | best rpa training in bangalore

    BeantwoordenVerwijderen

  24. Healrun is a health news blog we provide the latest news about health, Drugs and latest Diseases and conditions. We update our users with health tips and health products reviews. If you want to know any information about health or health product (Side Effects & Benefits) Feel Free To ask HealRun Support Team.

    BeantwoordenVerwijderen

  25. Pilpedia is supplying 100 percent original and accurate information at each moment of time around our site and merchandise, and the intent is to improve the usage of good and pure health supplement. For More Info please visit Pilpedia online store.

    BeantwoordenVerwijderen
  26. We are here to give you a complete review on the Parallel Profit project by Steve Clayton and Aidan Booth. If you are someone from the field you would already be familiar with these two names, for those of who are new. Parallel Profits Review

    BeantwoordenVerwijderen
  27. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea.
    here by i also want to share this.
    Java training in Chennai

    Java training in Bangalore

    Java online training

    Java training in Pune

    BeantwoordenVerwijderen
  28. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea.
    here by i also want to share this.Java training in Chennai

    Java training in Bangalore

    Java online training

    Java training in Pune

    BeantwoordenVerwijderen
  29. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
    AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR

    BeantwoordenVerwijderen
  30. Best softwares for Internet Marketers and legitimate make money online opportunities cxyrc

    BeantwoordenVerwijderen
  31. This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.
    Thank you for this blog. This for very interesting and useful.
    Java training in Chennai
    Java training in Bangalore
    Java online training
    Java training in Pune
    Java training in Bangalore|best Java training in Bangalore

    BeantwoordenVerwijderen
  32. Trim Fit Keto affecting ketosis.3)CYCLICAL KETOGENIC weight-reduction plan- alternates durations of ketogenic dieting with periods of high carbohydrate intakeThe start of Ketogenic diets At first ketogenic diets were used to deal with obesity and epilepsy. In wellknown ketogenic diets are similar to hunger Visit for more info : - https://360nutra.org/trim-fit-keto/

    BeantwoordenVerwijderen
  33. Revuesdefaits defines personal characteristics of various health merchandise together with skincare, weight loss, muscle and male enhancement. The study presented here is briefly described for reader convenience and to deliver them assurance with health standards. The best potential answers are given here concerning the selection of a perfect supplement or cream or serum that presumably remains to be safe for health and do not cause any facet effects.

    http://revuesdefaits.fr/mara-nutra-garcinia/

    https://www.facebook.com/Revues-De-Faits-2466562093413723/

    BeantwoordenVerwijderen
  34. Tevida your health and protection.3. The subsequent group contains traction devices like penis enhancement extenders, pumps, and a few different devices. Vacuum pumps won't be safe, and not like "classic" extenders, vacuum pumps are too steeply-priced. Their results are not permanent. Vacuum Visit for more Info :- https://360nutra.org/tevida/

    BeantwoordenVerwijderen
  35. Tevida a tried and examined technique that combining male enlargement physical activities with natural and organic male expansion dietary supplements can produce some distance better consequences in lots quicker time length. The blessings for the use of all herbal male enhancement Visit for more Info :- https://360nutra.org/tevida/

    BeantwoordenVerwijderen
  36. Buyers Reviews defines personal characteristics of different health products including skincare, weightloss, muscle and male enhancement.Buyers Reviews is supplying 100% original and accurate information at each moment of time around our site and merchandise, and the intent is to improve the usage of good and pure health supplement.

    BeantwoordenVerwijderen
  37. InMotion Body Keto Flex best calorie degree is for his or her personal wishes, and they may be capable of gain their dreams, combining their consuming plan with exercising. Not simplest do they start to enjoy lifestyles again, however experience food and see weight loss!Despite the fact that fad weight Visit for more info :- https://360nutra.org/inmotion-body-keto-flex/

    BeantwoordenVerwijderen
  38. AlkaTone Keto additionally in protein. It also limits water intake to keep away from ketones' dilution and punctiliously controls calorie intake. The weight loss plan has been in life for the reason that Nineteen Twenties, whilst it turned into considered to be a step forward within the remedy of formative years Visit for more info :- https://timesnutrition.com/alkatone-keto/

    BeantwoordenVerwijderen
  39. InMotionBodyKetoFlex21 the fact we photograph weeks of living on cardboard-tasting meals with nary a crumb of something remotely scrumptious.If it really is you then you definately need to go with a diet regime that helps you to have treats - some thing those treats can be for.For More Info : https://360nutra.org/inmotion-body-keto-flex/
    InMotion Body Keto Flex

    BeantwoordenVerwijderen
  40. Keto Flex information? There may be no mystery weight loss program, there may be no unique sauce, and there is no mystery sauce "weight loss program"; dieting does not work. Quit weight-reduction plan now, today, be Visit for more info :- https://360nutra.org/inmotion-body-keto-flex/

    BeantwoordenVerwijderen
  41. Tevida and medicinal plant life that won't damage the body device in any way. Above something else, it's your protection that need to be your number one subject while looking for a male enhancement complement to purchase. It's also clever to speak to your Visit for more Info :- https://360nutra.org/tevida/

    BeantwoordenVerwijderen