tag:blogger.com,1999:blog-21122514.post6718503152680888271..comments2024-03-23T11:05:13.046+01:00Comments on Dimitri Gielis Blog (Oracle Application Express - APEX): JSON for APEX Developers (part 2)Dimitri Gielishttp://www.blogger.com/profile/16295721159626839167noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-21122514.post-84348955887561889112016-02-08T21:40:52.816+01:002016-02-08T21:40:52.816+01:00You can also use APEX JS function $s() to set the ...You can also use APEX JS function $s() to set the value for the page item. Below is what I tried:<br /><br /> $('#P11_EMPNO').val(json.items[0].empno); //using jQuery val function to set value<br /> $s('P11_ENAME', json.items[0].ename); //using APEX javascript API $s() to set the value<br /><br />KevinKevin Zhanghttps://www.blogger.com/profile/16905246845885902585noreply@blogger.comtag:blogger.com,1999:blog-21122514.post-56571218209381042172016-02-08T21:38:48.146+01:002016-02-08T21:38:48.146+01:00Also, you can try use APEX's JavaScript functi...Also, you can try use APEX's JavaScript function $s() to set the value for the page item. <br /><br />Below is what I tried ... it is always good to know there are multiple ways to do it. <br /><br /><br /><br /> $('#P11_EMPNO').val(json.items[0].empno); //using jQuery val function to set value<br /> $s('P11_ENAME', json.items[0].ename); //using APEX javascript function $s() to set the value<br /><br /><br /><br />Cheers,<br /><br />KevinKevin Zhanghttps://www.blogger.com/profile/16905246845885902585noreply@blogger.comtag:blogger.com,1999:blog-21122514.post-75483678818397755192015-05-21T09:46:41.754+02:002015-05-21T09:46:41.754+02:00HI Mike,
If you hit the TEST button in your webse...HI Mike,<br /><br />If you hit the TEST button in your webservice you see the url you should use.<br /><br />Hope that helps,<br />DimitriDimitri Gielishttps://www.blogger.com/profile/16295721159626839167noreply@blogger.comtag:blogger.com,1999:blog-21122514.post-85732174244605504492015-05-20T23:48:24.893+02:002015-05-20T23:48:24.893+02:00Exactly, Dmitri! Thank you. I suspected it might b...Exactly, Dmitri! Thank you. I suspected it might be the Display type, but I was misreading the generated html. I'm also learning about the Console, and one of the sessions I heard today pointed me, in a round-about way, to P1_EMPNAME_DISPLAY. I knew the javascript innerHTML(), and then found jQuery's .html(). Now it works!<br /><br />My only remaining question was posted on your previous blog: If I duplicate your emp_json web service in my apex.oracle workspace, what URL do I use to call it?<br /><br />- MikeMikenoreply@blogger.comtag:blogger.com,1999:blog-21122514.post-37699204924341104402015-05-20T22:41:29.991+02:002015-05-20T22:41:29.991+02:00Hi Mike,
Probably because it's a display only...Hi Mike,<br /><br />Probably because it's a display only item... if it's a text item it should work.<br />If you want display only you need to check with the console how the field is called and probably use $('#P1_EMPNAME').html(json.items[0].ename)<br /><br />Hope that helps,<br />DimitriDimitri Gielishttps://www.blogger.com/profile/16295721159626839167noreply@blogger.comtag:blogger.com,1999:blog-21122514.post-9097074243726769962015-05-20T20:20:27.951+02:002015-05-20T20:20:27.951+02:00Dmitri -
Thanks for the simple example. Learning ...Dmitri -<br /><br />Thanks for the simple example. Learning Apex is a very slow process when you are the only one around who is using it. I appreciate that you gave a location on the page to put the getJSON function because it's not obvious to a newby. <br /><br />But what about the jQuery to set P10_EMPNO and P10_ENAME? I put this in the 'Execute when Page Loads' section:<br />$.getJSON("https://www.apexrnd.be/ords/training/emp_json/", function(json) {<br /> console.log(json);<br />$('#P1_EMPNO').val(json.items[0].empno);<br />$('#P1_EMPNAME').val(json.items[0].ename);<br />alert($('#P1_EMPNAME').val());<br />});<br /><br />My page items are named slightly differently (obviously on page 1, not page 10, and empname not ename). And the alert does display SMITH, so the value appears - on page load - to be obtaining data from the JSON object. But the value is not displayed on the page itself, in the Display Item P1_EMPNAME. It's label is there, but the value is not. Where is Apex resetting the value that is set on page load?<br /><br />Thanks,<br />MikeMikenoreply@blogger.com