How to create & publish a web page with UI in Mashup environment

abhijit_k
User offline. Last seen 2 years 46 weeks ago. Offline
Joined: 11/12/2008
Points: 80

Hi

I was working on an assignment simillar to the documentation page of 'Adding custom mashlets dynamically'.  I created 4 mashlets and I want to display them on demand by user.  I created a folder 'employeedata' under tomcat server\webapps and added index.jsp file in this folder.  I shut down and restarted both the tomcat server and repository.  I logged into the presto login page.  Once I am onto our first page,  I added a tab and tried http://localhost:8080/employeedata as well as http://localhost:8080/employeedata/index.jsp as we do to access  other in built apps.  But these urls returned http status of 404, resource is not available and not the resultant output.  Please let me know how to create and implement a web page in mashup environment which can serve my purpose.  The code goes like this :

 

<html>
<head>

  
    <script type="text/javascript"
            src="http://localhost:8080/static/mashlet/js/mashlet-loader.js"></script>
    <script type="text/javascript"   
    chooseMashlet: function(mashletName) {
  //mashletName is mashlet instance name to load
 
      var config = {
      serverUrl: "http://localhost:8080",
      el: "mtarget",
      name: mashletName,
      args: { height: "auto", width: "auto", hideEdit: "true" },
      callback: {
          onSuccess: function(m){ //alert("mashlet loaded"); },
          onFailure: function(e) {
              this.handleException(e);
          },
          scope: this
      }
      }
      Ema.load(config);
    }
    </script>

</head>
<body>
  <div><p>Click a button to display a mashlet:</p>
    <ul>
      <li><button label="Admin"
        onclick="chooseMashlet('Presto.EmployeeData.AdminData')"/></li>
      <li><button label="Finance"
        onclick="chooseMashlet('Presto.EmployeeData.FinanceData')".></li>
      <li><button label="Aeon"
        onclick="chooseMashlet('Presto.EmployeeData.AeonData')"/></li>
    <li><button label="Hrms"
        onclick="chooseMashlet('Presto.EmployeeData.HrmsData')"/></li>

    </ul>
  </div>
  <div id=mtarget"></div>
  </body>
</html>
 

Thanks & Regards

Abhijit Kulkarni

 

 

0
Your rating: None
aishmishra
aishmishra's picture
User offline. Last seen 10 weeks 6 days ago. Offline
Joined: 09/24/2008
Points: 3

 

Hi Abhijit,

Looks like its a Tomcat related thing. You will need to create a WEB-INF folder in the folder that you have created - employeedata in this case. Copy web.xml from ROOT folder of webapps into the WEB-INF folder you just created. Things should work. Do let me know if it works.

 

abhijit_k
User offline. Last seen 2 years 46 weeks ago. Offline
Joined: 11/12/2008
Points: 80

Hi Aish Mishra

Your inputs bear the fruits.  They struck right into bull's eye.  Thanks for the reply.

Now I face one more issue.  I am not able to load mashlets dynamically which I want to show/hide as per user request.  I even tried logging out of Presto Mashup and relogin into it, but it does not make any difference.  The .jsp page opens with just 4 buttons and completes with 'Done' status on status bar.  But it does not display the four mashlets in 4 different divs.

Pleease do reply.  The code goes like this :

<html>
<head>

  
    <script type="text/javascript"
            src="http://localhost:8080/static/mashlet/js/mashlet-loader.js"></script>
   
    <script>
 var serverUrl = "http://localhost:8080/";
   

     Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.AdminData.Mashlet",
       el: "mt1"
     });
     Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.FinanceData.Mashlet",
       el: "mt2"
     });
    
   Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.AeonData.Mashlet",
       el: "mt3"
     });
 
   Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.HrmsData.Mashlet",
       el: "mt4"
     });

    }
    </script>

</head>
<body>
  <div id="msource"><p>Click a button to display a mashlet:</p>
    <ul>
      <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.AdminData')">Admin</button></li>
      <br/>
      <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.FinanceData')">Finance</button></li>
 <br/>
      <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.AeonData')">Aeon</button></li>
 <br/>
 <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.HrmsData')">Hrms</button></li>
 <br/>
    </ul>
  </div>
  <div id="mt1" style="display:block"></div>
  <div id="mt2" style="display:block"></div>
  <div id="mt3" style="display:block"></div>
  <div id="mt4" style="display:block"></div>

</body>
 

Thanks & Regards

Abhijit Kulkarni

 

 

 

 

 

 

 

threepointone
User offline. Last seen 2 years 22 weeks ago. Offline
Joined: 09/22/2008
Points: 1

Looks like there's an issue with the way your mashlets are being loaded. The mashlets are being loaded in a script in the head tag into divs that aren't available until the body is finished loading. here's a quick fix.

<html>
<head>

  
    <script type="text/javascript"
            src="http://localhost:8080/static/mashlet/js/mashlet-loader.js"></script>
   
    <script>

 

function startApp(){
 var serverUrl = "http://localhost:8080/";
   

     Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.AdminData.Mashlet",
       el: "mt1"
     });
     Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.FinanceData.Mashlet",
       el: "mt2"
     });
    
   Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.AeonData.Mashlet",
       el: "mt3"
     });
 
   Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.HrmsData.Mashlet",
       el: "mt4"
     });

    }

 

}
    </script>

</head>
<body onload="startApp();">
  <div id="msource"><p>Click a button to display a mashlet:</p>
    <ul>
      <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.AdminData')">Admin</button></li>
      <br/>
      <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.FinanceData')">Finance</button></li>
 <br/>
      <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.AeonData')">Aeon</button></li>
 <br/>
 <li><button onclick="javascript:chooseMashlet('Presto.EmployeeData.HrmsData')">Hrms</button></li>
 <br/>
    </ul>
  </div>
  <div id="mt1" style="display:block"></div>
  <div id="mt2" style="display:block"></div>
  <div id="mt3" style="display:block"></div>
  <div id="mt4" style="display:block"></div>

</body>

abhijit_k
User offline. Last seen 2 years 46 weeks ago. Offline
Joined: 11/12/2008
Points: 80

Hi

Thank you for your prompt reply.  The problem seems to be not that.  I tried with your onload but it did not work. I gave hello messages at the top & bottom of the script and they successfully popped up.   The error console is also empty.  Still the mashlets do not appear.  Kindly assist. 

Here the code goes

    <script type="text/javascript"
            src="http://localhost:8080/static/mashlet/js/mashlet-loader.js"></script>
   
<script>

    var serverUrl="http://localhost:8080/";
    alert("hello1");
     Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.AdminData.Mashlet",
       el: "mt1"
     });

Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.FinanceData.Mashlet",
       el: "mt2"
     });

 Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.AeonData.Mashlet",
       el: "mt3"
     });

Ema.load( {
       serverUrl: serverUrl,
       name: "Presto.EmployeeData.HrmsData.Mashlet",
       el: "mt4"
     }); 

alert("hello2");
</script>

Thanks & Regards

Abhijit Kulkarni

threepointone
User offline. Last seen 2 years 22 weeks ago. Offline
Joined: 09/22/2008
Points: 1

oh man, I should have spotted this. please remove the trailing '/' from your serverUrl . 

as in var serverUrl="http://localhost:8080/";

should be var serverUrl="http://localhost:8080";

 

also, I still recommend you do it the onload way if this throws errors. 

 

abhijit_k
User offline. Last seen 2 years 46 weeks ago. Offline
Joined: 11/12/2008
Points: 80

Hi

That was the perfect solution.  The change in URL worked.  Thank you very much.

Thanks & Regards

Abhijit Kulkarni