Redirect to another page

20 views
Skip to first unread message

Anders Persson

unread,
Mar 19, 2014, 9:52:09 AM3/19/14
to eiffel-web...@googlegroups.com
Hi

I have a situation when I want to redirect to a certain page. When using the widget implementation I have created a BASE_PAGE.
.
deferred class
BASE_PAGE

inherit

WSF_PAGE_CONTROL
redefine
control,
initialize_controls
end

control: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]


When I detect that I should redirect to another page I have tried two different approaches:

1.

redirect_to_start_page()
local
redir : WSF_HTML_REDIRECTION_RESPONSE
do
create redir.make ("/")
response.send (redir)
end


2.

redirect_to_start_page()
do
  control.redirect ("/")
end


The first approach is not compatible with the widget implementation. I get some precondition errors but the redirection works.

The second alternative is not enough to make the page be redirected. I can not find how to actually trigger the redirection to the page.


Regards

Anders

javier hector

unread,
Mar 19, 2014, 10:10:16 AM3/19/14
to eiffel-web...@googlegroups.com
You can also do something like 


compute_response_redirect (req: WSF_REQUEST; res: WSF_RESPONSE; a_location: READABLE_STRING_32)
-- Redirect to `a_location'
                local
h: HTTP_HEADER
do
create h.make
h.put_content_type_text_html
h.put_current_date
h.put_location (a_location)
res.set_status_code ({HTTP_STATUS_CODE}.see_other)
res.put_header_text (h.string)
end

/Javier


--
--
You received this message because you are subscribed to the Google
Groups "Eiffel Web Framework" group.
 
To post to this group, send email to
eiffel-web...@googlegroups.com
To unsubscribe from this group, send email to
eiffel-web-frame...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/eiffel-web-framework
 
See the site for the Eiffel-Web-Framework project at
https://github.com/EiffelWebFramework/EWF
---
You received this message because you are subscribed to the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-web-frame...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anders Persson

unread,
Mar 19, 2014, 11:05:47 AM3/19/14
to eiffel-web...@googlegroups.com
Hi

I tried that and I get same behaviour as with 

control.redirect ("/")

Might be that another header is added by the framework. In the case that works I send the respons directly but then the problem is that the framework tries to respond one more time and I get some precondition errors 

Regards

Anders

javier hector

unread,
Mar 19, 2014, 11:25:11 AM3/19/14
to eiffel-web...@googlegroups.com
Hi
Can you check what you get using http://www.getpostman.com/?
or Fiddler?

/Javier

Anders Persson

unread,
Mar 19, 2014, 11:40:34 AM3/19/14
to eiffel-web...@googlegroups.com

I do that later. 

Anders

Anders Persson

unread,
Aug 22, 2014, 5:19:02 AM8/22/14
to eiffel-web...@googlegroups.com

Hi

I redesigned so that I check earlier If I should redirect. After the check I decide which page to send to the browser. Earlier I Started with the expected page and when I found a reason to redirect I did that. I guess the concequense was that the system tried to complete the first page but the status was corrupted due to my redirect

Anders

Den 19 mar 2014 16:25 skrev "javier hector" <javier...@gmail.com>:

Jocelyn Fiat

unread,
Aug 25, 2014, 9:52:30 AM8/25/14
to eiffel-web-framework
Hi Anders,

Was it a user usage issue, or something that could be improved in EWF?
note that I think I experienced in the past that sometime it works better with absolute URL, rather than just "/", I think that depended of the browser (you can use WSF_REQUEST.absolute_script_url ("/")  to help building the absolute url).

-- Jocelyn
Jocelyn
------------------------------------------------------------------------
Eiffel Software
805-685-1006
http://www.eiffel.com
Customer support: http://support.eiffel.com
User group: http://groups.eiffel.com/join
------------------------------------------------------------------------

Anders Persson

unread,
Aug 25, 2014, 12:15:58 PM8/25/14
to eiffel-web...@googlegroups.com
I think it was how I used it. But a problem could be that if I find an error when executing a page I do not know how to handle it. I guess at the moment I would initially ignore the problem and send the page anyway with some information and ask the user to click a link to proceed. 

It is more about error handling maybe. One need to wright well structured code.

Anders
Reply all
Reply to author
Forward
0 new messages