IzPack ProcessPanel using executeclass not giving desired onSuccess/onFail behavior

StackOverflow https://stackoverflow.com/questions/15077839

  •  11-03-2022
  •  | 
  •  

Question

I'm following the IzPack documentation use case Executing a Java Class with ProcessPanel and am running into some difficulty achieving the desired behavior from the onSuccess and onFail elements and could use some clarification from someone more familar with IzPack 4.3.5.

I've defined a java condition, process.panel.condition, that I want to use to control the availability of the next and previous buttons on the process panel after the run method in my Java class has been invoked. This run method assigns true or false to the static field, ConditionBoolean, underlying the process.panel.condition condition.

My expectation is that when process.panel.condition is true, I'd like the previous button to become disabled and the next button enabled. When process.panel.condition is false, I'd like the complement to occur- previous becomes enabled and next becomes disabled.

Instead what appears to be happening is that the previous button assignment is working but the next button is always made enabled.

Can anyone point out why I'm seeing this behavior and how I should go about changing my approach to achieve my desired behavior?

Below are the xml definitions and associated Java class referenced in the executeclass element.

<conditions>
    <condition type="java" id="process.panel.condition">
        <java>
            <class>MyClass</class>
            <field>ConditionBoolean</field>
        </java>
        <returnvalue type="boolean">True</returnvalue>
    </condition>
</conditions>

Process spec xml as follows:

<processing>
    <job name="Step 1">
        <executeclass name="MyClass">
            <arg>...</arg>
        </executeclass>
    </job>
    <onFail previous="false" next="false" />
    <onSuccess condition="!process.panel.condition" previous="true" next="false" />
    <onSuccess condition="process.panel.condition" previous="false" next="true" />
</processing>

And the MyClass implementation:

import com.izforge.izpack.util.AbstractUIProcessHandler;

public class MyClasss {
    public static boolean ConditionBoolean;

    public void run(AbstractUIProcessHandler handler, String[] args) {      
        ConditionBoolean = false;

        try {
            ...

            ConditionBoolean = true;
        } catch (Throwable e) {
            handler.logOutput(e.getMessage(), false);
        }
    }
}
Was it helpful?

Solution 2

After digging through the IzPack issues, I found IzPack-238, Installation will be treated as successfull [sic] even if a process in the ProcessPanel returns a boolean value of false, which pointed out that IzPack would report success after invoking a run method with a void return type.

This issue was then patched in version 4.2.1 to allow the run method to have a boolean return value that indicates whether or not the run method completed successfully. Despite the issue being resolved back in 2009-02, the documentation refered to in the question was not updated.

After switching the return value of the run method from void to boolean, and returning the outcome, I was able to resolve my problem.

OTHER TIPS

I've never seen a non-built-in condition id to have dots. So it might be a bug with izpack, considering it still has various weird bugs. Consider changing the id to something like "processPanelCondition".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top