Hi Bob,

Thanks for your answers, they were helpful.

On Thu, Jul 2, 2009 at 2:20 AM, Bob Schellink <[email protected]> wrote:

> You can define the field as private or protected and Click won't bind it.
> You can also globally switch off autobinding in click.xml
> with autobinding="false".
>

Hmm... going private or protected, fields must be added to the model via
addModel or is there annotation to do it?


> if (getContext().getRequestAttribute("app") == null) {
>  ...
> }
>
> That should break the recursive call.
>
> Click 2.1.0 will support passing parameters to redirect:
>
> Map params = new HashMap();
> params.put("app", "default");
> setRedirect(this, params);


When I try to use 'getContext().getRequestAttribute("app")', it always
return null, which causes it to go into a redirect loop.

I worked around it with the code below (autobinding on, 2.1.0RC1, Tomcat 6):

// Redirect /context/page -> /context/page?app=default before refreshing and
rendering the page...
public class MyPage extends BorderPage {
    public String app = null;
...
public void onInit() {
                if ((app == null || app.trim().length() == 0) &&
getContext().getSession().getAttribute("app") == null) {
                        Map params = new HashMap();
                        params.put("app", "default");
                        setRedirect(this.getClass(), params);
                        return;
                } else if (app != null) {
                        getContext().getSession().setAttribute("app", app);
                }

                app = (String)
getContext().getSession().getAttribute("app");
....

Hopefully that is helpful to others

-G

Reply via email to