tags:

views:

238

answers:

1

Hello

I can't find any resources which can answer why I'm getting an error with this:

oncomplete="#{MyBacking.oError ? #{rich:component('oErrorPanel')}.show() : return false;}"

in a richfaces a4j:commandButton. oError is referring to a method in my bean called isOError.

I'm getting the error

SEVERE: Servlet.service() for servlet Faces Servlet threw exception
org.apache.el.parser.ParseException: Encountered " "?" "? "" at line 1, column 30.
Was expecting one of:
    "}" ...
    "." ...
...

I want to say 'if a method returns true, show modal panel A otherwise false'. Any help much appreciated.

EDIT I've edited the code so it looks as follows:

                        <a4j:region id="Cont">
                        <a4j:form name="Form">
                            <h:panelGrid columns="2" style="padding: 2px;">

                                <h:outputText value="Old password&#160;" />
                                <h:inputSecret id="FormOldP" value="#{MyBacking.dbOldPwd}" />

                                <h:outputText value="New password&#160;" />
                                <h:inputSecret id="FormNewP0" value="#{MyBacking.dbNewPwd0}" />

                                <h:outputText value="Re-enter new password&#160;" />
                                <h:inputSecret id="FormNewP1" value="#{MyBacking.dbNewPwd1}" />

                                <h:panelGroup>
                                    <a4j:commandButton value="Submit"
                                        action="#{MyBacking.dbPwdChange}"
                                        data="#{MyBacking.oldDbPwdError}"
                                        oncomplete="if(data == true) { rich:component('OldErrorPanel').show(); }"
                                        image="/img/btnSubmit16.png"
                                        reRender="sysMsg,FormCont" />

                                    <a4j:commandButton value="Cancel"
                                        onclick="#{rich:component('MyPanel')}.hide();return false;" />
                                </h:panelGroup>
                            </h:panelGrid>
                        </a4j:form>
                    </a4j:region>

This compiles fine, but even if the boolean is set to true (when old passwd is not as the one stored) panel MyPanel remains on screen but the error modal OldErrorPanel doesn't appear. The above looks ok to me though. This is the java:

public void setOldDbPwdError(boolean b) {
    logger.info("setting ldDbPwdErro to "+b);
    oldDbPwdError = b;
}

public boolean isOldDbPwdError() {
    logger.info("asking for isOldDbPwdError, returning" +oldDbPwdError);
    return oldDbPwdError;
}

Any further advice greatly appreciated.

+2  A: 

Your expression is invalid. You are opening another expression from within your expression (the #{})

If it was valid it would look like : oncomplete="#{MyBacking.oError ? rich:component('oErrorPanel').show() : ''}"

However I don't think that this addresses your problem as you would have to reRender the button itself to get the value of oError (remember that JSF is all rendered to HTML/Javascript for the page)

I would use the data attribute on the commandButton like this:

<a:commandButton
  id="Bgo"
  action="#{MyBacking.someAction}"
  value="Submit"
  data="#{MyBacking.oError}"
  oncomplete="if(data == true) { rich:component('oErrorPanel').show(); }"/>

Have a read of the Richfaces manual particularly around Javascript Interactions.

UPDATE: in response to updated question. Try reRendering the value of what you use for the data somewhere else on your page to check the value. Eg:

<h:outputText id="reRenderMe" value="#{MyBacking.oError}"/>
Damo
@DAmo, thanks for the response - please see my updated question.
Mark Lewis
I found that actually last night after I updated my question, but you've beaten me to it - thanks very much for your work.
Mark Lewis