You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mohammad Irfan <ir...@gawab.com> on 2004/10/19 10:20:34 UTC

Logout Cleanly

Anyone know how to logout cleanly and right? I tried to logout with this 
in tapestry :
    public void menuAction( IRequestCycle cycle )
    {
        Object parameter[] = cycle.getServiceParameters();
       
        String arg = (String) parameter[0];
       
       
        if( arg.equalsIgnoreCase("logout") )
        {
            Visit visit = (Visit)cycle.getEngine().getVisit();
           
            try {
                visit.getLoginContext().logout();
                visit.setLoginContext(null);
            } catch (LoginException e) {
                // TODO Auto-generated catch block
                _log.error("Failed Logout",e);
               
                throw new LosLoginException("Failde Logout",e);
   
            }
            visit.setAuthenticated(false);
           
            Home home = (Home) cycle.getPage("Home");
            cycle.activate(home);
        }
    }
The fact is, the application still stores the login context. Now when 
I'm going to logout, I use some brute method. I modified the logout link 
into :  <a href="?service=restart" id="logout">Logout</a>
I copied the restart from the tapestry error page. Don't know is it the 
right thing to do.




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: LinkSubmit with parameters

Posted by Norbert Sándor <pr...@hotmail.com>.
LinkSubmit just submits the form, so it doesn't have parameters like
DirectLink.
You can "pass" parameters to LinkSubmit using Hidden components for example.

Norbi

----- Original Message ----- 
From: "Andreas Vombach" <an...@psi.ch>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, October 21, 2004 8:34 AM
Subject: LinkSubmit with parameters


> Is it possible to give the LinkSubmit some user parameters like the
> Directlink component? Maybe a small example using its JavaScript portion
> would be helpul.
>
> Thanks Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


LinkSubmit with parameters

Posted by Andreas Vombach <an...@psi.ch>.
Is it possible to give the LinkSubmit some user parameters like the 
Directlink component? Maybe a small example using its JavaScript portion 
would be helpul.

Thanks Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: How do I submit without submit button

Posted by James Sherwood <js...@romulin.com>.
You could grab the value in the text field using javascript and call a
directlink with this value as the parameter.

Would not require submitting the form


James


----- Original Message ----- 
From: "Andreas Vombach" <an...@psi.ch>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, October 20, 2004 3:45 AM
Subject: How do I submit without submit button


> I would like to send the content of a TextField to the server without
> having to submit the complete form.
> If possible, it should work using the DirectLink component with
parameters.
> The problem I face is that values of TextFields are only read out by
> using a submit Button.
> Is there a way to give the actual value of a TextField to a DirectLink
> parameter? (evtl. with Javascript???)
>
> Thanks Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: How do I submit without submit button

Posted by Markus Wiederkehr <ma...@gmail.com>.
If you have no problem with JavaScript you could use the LinkSubmit
component to have a link instead of a button. That would still submit
the entire form though.

One option would be to reduce the size of the form to contain only the
TextField. If that isn't possible you could try to create a smaller
form inside the big one (I haven't tried that, don't know if it works,
probably not). The last option would be to look into the source of
LinkSubmit and create your own component that can be parameterized.

On Wed, 20 Oct 2004 08:45:36 +0200, Andreas Vombach
<an...@psi.ch> wrote:
> I would like to send the content of a TextField to the server without
> having to submit the complete form.
> If possible, it should work using the DirectLink component with parameters.
> The problem I face is that values of TextFields are only read out by
> using a submit Button.
> Is there a way to give the actual value of a TextField to a DirectLink
> parameter? (evtl. with Javascript???)
> 
> Thanks Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


How do I submit without submit button

Posted by Andreas Vombach <an...@psi.ch>.
I would like to send the content of a TextField to the server without 
having to submit the complete form.
If possible, it should work using the DirectLink component with parameters.
The problem I face is that values of TextFields are only read out by 
using a submit Button.
Is there a way to give the actual value of a TextField to a DirectLink 
parameter? (evtl. with Javascript???)

Thanks Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Component either input or text

Posted by Andreas Vombach <an...@psi.ch>.
Markus Wiederkehr wrote:

>Maybe this is what you want:
>
>CondEdit.html:
>
><span jwcid="@Conditional" condition="ognl:edit">
>  <span jwcid="textField"/>
></span>
><span jwcid="@Conditional" condition="ognl:!edit">
>  <span jwcid="insert"/>
></span>
>  
>
This is a very simple and powerful sulution, thus, I discovered my 
problem is more in the submit action.
It looks like

    <span jwcid="tablerowIDColumnValue@Block">
    <span jwcid="@CondEdit" value="ognl:components.table.tableRow.value" 
