• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfmessagebox

Contributor ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Hello,
I'm trying to use cfmessagebox.
I found an example but nothing happens.
Where is the error? Is it compatible with all browsers?
Thank you for your help.

 

 

<head>
<cfset msg="Avant de nous donner vos desideratas, nous avons besoin de mieux vous connaître.">
<script type="text/javascript"> 
function showMB(mbox) { 
ColdFusion.MessageBox.show(mbox); 
} 
</script> 
</head> 
 
<body>
<cfform> 
<cfinput type="image" name="choix" onclick="showMB('mymessagebox')" value="Alert" src="../_Pictures/Complements.gif" align="absmiddle" callbackhandler="http://www.solivres.com/Admin/_ebooks/indexSolivres.cfm" modal="true"> 
</cfform> 

<cfmessagebox name="mymessagebox" type="alert" message="#msg#" /> 
 
</body>

 

 

 

Views

393

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Oct 06, 2020 Oct 06, 2020

Hello,
Indeed, it is easier in Javascript!
I find it unfortunate that Adobe (or some other company!) Doesn't provide a library of includes which will avoid reinventing the wheel all the time.
Here is the first:

<head>
 <script type="text/javascript"> 
   function showMB(msg) {
     if ( alert(msg)) {
       <CFLOCATION url="#direct#">}
   } 
 </script>
</head> 
	 
<body>
  <cfform> 
     <cfinput type="image" name="choix" onclick="showMB('#msg#')" value="Alert" src="#bouton#" align="absmiddle">
  </
...

Votes

Translate

Translate
Contributor ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

No answer ?

Help me please.

Thank you in advance.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

I'm sorry in advance, but I don't think you're going to like my answer, which is: learn JavaScript instead. The JS UI components in CF are old and unreliable, and you'll need to know JS anyway to do anything useful with them.

 

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

I agree with Dave Watts.

 

I've replaced CFMessageBox with SweetAlert2.  It's more complicated to integrate (compared to some of the CFUI tags), but's it's more future proof regarding device/browser compatibility and is actively developed.
https://sweetalert2.github.io/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2020 Sep 24, 2020

Copy link to clipboard

Copied

You need something to create an event. So replace 

<cfinput type="image" 

with

<cfinput type="button" 

 In any case, follow the advice from Dave and Jamo. ColdFusion UIs, such as cfmessagebox, are out of date.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 06, 2020 Oct 06, 2020

Copy link to clipboard

Copied

Hello,
Indeed, it is easier in Javascript!
I find it unfortunate that Adobe (or some other company!) Doesn't provide a library of includes which will avoid reinventing the wheel all the time.
Here is the first:

<head>
 <script type="text/javascript"> 
   function showMB(msg) {
     if ( alert(msg)) {
       <CFLOCATION url="#direct#">}
   } 
 </script>
</head> 
	 
<body>
  <cfform> 
     <cfinput type="image" name="choix" onclick="showMB('#msg#')" value="Alert" src="#bouton#" align="absmiddle">
  </cfform>
</body>

Thank you all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2020 Oct 06, 2020

Copy link to clipboard

Copied

LATEST

ZNB, Adobe DID provide such a library. It's what made the cfmessagebox (and several other CFML UI tags) work. 

 

The problem with that approach is that the libraries often either changed quickly (perhaps for addressing security reasons), or got dropped by the vendor (because this world of JS-based UI elements has been evolving and changing for 2 decades).

 

So nearly everyone--or at least everyone who was concerned about the above issue--has spent the better part of the past two decades complaining that Adobe should in fact never have put in such libraries, and that instead people SHOULD "just do it themselves".

 

Here you see the conundrum: a total "damned if they do, damned if they don't" situation.

 

FWIW, the very reason your initial cfmessagebox failed is likely because in CF2018 and after a certain update in CF2016 as well, Adobe REMOVED the old library (yui) that was underlying its functionality. In the CF docs on "deprecated features", they tell folks how they can add it back. But you will be adding back an old library that the vendor (yahoo) no longer supports at all.

 

Could Adobe have instead designed the whole UI tag featureset in such a way that folks could plug in "more modern versions" of the libraries they used? Sure. That would have been brittle--because the vendor could change something that would now make existing CF code break. And it would have been expensive, if they then had to deal with fixing issues in CF that now failed with those later libraries.(Some might even wish that they could let folks plug in ANY UI library, but there's no way that could have been expected to work.)

 

Adobe opted instead to keep things at a stable base, for those who wanted these tags...but again there was always an outcry from certain quarters that Adobe shouldn't be providing such "training wheels"--or worse, "a gun with which folks could shoot themselves". Not everyone agreed with that assessment, and I can tell you that many, many people are still using these UI tags today, after "putting the libraries back in". To each, their own.

 

You have come to the result that most would want: find and use a JS UI library that works for you.

 

As for the hope that anyone will ever make that easier, I doubt it. There are just too many concerns to be managed.

 

Hope that's helpful. (I know it's WAY more than most would want to hear/read, but given your last question, it seemed a reply that was warranted.)


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation