Redirecting & Toggle issues

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Redirecting & Toggle issues

D4Ni
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting & Toggle issues

Erik Bruchez
Administrator
Dani,

Redirection can be achieved simply with the xforms:load action.

On the toggle: XForms doesn't yet have a data-bound switch (that's
scheduled for XForms 1.2), but if what you are trying to do is show
part of the page depending on a value in the instance, you can do this
with something like this:

<xforms:group ref=".[logViz = 0]">
  ... case 1 ...
</xforms:group>
<xforms:group ref=".[logViz != 0]">
  ... case 2 ...
</xforms:group>

I hope this helps,

-Erik

On Thu, Apr 14, 2011 at 2:59 PM, D4Ni <[hidden email]> wrote:

> Hy,
>
> My name is Dani, I'm from Romania, and I'm currently working at my Licence's
> Degree which is on XForms.
> Before I'll show you my problem I want to note that I'm pretty new to XForms
> (I just started from scratch) and I'm not using Orbeon framework (I like to
> work in notepad (ConTEXT actually) because I want control to everthing i
> do), I'm using plain XForms and PHP for database interaction.
>
> My problem is with a login form. The form is complex. I use 5 types of
> users, made by selection with a select1 (no problem here).
> After I enter the information (user & password) I submit the data to a php
> and I check the database. If the credentials are wrong I return a string
> (message) to my Instance (msgViz) which is displayed as an output. Because I
> am using the replace="instance" option I can't redirect from PHP if the
> credentials are right.
>
> Is there a method to redirect using XForms?
> OR
> Is there a method to alert the user his credentials are wrong without
> returning something to the instance?
>
> The code used for this:
>
> The instance (the part for one user):
>
>
>
>
>                 vizitator
>                 vizitator
>
>
>
>
>
>
> The submission:
>
>
>
> The PHP for the wrong credentials:
>
>      $doc->getElementsByTagName("logViz")->item(0)->nodeValue = '0';
>      $doc->getElementsByTagName("pViz")->item(0)->nodeValue = '';
>      $doc->getElementsByTagName("msgViz")->item(0)->nodeValue = 'Invalid
> username or password!';
>      echo $doc->saveXML();
>      exit;
>
> The form:
>
>
>
> Vizitator:
>
>
>         Username:
>
>
>
>
>         Password:
>
>
>
>
> Login
>
>
>
>
>
>
>
>
> ----
>
> Because I didn't manage to redirect my page after I logged in, I tried to
> hide the selection and the login forms with a swith/case. The toggle works
> if I use it with an submit event, but that's not helping me because the
> credentials could be right or wrong. So my question is:
> Can a toggle be set around a value from the model instance?
>
> What I was thinking is if the logViz = 0, then I have the NotLogged case,
> and if logViz = 1, I have the Logged case. Is it possible?
>
> I've attached the whole document in xforms.rar
> I'm working at this page for a week now because of the redirection & toggle
> problems, and it's getting frustrating because my time is short. I've tried
> several solutions but nothing worked. I would really appreciate some help
> from you guys to solve this.
>
> Thanks in advance.
> http://orbeon-forms-ops-users.24843.n4.nabble.com/file/n3450828/xform.rar
> xform.rar
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Redirecting-Toggle-issues-tp3450828p3450828.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting & Toggle issues

D4Ni
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting & Toggle issues

D4Ni
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Redirecting & Toggle issues

Erik Bruchez
Administrator
In reply to this post by D4Ni
Yes you can. You need to understand a little bit how XForms events and
actions work first.

The idea: your XForms action <xforms:load> must run upon a certain
event, maybe xforms-submit-done. Then if a condition is met, run the
action. Something like:

<xforms:action ev:event="xforms-submit-done" if="condition"
resource="URL to load"/>

-Erik

On Fri, Apr 15, 2011 at 1:08 AM, D4Ni <[hidden email]> wrote:

> Thanks for such a quick response Erik:). I will try the toggle thing.
>
> About the redirection though:
>
> I want to redirect the page automatic when the credentials are right, not
> through a link or button. Can I achieve that with the xforms: load. If yes,
> how exactly? That kind of redirection I'm interested in if it exist.
>
> When I first learned about XForms, I used a tutorial from IBM, and they
> showed the login form and all, but they didn't redirect the page, instead
> they hide it. The tutorial didn't work for me as they made it. They said in
> the tutorial that XForms has mechanisms to redirect dynamic but they didn't
> specify anything... I searched about it but didn't find anything suitable.
> Am I missing something?
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Redirecting-Toggle-issues-tp3450828p3451524.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Redirecting & Toggle issues