edit=ognl:(components.table.tableRow.editCol==8)/>
    <a jwcid="@DirectLink" listener="ognl:listeners.editHours" 
parameters='ognl:{components.table.tableRow.ID, 8}'>
        <img jwcid="@Image" image="ognl:assets.myIcon" alt="Edit"/>
    </a>
    </span>

It is not easy to be seen but the comparision of the actual with the 
"hard-coded" column makes the cell editable.
The DirectLink steers the edit toggeling and by pressing on the Image 
icon the edited value shall be taken from the form.
Till now getting values from Textfields is only possible with a submit 
button, I would like the DirectLink to do the submit for the edited 
value as well.
Is it possible?

Thanks Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Component either input or text

Posted by Markus Wiederkehr <ma...@gmail.com>.
Maybe this is what you want:

CondEdit.html:

<span jwcid="@Conditional" condition="ognl:edit">
  <span jwcid="textField"/>
</span>
<span jwcid="@Conditional" condition="ognl:!edit">
  <span jwcid="insert"/>
</span>

CondEdit.jwc:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">

<component-specification class="org.apache.tapestry.BaseComponent"
    allow-body="no" allow-informal-parameters="no">

  <parameter name="edit" type="boolean" required="yes" direction="in"/>
  <parameter name="value" type="java.lang.String" required="yes"/>

  <component id="textField" type="TextField">
    <inherited-binding name="value" parameter-name="value"/>
  </component>

  <component id="insert" type="Insert">
    <inherited-binding name="value" parameter-name="value"/>
  </component>
    
</component-specification>

Of course you could use a TextArea instead of the TextField and
InsertText instead of Insert... I'm not sure how to do it without the
HTML template.

hth,

Markus

On Tue, 19 Oct 2004 12:02:04 +0200, Andreas Vombach
<an...@psi.ch> wrote:
> I would like to implement a custom component which can behave either as
> input field or as normal text, depending on if it is selected for edit
> or not.
> The problem is how to back pass the edited value to the model for
> update. Using the "form" direction seems to need a AbstractFormComponent
> rather than a AbstractComponent (???) so the "auto" direction for the
> value parameter seems to be the right choice. The question is: How can
> the "newval" parameter be passed back to the data model? Or am I on the
> totally wrong way ...?
> 
> Thanks Andreas
> 
> The jwc file:
> 
> <component-specification
>     class="myEdit"
>     allow-informal-parameters="no"
>     allow-body="no">
>   <parameter name="value" direction="auto" type="java.lang.String"
> required="yes"/>
>   <parameter name="edit" direction="in" type="boolean" required="yes"/>
> </component-specification>
> 
> The java code (part)
> 
>     protected void renderComponent(IMarkupWriter writer, IRequestCycle
> cycle)
>     {
>     String value = getValue();
>     if (isEdit())
>     {
>         writer.beginEmpty("input");
>         writer.attribute("type", "text");
>         writer.attribute("name", "newval");
>         writer.attribute("value", value);
>         writer.attribute("size", 3);
>         writer.attribute("maxlength", 4);
>         renderInformalParameters(writer, cycle);
>     }
>     else
>     {
>         writer.printRaw(value);
>     }
> }

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Component either input or text

Posted by Eric R Glass/MAXIMUS <er...@maximus.com>.
Hi Andreas,

We had a need to either show an input text field (For adding a record with 
a primary key that is used as a code for other tables); or context text 
with a input hidden field (For editing a record with the primary key 
shown, but not editable).

I decided to extend the TextField component and created our own 
TextFieldHiddenConditional component.

You can do the same thing I did with several of the components that come 
with Tapestry, but I decided to put the functionality into one component.

JWC:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">

<component-specification class=
"some.domain.package.name.TextFieldHiddenConditional"
        allow-body="no" allow-informal-parameters="yes">
 
    <description>
      Implements a text input field within a Form, except when a condition 
has not
      been met, then stores the selected value in a hidden field on the 
form.
    </description>
 
    <parameter name="value" type="java.lang.String" required="yes">
            <description>
                    The property read and updated by the text input field.
            </description>
    </parameter>
 
    <parameter name="condition" type="boolean" direction="in" required=
"yes">
        <description>
            The condition to evaluate.
        </description>
    </parameter>
 
    <parameter name="invert" type="boolean" direction="in" required="no">
        <description>
                If true, inverts the condition, so that a false condition 
causes the 
                content to be included.  If false (the default), then the 
condition
                is evaluated normally.
        </description>
    </parameter>
 
    <parameter name="disabled" type="boolean" direction="in" required="no"
>
            <description>
                    If true, then the text input field will be disabled 
