Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4334040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:28:29+00:00 2026-05-21T10:28:29+00:00

I create portlets and there can be many instance of a portlet on a

  • 0

I create portlets and there can be many instance of a portlet on a page, so that the functions and dom elements must be identified, AKA they must start with a particular namespace.

so that in some cases, I have to have my JS in a JSP page and cannot move it to a separate file, it is very inconvenient and hard to maintain.

a javascript in a JSP

var validator = new A.FormValidator({
        boundingBox: document.orderForm,

        validateOnBlur: true,
        validateOnInput: false,

        rules: {

            <portlet:namespace />significanceLevel: {
                digits: true                
            },

            <portlet:namespace />languageFrom: {
                required: true,
                notEqualTo: '#<portlet:namespace />languageTo'
            },

            <portlet:namespace />languageTo: {
                required: true,
                notEqualTo: '#<portlet:namespace />languageFrom'
            }
}
......

From <portlet:namespace />significanceLevel JSP generates _my_namespace_significanceLevel: .
Even if I pass myNamespace (from a JS in JSP – namespaces resolved on serverside) into a constructor, I cannot create myNamespace + ‘methodName’ in runtime

Namespace is only known on serverSide. So that one JS always has to be in a JSP page so that <portlet:namespace /> is resolved and all other JS objects have it accessible via constructor parameter for instance.

this is one workaround, but it cannot be used in many cases :

window[instance._method] = function() {
    instance.fileAddError.apply(instance, arguments);
};

where the name of _method was concatenated from string literals

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:28:30+00:00Added an answer on May 21, 2026 at 10:28 am

    It is easy to add dynamic properties to objects during runtime:

    rules[namespace + 'significanceLevel'] = {digits: true};
    

    So you could do something along the lines of:

    var namespace = <portlet:namespace />;
    var opts = {
        boundingBox: document.orderForm,
        validateOnBlur: true,
        validateOnInput: true,
        rules: {};
    };
    var addRule = function (name, rule) {
        opts.rules[namespace + name] = rule;
    }
    
    addRule('significanceLevel', {digits: true});
    addRule('languageFrom', {...});
    // etc...
    
    var validator = new A.FormValidator(opts);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can easily create Liferay portlets and themes individually using the Liferay plugin SDK.
I will be using jQuery's functionality to create portlet widgets for my web application
I am trying to create a simple portlet for Liferay 5.2.2 using Grails 1.2.1
I create my portlet with Liferay (sdk 6.1), by deploy the portlet gets some
I created a portlet that uses AJAX every function. That is, the portlet is
How to create a Html table using DOM model using Javascript? for ex: <table
I want to create simple dummy tag which can work with Struts2. I have
I'm trying to create a custom login portlet for liferay because I also need
I've got an application here that I wrote many years ago that consists of
How can I programmatically add portlet to the JBoss Portal dashboard of specific user?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.