473,594 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript question on displaying contents of a webpage in a portlet

I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)
if (cityName.toLow erCase() ==
cityName[i].cityName.toLow erCase())
{
open (weatherURL);
break;
}

var cityName = [
{ cityName: 'austin',
weatherURL: "austin.htm l" },
{ cityName: "albany",
weatherURL: "albany.htm l" },
{ cityName: "amsterdam" ,
weatherURL: "amsterdam.html " },
{ cityName: "beijing",
weatherURL: "beijing.ht ml" },
{ cityName: "berlin",
weatherURL: "berlin.htm l" }

];
</script>
Thanks!
Brie

Feb 9 '06 #1
4 1971

Brie wrote:
I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)
i < cityName ?

1. You're using cityName before you even have it defined.
2. You're comparing a number to an object.

You probably really meant this:

for(var i = 0; i < cityName.length ; i++)
if (cityName.toLow erCase() ==
cityName[i].cityName.toLow erCase())


Now you've confused me. Do you have in your form an element with the
name "cityName" ? The expression on the left hand side makes me assume
so. In which case, you should then access it properly:

if(document.for ms["formName"].elements["cityName"].value.toLowerC ase()
== ...)

And finally, where is your script defined? The way it is at the
moment, it'll execute right away. Meaning, since it's not contained in
a function and you're waiting for a response from the user, it's
useless.

Feb 9 '06 #2

Brie wrote:
I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)
i < cityName ?

1. You're using cityName before you even have it defined.
2. You're comparing a number to an object.

You probably really meant this:

for(var i = 0; i < cityName.length ; i++)
if (cityName.toLow erCase() ==
cityName[i].cityName.toLow erCase())


Now you've confused me. Do you have in your form an element with the
name "cityName" ? The expression on the left hand side makes me assume
so. In which case, you should then access it properly:

if(document.for ms["formName"].elements["cityName"].value.toLowerC ase()
== ...)

And finally, where is your script defined? The way it is at the
moment, it'll execute right away. Meaning, since it's not contained in
a function and you're waiting for a response from the user, it's
useless.

Feb 9 '06 #3

web.dev wrote:
Brie wrote:
I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)


i < cityName ?

1. You're using cityName before you even have it defined.
2. You're comparing a number to an object.

You probably really meant this:

for(var i = 0; i < cityName.length ; i++)
if (cityName.toLow erCase() ==
cityName[i].cityName.toLow erCase())


Now you've confused me. Do you have in your form an element with the
name "cityName" ? The expression on the left hand side makes me assume
so. In which case, you should then access it properly:

if(document.for ms["formName"].elements["cityName"].value.toLowerC ase()
== ...)

And finally, where is your script defined? The way it is at the
moment, it'll execute right away. Meaning, since it's not contained in
a function and you're waiting for a response from the user, it's
useless.


Here's where the script is defined. THis is another page:

<body>
<%
//Get portlet context object
IPortletContext portletContext =
PortletContextF actory.createPo rtletContext(re quest,response) ;
IPortletRespons e portletResponse = portletContext. getResponse();

//Get user name from incoming form, and set it into the
portletResponse
String cityName = request.getPara meter("cityName ");
if (cityName == null)
{
System.out.prin tln("FHWeather: setUserPrefs: selected cityName is
null, set default albany");
cityName = "albany";
}

System.out.prin tln("FHWeather: setUserPrefs: cityName = " +
cityName);

IPortletRequest portletRequest = portletContext. getRequest();
portletResponse .setSettingValu e(SettingType.U ser, "cityName",
cityName);

System.out.prin tln("FHWeather: setUserPrefs: cityName = " +
portletRequest. getSettingValue (SettingType.Us er, "cityName") );

portletResponse .returnToPortal ();
%>
</body>
</html>

Thanks!

Feb 9 '06 #4

Brie wrote:
Here's where the script is defined. THis is another page:
<% [snip] %>


Where is the script defined? Posting server-side script is not very
useful. Instead, you should post what the client receives.

Feb 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1409
by: allerhed | last post by:
Hi! Is there any one who has toyed around with the portlet container from jakarta-pluto(JSR-168)? I'm trying to render a known portlet ( I have the context path of the portlet as identifier) in a servlet, i dont need to create all the fancy stuff a complete portal would use. I just want to instanciate the portlet an render it from my servlet. Any one who has any code they could share or some helpful documentation or even a working sample...
2
1474
by: Eli | last post by:
Hi gurus, My question is about exchanging data on a basic HTML page between a JavaScript piece of code and a Java client-side <APPLET> residing on the same webpage. To demonstrate the idea of data encription at the client side to students my idea is to build a simple <FORM> on the webpage with 2 text fields and a submit button. The student fills in the text field on top and click Submit. At this moment, onsubmit() sends the text field...
1
1628
by: Brett | last post by:
I am writing a program that will allow a user to enter a webpage address into a form. Then it will download and display the webpage below the current one. example ---------------------------------------------------- | _____________ | | _____________enter web address | Load Button | | | -------------- | |___________________________________________________
5
2045
by: Brie_Manakul | last post by:
Is there a way in javascript to do an if else that shows a script in an iframe? Let me know if that doesn't make sense. We have a portal and in a portlet I need to grab these javascript links to display in the portlet if a user selects a certain city. Let me know if this can be done. Below is my code. Any help would be greatly appreaciated. Thanks! <%@ page language="java" import="java.util.*, java.text.* " %> <%@ page...
4
2300
by: Brie_Manakul | last post by:
I need to set up an if else to show different weather scripts based on the city selection they choose. Any help on this would be great. Thanks! <%@ page language="java" import="java.util.*, java.text.* " %> <%@ page import="com.plumtree.remote.portlet.*" %> <%@ page import="com.plumtree.remote.prc.*" %> <% String path = request.getContextPath();
0
2594
by: Mario | last post by:
Hi I have to make few portals for all departments in my company. One portal for one department. Each portal has to present information about department employees. I have written WSRP portlet, which gets data from LDAP,and shows them on portal page. I'd like to reuse this portlet in all my portals. I think that my portlet should be parametrizable. Each instance should get unique unit code, which can be set (on default, constans, string...
2
4052
by: mahesh.mohan1 | last post by:
Hi All, I am trying to deploy one of the portal applications on websphere 6.1. During the course of deployment, I get the following error: EJPPC0005E: portlet.xml validation caught a SAXException. The Message was: cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd":supported-locale,...
5
1438
by: gyip | last post by:
My environment: IE7 browser hitting an ASP.NET webpage that uses Javascript to render the contents. This is not an ASP.NET problem but a Javascript problem that I am encountering. Problem: I am basically generating a menu which is essentially a TABLE within a DIV tag using Javascript. For some reason the table is not displaying. The DIV tag essentially has the dimensions of 0. What I have done:
2
3447
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in advance for responding. I have made a stub of the codes for better understanding. Situation: I have a Java servlet (HelloWorldServlet) running on a Tomcat (5.5.26) server on a Linux machine (compiled in JDK1.4.2). It writes Javascript to construct...
0
7941
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8368
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.