Erik Bruchez
Administrator
In reply to this post by D4Ni
Neither do I if you don't produce an easy to reproduce example.

-Erik

On Fri, Apr 15, 2011 at 2:29 AM, D4Ni <[hidden email]> wrote:

> Also wanted to note that I tried the toggle thing how you showed me and it
> doesn't work. It didn't show me the case at all. I don't know what exactly
> I'm missing...
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Redirecting-Toggle-issues-tp3450828p3451636.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Redirecting & Toggle issues

D4Ni
In reply to this post by Erik Bruchez
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Redirecting & Toggle issues

Erik Bruchez
Administrator
Your condition is incorrect:

instance('vizInst')/viz/logViz = 1

->

instance('vizInst')/logViz= 1

That's because instance() returns the root element of the instance,
not the document node.

-Erik

On Sat, Apr 16, 2011 at 12:43 AM, D4Ni <[hidden email]> wrote:

> First of all Thanks for the respones.
>
> @Redirection:
> This is interesting. But how do the condition work? I have to use a function
> or can I use a value?
>
> <xf:instance id="vizInst">
>      <dataViz xmlns="">
>            <viz>
>                 <uViz>vizitator</uViz>
>                 <pViz>vizitator</pViz>
>                 <msgViz/>
>                 <logViz>0</logViz>
>                 <contViz/>
>           </viz>
>      </dataViz>
>      </xf:instance>
>
> I binded the logViz from the instance as a decimal.
>
> <xf:bind nodeset="instance('vizInst')/viz/logViz" type="xs:decimal" />
>
> In th PHP if the credentials are right i return logViz = 1 else logViz = 0
>
> so i made this action:
>
> <xf:action ev:event="xforms-submit-done" if="instance('vizInst')/viz/logViz
> = 1" resource="http://www.google.com"/>
>
> It is correct? Because it doesn't work. I don't know how to write the
> condition.
>
> I also tried this:
>
>  <xf:action ev:event="xforms-submit-done"
> if="instance('vizInst')/viz/.[logViz = 1]"
> resource="http://www.google.com"/>
>
> If i make the redirection I don't need the toggle to hide the form, and that
> would be great. I tried several actions to the logViz like setvalue for
> exemple, but it didn't work, i'm doing something wrong. How can I do a
> little debugging around an instance value?
>
> @Toggle:
> I have two cases(for now): NotLogged (showing the select1 and the login
> forms for each value of the select1) and Logged (showing a message)
>
> Before I wrote here i tried this:
>
> <xf:submission id="loginV" method="post" action="loginV.php"
> ref="instance('vizInst')" replace="instance" targetref="instance('vizInst')"
> />
>      <xf:action ev:observer="loginV" ev:event="xforms-submit">
>        <xf:toggle case="Logged" />
>      </xf:action>
> And it worked. But I understand now that I need a condition and the
> xforms-submit-done event maybe.
>
> After your response I tried to do this:
>
> <xf:switch>
>    <xf:case id="NotLogged">
>  <xf:group ref="instance('vizInst')/viz.[logViz = 'false']"> //or 0
>          case 1 (select1 and login forms)
>  </xf:group>
> </xf:case>
>
> <xf:case id="Logged">
>  <xf:group ref=".[logViz != 'true']"> //or 1
>  <p> You are logged </p>  //case 2
> </xf:group>
> </xf:case>
> </xf:switch>
>
> But i'm not using the toggle anymore. Just the code above. I thought the
> control of the cases are within the logViz... what am I doing wrong? I want
> to learn :).
>
> Now in the first case I have several groups beyond the big one i'm using for
> the case. Could that be the problem?
>
> The entire code (cases):
>
>
> <xf:switch>
>    <xf:case id="NotLogged">
>  <xf:group ref=".[logViz = 'false']">
>
>
> <xf:select1 ref="instance('usrInst')/user">
>   <xf:label>Alege tipul de user: </xf:label>
>
>   <xf:choices>
>      <xf:label>Drepturi normale</xf:label>
>
>      <xf:item>
>               <xf:label>Vizitator</xf:label>
>               <xf:value>1</xf:value>
>      </xf:item>
>
>      <xf:item>
>               <xf:label>Student</xf:label>
>               <xf:value>2</xf:value>
>      </xf:item>
>
>      <xf:item>
>               <xf:label>Profesor</xf:label>
>               <xf:value>3</xf:value>
>      </xf:item>
>
>      <xf:item>
>               <xf:label>Secretar</xf:label>
>               <xf:value>4</xf:value>
>      </xf:item>
>
>   </xf:choices>
>
>   <xf:choices>
>      <xf:label>Drepturi Speciale</xf:label>
>
>      <xf:item>
>               <xf:label>Administrator</xf:label>
>               <xf:value>5</xf:value>
>      </xf:item>
>
>   </xf:choices>
> </xf:select1>
>
> <br />
> <br />
>
>
>
>
> <xf:group ref="instance('vizInst')/viz">
> <fieldset class="fviz">
> <legend>Vizitator:</legend>
> <p class="inp">
> <xf:input ref="uViz">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pViz">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> <p class="inp">
> <xf:submit submission="loginV">
> <xf:label>Login</xf:label>
> </xf:submit>
> </p>
> <p>
> <xf:output class="msg" ref="msgViz" />
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('studInst')/stud">
> <fieldset class="fstud">
> <legend>Student:</legend>
> <p class="inp">
> <xf:input ref="uStud">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pStud">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('profInst')/prof">
> <fieldset class="fprof">
> <legend>Profesor:</legend>
> <p class="inp">
> <xf:input ref="uProf">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pProf">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('secInst')/sec">
> <fieldset class="fsec">
> <legend>Secretar:</legend>
> <p class="inp">
> <xf:input ref="uSec">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pSec">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('admInst')/admin">
> <fieldset class="fadm">
> <legend>Administrator:</legend>
> <p class="inp">
> <xf:input ref="uAdm">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pAdm">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
> </xf:group>
> </xf:case>
>
>
> <xf:case id="Logged">
> <xf:group ref=".[logViz != 'true']">
> <p> You are logged !!!</p>
> </xf:group> -->
> </xf:case>
> </xf:switch> -->
>
> Thanks in advance.
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Redirecting-Toggle-issues-tp3450828p3453677.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Redirecting & Toggle issues