and any input from
            the text input field will be ignored.
            </description>
    </parameter>
 
    <parameter name="hidden" type="boolean" direction="in" required="no">
            <description>
                    If true, then the text input field will be changed to 
be a password input
            field on the form.
            </description>
    </parameter>
 
    <reserved-parameter name="type"/>
    <reserved-parameter name="value"/>
    <reserved-parameter name="name"/>
 
    <property-specification name="name" type="java.lang.String"/>
    <property-specification name="form" type="org.apache.tapestry.IForm"/>

</component-specification>

Java:

public abstract class TextFieldHiddenConditional extends TextField {

    /**
     * Called when new TextFieldHiddenConditional Object is instantiated
     */
    public TextFieldHiddenConditional() {
        super();
    }

    /**
     * Gets the condition property.
     * 
     * @return The boolean condition.
     */
    public abstract boolean getCondition();

    /**
     * Gets the invert property.
     * 
     * @return The boolean invert.
     */
    public abstract boolean getInvert();

    /**
     * @see 
org.apache.tapestry.AbstractComponent#renderComponent(org.apache.tapestry.IMarkupWriter,
     *      org.apache.tapestry.IRequestCycle)
     */
    protected void renderComponent(IMarkupWriter writer, IRequestCycle 
cycle) {
        IForm form = getForm(cycle);

        if (getCondition() != getInvert()) {
            super.renderComponent(writer, cycle);
        } else {
            String name = form.getElementId(this);

            if (!cycle.isRewinding() && !form.isRewinding()) {
                form.addHiddenValue(name, readValue());
            } else {
                updateValue(cycle.getRequestContext().getParameter(name));
            }
        }
    }
}

The ease and power of extending Tapestry is great!

I hope this helps.

Eric





Andreas Vombach <an...@psi.ch> 
10/19/2004 06:02 AM
Please respond to
"Tapestry users" <ta...@jakarta.apache.org>


To
Tapestry users <ta...@jakarta.apache.org>
cc

Subject
Component either input or text






I would like to implement a custom component which can behave either as 
input field or as normal text, depending on if it is selected for edit 
or not.
The problem is how to back pass the edited value to the model for 
update. Using the "form" direction seems to need a AbstractFormComponent 
rather than a AbstractComponent (???) so the "auto" direction for the 
value parameter seems to be the right choice. The question is: How can 
the "newval" parameter be passed back to the data model? Or am I on the 
totally wrong way ...?

Thanks Andreas


The jwc file:

<component-specification
    class="myEdit"
    allow-informal-parameters="no"
    allow-body="no">
  <parameter name="value" direction="auto" type="java.lang.String" 
required="yes"/>
  <parameter name="edit" direction="in" type="boolean" required="yes"/>
</component-specification>

The java code (part)

    protected void renderComponent(IMarkupWriter writer, IRequestCycle 
cycle)
    {
    String value = getValue();
    if (isEdit())
    {
        writer.beginEmpty("input");
        writer.attribute("type", "text");
        writer.attribute("name", "newval");
        writer.attribute("value", value);
        writer.attribute("size", 3);
        writer.attribute("maxlength", 4);
        renderInformalParameters(writer, cycle);
    }
    else
    {
        writer.printRaw(value);
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



Component either input or text

Posted by Andreas Vombach <an...@psi.ch>.
I would like to implement a custom component which can behave either as 
input field or as normal text, depending on if it is selected for edit 
or not.
The problem is how to back pass the edited value to the model for 
update. Using the "form" direction seems to need a AbstractFormComponent 
rather than a AbstractComponent (???) so the "auto" direction for the 
value parameter seems to be the right choice. The question is: How can 
the "newval" parameter be passed back to the data model? Or am I on the 
totally wrong way ...?

Thanks Andreas


The jwc file:

<component-specification
    class="myEdit"
    allow-informal-parameters="no"
    allow-body="no">
  <parameter name="value" direction="auto" type="java.lang.String" 
required="yes"/>
  <parameter name="edit" direction="in" type="boolean" required="yes"/>
</component-specification>

The java code (part)

    protected void renderComponent(IMarkupWriter writer, IRequestCycle 
cycle)
    {
    String value = getValue();
    if (isEdit())
    {
        writer.beginEmpty("input");
        writer.attribute("type", "text");
        writer.attribute("name", "newval");
        writer.attribute("value", value);
        writer.attribute("size", 3);
        writer.attribute("maxlength", 4);
        renderInformalParameters(writer, cycle);
    }
    else
    {
        writer.printRaw(value);
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Logout Cleanly

Posted by Markus Wiederkehr <ma...@gmail.com>.
Have a look at http://wiki.apache.org/jakarta-tapestry/FrequentlyAskedQuestions/LogoutLink

Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org