This discussion is archived
12 Replies Latest reply: Oct 11, 2012 8:29 AM by ryansun RSS

Is there an APEX_ITEM command for Buttons also? 4.1.0

ryansun Newbie
Currently Being Moderated
Ver: 4.1.0

Hi There,

For regular text,display and LOV type items we can use the APEX_ITEM procedures in a select and it works great. I had two questions,

1. For one of the fields in the select, I want to add a button next to it which would be used to submit the page and run a validation to check if the text item is correct against a table.
2. Is there a javascript command that can be put in that button when pressed that will submit the page and execute the validations, processes before it?

If this was a regular page item I could easily create a button next to it. But I am dynamically generating the form using the APEX_ITEM procedure so I cannot use the regular buttons from what I understand.

Any help please!

Thanks,
Sun
  • 1. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    VC Guru
    Currently Being Moderated
    No, you cannot and you don't need an api for that

    because APEX_ITEM API only supports the html input elements for buttons you would just add a dummy column and define a column link under the report column attributes for the same
  • 2. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    ryansun Newbie
    Currently Being Moderated
    Hi VC, In my case this is a PL/SQL region and so I don't have the "report" link that I can select to check the column attributes as is the case with the normal forms, reports in Apex. So you are saying I create a Dummy column in the SQL and define the header as a Hyperlink? In that case how and where do I put a page submit or some code that executes the validations or processes? Do you have any link to some documentation on this?

    Actually, even if its not a button, even if I can add some sort of javascript to the text field itself where if a user makes changes to item, it runs a validation against the table to see if its a valid item. So I can put that logic in a validation. I was not sure how to make a call to submit in javascript if this idea is even possible.

    Thanks

    Edited by: ryansun on Oct 11, 2012 6:45 AM
  • 3. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    VC Guru
    Currently Being Moderated
    ok.. in your pl/sql you can easily print the html as shown below
    //pl/sql
    htp.p('<a href="apex.submit('SAVE');"><img src="#IMAGE_PREFIX#edit.gif" alt=""></a>');
    
    //if you have a sql
    select 
    ...,
    ...,
    '<a href="apex.submit('SAVE');"><img src="#IMAGE_PREFIX#edit.gif" alt=""></a>' button
    from your_table
  • 4. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    ryansun Newbie
    Currently Being Moderated
    Thanks VC,

    So this SAVE is supposed to be an actual item? I get an error when I use it in PL/SQL
    ORA-06550: line 54, column 34: PLS-00103: Encountered the symbol "SAVE" when expecting one of the following: ) , * & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec as between from using || multiset member submultiset The symbol ", was inserted before "SAVE" to continue. ORA-06550: line 61, 
    
    {code}
    
    I tried using it within my existing PL/SQL code which is working fine 
    
    {code}
    select
    .
    .
    .
    .
    .
      apex_item.text(22,"NO_OF_LIC_UNITS") "NO_OF_LICES_UNITS",
                                    apex_item.date_popup(23,rownum,"LAST_CUST_PURCHASE_DATE",'DD-MON-RRRR') "LAST_CUST_PURCHASE_DATE"
            FROM competitor  WHERE SR_NO = TO_NUMBER(list_items(i))
                        )
                        
                        LOOP
                        htp.p('<table class="tbl-body" align="left"> <tr bgcolor="white" align="left" vlign="left">
                        <tr bgcolor="white"><th class="header" align="right"><br><br></th><td align="left"></td></tr>                    
                        <tr bgcolor="white"><th class="header" align="right">Install Status</th><td align="left">'||k.INSTALL||'<a href="apex.submit('SAVE');"><img src="#IMAGE_PREFIX#edit.gif" alt=""></a></td></tr>
                        <tr bgcolor="white"><th class="header" align="right">Pillar</th><td align="left">'||k.PILL||'</td></tr>
                        <tr bgcolor="white"><th class="header" align="right"> Product</th><td align="left">'||k.PRODUCT_NAME||'</td></tr>
    .
    .
    .
    .
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • 5. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    VC Guru
    Currently Being Moderated
    No, SAVE will be the request set to when you click that button. (that's just an example and you can do whatever you want on the onclick)

    see this http://www.w3schools.com/tags/att_a_href.asp
    select
    .
    .
    .
    .
    .
      apex_item.text(22,"NO_OF_LIC_UNITS") "NO_OF_LICES_UNITS",
                                    apex_item.date_popup(23,rownum,"LAST_CUST_PURCHASE_DATE",'DD-MON-RRRR') "LAST_CUST_PURCHASE_DATE"
            FROM competitor  WHERE SR_NO = TO_NUMBER(list_items(i))
                        )
                        
                        LOOP
                        htp.p('<table class="tbl-body" align="left"> <tr bgcolor="white" align="left" vlign="left">
                        <tr bgcolor="white"><th class="header" align="right"><br><br></th><td align="left"></td></tr>                    
                        <tr bgcolor="white"><th class="header" align="right">Install Status</th><td align="left">'||k.INSTALL||'<a href="apex.submit(''SAVE'');"><img src="#IMAGE_PREFIX#edit.gif" alt=""></a></td></tr>
                        <tr bgcolor="white"><th class="header" align="right">Pillar</th><td align="left">'||k.PILL||'</td></tr>
                        <tr bgcolor="white"><th class="header" align="right"> Product</th><td align="left">'||k.PRODUCT_NAME||'</td></tr>
    .
    .
    .
    .
    please note the two quotes around SAVE
  • 6. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    ryansun Newbie
    Currently Being Moderated
    So the first part worked great!

    1. I can see a blue edit button, is there by any chance an update one also?
    2. When I hit the button it submits and the URL in the address bar changes to http://thewebsitename/apex/apex.submit('SAVE');

    So, how do we capture this SAVE state so that we can run the validations and secondly, why doesn't the page refresh and return to the same page? Like a standard page submit with no branches?

    Thanks
  • 7. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    VC Guru
    Currently Being Moderated
    apex.submit...
    //just add javascript: before it
    javascript:apex.submit.....
  • 8. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    ryansun Newbie
    Currently Being Moderated
    Thanks VC. That also worked

    Now this is getting down to hand holding quite literally.

    Now for validations, I don't see this item in the options because I guess this item is created at run time. So if I have to now run some validations and processes based on the submit,

    1. How would I pass the value of that item and how can I create a validation and process? Would all of this have to be done in Javascript? Not familiar with that.
    2. Basically, I was looking at the standard process. E.g lets say I have the employee form which has emp no and emp name. When the user enters a emp no and hits this button using the above mentioned logic, the emp name should be populated.

    IS this going to be a complex thing to do?

    Thanks
  • 9. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    VC Guru
    Currently Being Moderated
    ryansun wrote:
    Thanks VC. That also worked

    Now this is getting down to hand holding quite literally.

    Now for validations, I don't see this item in the options because I guess this item is created at run time. So if I have to now run some validations and processes based on the submit,

    1. How would I pass the value of that item and how can I create a validation and process? Would all of this have to be done in Javascript? Not familiar with that.
    2. Basically, I was looking at the standard process. E.g lets say I have the employee form which has emp no and emp name. When the user enters a emp no and hits this button using the above mentioned logic, the emp name should be populated.

    IS this going to be a complex thing to do?

    Thanks
    Is it a simple form or a tabular form?

    can you explain in more detail what you are trying to achieve...probably setup an example on apex.oracle.com
  • 10. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    ryansun Newbie
    Currently Being Moderated
    Its a simple form. This is what I have done so far,

    1. Created a tabular report on one page with a checkbox and some javascript which takes the row selected in a javascript function and opens a new page where the whole form is rendered dynamically using pl/sql (APEX_ITEM) .Eg, I have a page listing all employees, I select one employee and hit the edit button it brings me to this page where I have that one record in edit mode. So user can update, change, delete that record.

    2. So in this case if user enters a new employee number, it should go against the employee table and see if it exists and raise an error if not. This is very simple in the regular page where we can add a item, button. But in this case where we generate it dynamically, I was able to submit the page by what you provided, but after that, I wanted to also capture the value of install field and then validate it against the table.

    Does that make sense?

    Thanks
  • 11. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    VC Guru
    Currently Being Moderated
    for this simple requirement why are you doing all this dynamically??

    why don't you Just create a form region on that table instead of creating html dynamically
  • 12. Re: Is there an APEX_ITEM command for Buttons also? 4.1.0
    ryansun Newbie
    Currently Being Moderated
    So from the first page when the user selects multiple records using a check box, all those records need to be passed to the other page which will show only those records in tabular format.

    Any suggestions on how do we pass the set of records to the edit page such that all the selected records are shown in a tabular format?

    Still learning as I experience new requirements in Apex.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points