Erik Bruchez
Administrator
In reply to this post by D4Ni
This one is not correct XPath and also would point to the wrong node:

instance('vizInst')/viz.[logViz = 'false']

Try:

instance('vizInst')[logViz = 'false']

Although it seems like logViz should compare to '0' or '1', not 'false', right?

-Erik

On Sat, Apr 16, 2011 at 12:43 AM, D4Ni <[hidden email]> wrote:

> First of all Thanks for the respones.
>
> @Redirection:
> This is interesting. But how do the condition work? I have to use a function
> or can I use a value?
>
> <xf:instance id="vizInst">
>      <dataViz xmlns="">
>            <viz>
>                 <uViz>vizitator</uViz>
>                 <pViz>vizitator</pViz>
>                 <msgViz/>
>                 <logViz>0</logViz>
>                 <contViz/>
>           </viz>
>      </dataViz>
>      </xf:instance>
>
> I binded the logViz from the instance as a decimal.
>
> <xf:bind nodeset="instance('vizInst')/viz/logViz" type="xs:decimal" />
>
> In th PHP if the credentials are right i return logViz = 1 else logViz = 0
>
> so i made this action:
>
> <xf:action ev:event="xforms-submit-done" if="instance('vizInst')/viz/logViz
> = 1" resource="http://www.google.com"/>
>
> It is correct? Because it doesn't work. I don't know how to write the
> condition.
>
> I also tried this:
>
>  <xf:action ev:event="xforms-submit-done"
> if="instance('vizInst')/viz/.[logViz = 1]"
> resource="http://www.google.com"/>
>
> If i make the redirection I don't need the toggle to hide the form, and that
> would be great. I tried several actions to the logViz like setvalue for
> exemple, but it didn't work, i'm doing something wrong. How can I do a
> little debugging around an instance value?
>
> @Toggle:
> I have two cases(for now): NotLogged (showing the select1 and the login
> forms for each value of the select1) and Logged (showing a message)
>
> Before I wrote here i tried this:
>
> <xf:submission id="loginV" method="post" action="loginV.php"
> ref="instance('vizInst')" replace="instance" targetref="instance('vizInst')"
> />
>      <xf:action ev:observer="loginV" ev:event="xforms-submit">
>        <xf:toggle case="Logged" />
>      </xf:action>
> And it worked. But I understand now that I need a condition and the
> xforms-submit-done event maybe.
>
> After your response I tried to do this:
>
> <xf:switch>
>    <xf:case id="NotLogged">
>  <xf:group ref="instance('vizInst')/viz.[logViz = 'false']"> //or 0
>          case 1 (select1 and login forms)
>  </xf:group>
> </xf:case>
>
> <xf:case id="Logged">
>  <xf:group ref=".[logViz != 'true']"> //or 1
>  <p> You are logged </p>  //case 2
> </xf:group>
> </xf:case>
> </xf:switch>
>
> But i'm not using the toggle anymore. Just the code above. I thought the
> control of the cases are within the logViz... what am I doing wrong? I want
> to learn :).
>
> Now in the first case I have several groups beyond the big one i'm using for
> the case. Could that be the problem?
>
> The entire code (cases):
>
>
> <xf:switch>
>    <xf:case id="NotLogged">
>  <xf:group ref=".[logViz = 'false']">
>
>
> <xf:select1 ref="instance('usrInst')/user">
>   <xf:label>Alege tipul de user: </xf:label>
>
>   <xf:choices>
>      <xf:label>Drepturi normale</xf:label>
>
>      <xf:item>
>               <xf:label>Vizitator</xf:label>
>               <xf:value>1</xf:value>
>      </xf:item>
>
>      <xf:item>
>               <xf:label>Student</xf:label>
>               <xf:value>2</xf:value>
>      </xf:item>
>
>      <xf:item>
>               <xf:label>Profesor</xf:label>
>               <xf:value>3</xf:value>
>      </xf:item>
>
>      <xf:item>
>               <xf:label>Secretar</xf:label>
>               <xf:value>4</xf:value>
>      </xf:item>
>
>   </xf:choices>
>
>   <xf:choices>
>      <xf:label>Drepturi Speciale</xf:label>
>
>      <xf:item>
>               <xf:label>Administrator</xf:label>
>               <xf:value>5</xf:value>
>      </xf:item>
>
>   </xf:choices>
> </xf:select1>
>
> <br />
> <br />
>
>
>
>
> <xf:group ref="instance('vizInst')/viz">
> <fieldset class="fviz">
> <legend>Vizitator:</legend>
> <p class="inp">
> <xf:input ref="uViz">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pViz">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> <p class="inp">
> <xf:submit submission="loginV">
> <xf:label>Login</xf:label>
> </xf:submit>
> </p>
> <p>
> <xf:output class="msg" ref="msgViz" />
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('studInst')/stud">
> <fieldset class="fstud">
> <legend>Student:</legend>
> <p class="inp">
> <xf:input ref="uStud">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pStud">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('profInst')/prof">
> <fieldset class="fprof">
> <legend>Profesor:</legend>
> <p class="inp">
> <xf:input ref="uProf">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pProf">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('secInst')/sec">
> <fieldset class="fsec">
> <legend>Secretar:</legend>
> <p class="inp">
> <xf:input ref="uSec">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pSec">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
>
>
>
> <xf:group ref="instance('admInst')/admin">
> <fieldset class="fadm">
> <legend>Administrator:</legend>
> <p class="inp">
> <xf:input ref="uAdm">
>         <xf:label>Username: </xf:label>
> </xf:input>
> </p>
> <p class="inp">
> <xf:secret ref="pAdm">
>         <xf:label>Password: </xf:label>
> </xf:secret>
> </p>
> </fieldset>
> </xf:group>
>
> </xf:group>
> </xf:case>
>
>
> <xf:case id="Logged">
> <xf:group ref=".[logViz != 'true']">
> <p> You are logged !!!</p>
> </xf:group> -->
> </xf:case>
> </xf:switch> -->
>
> Thanks in advance.
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Redirecting-Toggle-issues-tp3450828p3453677.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Redirecting & Toggle issues

D4Ni
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Redirecting & Toggle issues

Erik Bruchez
Administrator
Good to hear! -Erik

On Tue, Apr 19, 2011 at 1:28 AM, D4Ni <[hidden email]> wrote:

> Thanks for the response Erik and your help :).
>
> I managed to redirect my page using the count-non-empty event, and works
> good now. I've advanced do the next steps of my application. Your responses
> help me for the future, because I understand XForms logic better now.
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Redirecting-Toggle-issues-tp3450828p3459812.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws