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

  • Home
  • SEARCH
  • 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 8139849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:57:49+00:00 2026-06-06T11:57:49+00:00

The situation is easy. I created a rules file: package org.domain.rules; dialect mvel import

  • 0

The situation is easy. I created a rules file:

package org.domain.rules;
dialect "mvel"
import eu.ohim.fsp.core.configuration.domain.xsd.Section;

global java.lang.String sectionName;

rule "rule 1"
salience 1000
when
    Section($name : nameOfTheSection)
    eval(sectionName == null)
then
    System.out.println("Section: " + $name+ "("+$name.length()+")");
    System.out.println("Section Name: " + sectionName + "("+sectionName.length()+")");
    System.out.println("Mark Details: " + sectionName.equals(null));
end

And before firing the rules I added the Section object with a valid coreName and the globals:

public void fireInserted(Section section1) {
    kstateful.insert(section1);
    kstateful.setGlobal("sectionName", new String("markudetails"));
    kstateful.fireAllRules();
}

The result is:

Section: markudetails(12)
Section Name: markudetails(12)
Mark Details: false

QUESTION: How can it be possible? in when part is null and in then part is not null!!!

  • 1 1 Answer
  • 0 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-06-06T11:57:51+00:00Added an answer on June 6, 2026 at 11:57 am

    Global vars are not a part of the knowledge base, but a separate channel to push some context into the rule execution. It is not appropriate to use them in a when clause. The exact reason why it was null in your case may be hard to trace, since rule activation is completely decoupled from rule execution. The variable may simply not be bound at when clause evaluation time, but is bound at then clause execution time.

    To summarize: don’t use globals in a when clause, that’s not what they are for.

    Your problem has an easy general solution: you can insert a configuration object into the knowledge. That object can have your desired “sectionName” property which you will then find easy to test in a when.

    As an aside, it is meaningless to test for object.equals(null) — this can never produce true. There is also no need to use new String("markudetails"). Instead use just "markudetails".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my situation: I have an application that use a configuration file. The
This is most likely not an easy one but here is the situation: I
Is there an easy way to disable Python egg caching? We have the situation
I have a situation where I'm trying to create a quick and easy admin
I can do this with linq easy but i got a situation where i
Here's my situation: I've written a simple web browser. Tabbed browsing was easy enough
Situation is simple: I post a plain HTML form with a textarea. Then, in
Situation: I'm working with Adobe Livecycle ES2 and Flex In our project we show
Situation: 1. Linux TCP server 2 Windows C# client application The server receives messages
Situation: I have an index page which loads pages into it with ajax as

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.