RJS page.replace(_html) problems

For some time now I try to get my code working. This Monday I switched
to RJS (first with 1.0 + plugin) and yesterday to Edge Rails, so I guess
I’ve been using the most recent version.

I have a div with id=“detail” which I want to update with a partial.

If I’m using page.replace_html the content will be replaced with text,
i.e. the javascript won’t become evaluated (all RJS statements for this
action are visible, not just the one).

Using page.replace instead results in correct display, but the div tag
is lost then, so I can’t do further updates.

Quote from the changelog for actionpack:

Use Element.update(‘id’, ‘html’) instead of $(‘id’).innerHTML = ‘html’
in JavaScriptGenerator#replace_html so that script tags are evaluated.

TIA - Bernd

I had somewhat similar issue: RJS results were not evaluated but were
simply shown on the page. The reason was: I forgot to have <%=
javascript_include_tag :defaults %> in my layout or view file. Hope it
helps.

I forgot to have <%= javascript_include_tag :defaults %> in my layout or view file.

Hi Sergei,

thanks for the answer. Unfortunatly that’s not the reason. I do have the
above statement in my layout. And page.replace / page.hide work fine
(except for the fact that replace_html is eating the div id too as
described above).

I guess the problem is either related to

BTW - my prototype.js version is 1.5.0_pre0

Thanks! - Bernd

Martin Bernd S. wrote:

BTW - my prototype.js version is 1.5.0_pre0

Thanks! - Bernd

I upgraded myself to use Scriptaculous 1.5.3 (this includes upgrades to
prototype.js and other js files as well). There is an important
enhancement in there for “evalScripts” support for RJS.

http://script.aculo.us/downloads


Regards, Lori
http://blog.dragonsharp.com

Martin,

Sounds like your approach is correct… Can you post your .rjs code?
Maybe your question will become clearer if I can see the code you’re
trying to write.

Jeff

Hi Jeff,

I tried a lot of different ways. In the current version I have
eliminated the .rjs files completly and call the page methods directly
in the controller (i.e. inline). I also tried render and now
render_to_string. Here’s the current code (let me know if you need
further pieces):

controller (action):

def update_detail
@object = Class.instance_eval(params[:klazz]).find(params[:object_id])
detail = render_to_string :partial => “detail”, :object => @object
render :update do |page|
page.replace_html ‘cmpdetail’, detail
page.replace_html ‘update_reject’, link_to_action(“update_reject”,
@object)
end
end

The update_detail action feeds the detail view with an object (klazz.id)
picked from one of two lists for different classes. It also updates a
link to reject this object (here the update with replace_html works
repeatedly).

class ApplicationController < ActionController::Base
after_filter :set_charset

def set_charset
#@headers[“Content-Type”] ||= “text/html; charset=iso-8859-1”

#content_type = @headers["Content-Type"]
#@headers["Content-Type"] = "#{content_type}; charset=iso-8859-1"

content_type = @headers["Content-Type"] || 'text/html'
if /^text\//.match(content_type)
  @headers["Content-Type"] = "#{content_type}; charset=iso-8859-1"
end

end
end

As I said, the page.replace works perfect, except for consuming the div
with the id, thus preventing the whole thing from being updateable
again.

Thanks! - Bernd

All,

I am attempting connect ROR to a remote web service and I am having no
luck. Below is the WSDL from this service.

Here is the API definition:

class WeblogicTesterApi < ActionWebService::API::Base
api_method :findStringLength, :expects => [{:str => :string}],
:returns => [:int]
end

And my test controller

class WeblogicWebServiceTesterController < ApplicationController
web_client_api :weblogicTester, :soap,
http://localhost:7001/RubyWebService/com/captech/ruby/ReverseRubyWebService.jws’,
:handler_name => ‘weblogicTester’

def findStringLength
len = weblogicTester.FindStringLength(‘Ron’)
end
end

When I run, I get the following:

Processing WeblogicWebServiceTesterController#findStringLength (for
127.0.0.1 at 2006-03-22 12:51:12) [GET]

Parameters: {“action”=>“findStringLength”,
“controller”=>“weblogic_web_service_tester”}

SOAP::FaultError (

Could not resolve method with element
‘urn:ActionWebService:FindStringLength’ as top element.

):

#SOAP::Mapping::Object:0x391eaa0

And on the web service side I see the following:

<Mar 22, 2006 12:51:12 PM EST> <000000> <Returning HTTP
500 due
to SOAP fault occurring on
DispFile=com.captech.ruby.ReverseRubyWebService>

Is there any way to dump the SOAP message before it leaves so I can see
the request? any thoughts on what is going wrong?

BTW…I can get a remote web service to connect in fine to ROR, just not
the other way around…yet.

Ron

<?xml version="1.0" encoding="utf-8"?>



<s:schema elementFormDefault=“qualified”
targetNamespace=“http://www.openuri.org/
xmlns:s=“http://www.w3.org/2001/XMLSchema”>
<s:element name=“findStringLength”>
<s:complexType>
<s:sequence>
<s:element name=“str” type=“s:string” minOccurs=“0”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“findStringLengthResponse”>
<s:complexType>
<s:sequence>
<s:element name=“findStringLengthResult” type=“s:int”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“int” type=“s:int”/>
</s:schema>

I see at least part of the problem, here is the request from rails:

<env:Envelope xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>

<env:Body>

	<n1:FindStringLength 

env:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/
xmlns:n1=“urn:ActionWebService”>

		<str xsi:type="xsd:string">Ron</str>

	</n1:FindStringLength>

</env:Body>

</env:Envelope>

And here is the same request from

<SOAP-ENV:Envelope
xmlns:SOAP-ENC=“http://schemas.xmlsoap.org/soap/encoding/
xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>

<SOAP-ENV:Body>

	<FindStringLength xmlns="http://www.openuri.org/">

		<str>string</str>

	</FindStringLength>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

So for some reason ActionWebservice is putting its own namespace on the
request and it s puking on the server side. Why might it be doing that
and I can I prevent that from happening?

Ron


From: [email protected] on behalf of Ron DiFrango
Sent: Wed 3/22/2006 1:15 PM
To: [email protected]
Subject: Webserivce problems

All,

I am attempting connect ROR to a remote web service and I am having no
luck. Below is the WSDL from this service.

Here is the API definition:

class WeblogicTesterApi < ActionWebService::API::Base
api_method :findStringLength, :expects => [{:str => :string}],
:returns => [:int]
end

And my test controller

class WeblogicWebServiceTesterController < ApplicationController
web_client_api :weblogicTester, :soap,
http://localhost:7001/RubyWebService/com/captech/ruby/ReverseRubyWebService.jws’,
:handler_name => ‘weblogicTester’

def findStringLength
len = weblogicTester.FindStringLength(‘Ron’)
end
end

When I run, I get the following:

Processing WeblogicWebServiceTesterController#findStringLength (for
127.0.0.1 at 2006-03-22 12:51:12) [GET]

Parameters: {“action”=>“findStringLength”,
“controller”=>“weblogic_web_service_tester”}

SOAP::FaultError (

Could not resolve method with element
‘urn:ActionWebService:FindStringLength’ as top element.

):

#SOAP::Mapping::Object:0x391eaa0

And on the web service side I see the following:

<Mar 22, 2006 12:51:12 PM EST> <000000> <Returning HTTP
500 due
to SOAP fault occurring on
DispFile=com.captech.ruby.ReverseRubyWebService>

Is there any way to dump the SOAP message before it leaves so I can see
the request? any thoughts on what is going wrong?

BTW…I can get a remote web service to connect in fine to ROR, just not
the other way around…yet.

Ron

<?xml version="1.0" encoding="utf-8"?>



<s:schema elementFormDefault=“qualified”
targetNamespace=“http://www.openuri.org/
xmlns:s=“http://www.w3.org/2001/XMLSchema”>
<s:element name=“findStringLength”>
<s:complexType>
<s:sequence>
<s:element name=“str” type=“s:string” minOccurs=“0”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“findStringLengthResponse”>
<s:complexType>
<s:sequence>
<s:element name=“findStringLengthResult” type=“s:int”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“int” type=“s:int”/>
</s:schema>

OK, I have gotten it closer now by adding a name space declaration as
follows:

class WeblogicWebServiceTesterController < ApplicationController
web_client_api :reverseRubyWebService, :soap,
http://localhost:7001/RubyWebService/com/captech/ruby/ReverseRubyWebService.jws’,
:handler_name => ‘ReverseRubyWebService’, :namespace =>
http://www.openuri.org/

def findStringLength
len = reverseRubyWebService.FindStringLength(‘Ron’)
end
end

this produces:

<env:Envelope xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
env:Body
<n1:FindStringLength
env:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/
xmlns:n1=“http://www.openuri.org/”>
Ron
</n1:FindStringLength>
</env:Body>
</env:Envelope>

But what is missing is the n1:str why is it not adding the name space
stuff to the required elements?

Ron


From: [email protected] on behalf of Ron DiFrango
Sent: Wed 3/22/2006 1:26 PM
To: [email protected]; [email protected]
Subject: [Rails] RE: Webserivce problems

I see at least part of the problem, here is the request from rails:

<env:Envelope xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>

    <env:Body>

            <n1:FindStringLength 

env:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/
xmlns:n1=“urn:ActionWebService”>

                    <str xsi:type="xsd:string">Ron</str>

            </n1:FindStringLength>

    </env:Body>

</env:Envelope>

And here is the same request from

<SOAP-ENV:Envelope
xmlns:SOAP-ENC=“http://schemas.xmlsoap.org/soap/encoding/
xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>

    <SOAP-ENV:Body>

            <FindStringLength xmlns="http://www.openuri.org/">

                    <str>string</str>

            </FindStringLength>

    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

So for some reason ActionWebservice is putting its own namespace on the
request and it s puking on the server side. Why might it be doing that
and I can I prevent that from happening?

Ron


From: [email protected] on behalf of Ron DiFrango
Sent: Wed 3/22/2006 1:15 PM
To: [email protected]
Subject: Webserivce problems

All,

I am attempting connect ROR to a remote web service and I am having no
luck. Below is the WSDL from this service.

Here is the API definition:

class WeblogicTesterApi < ActionWebService::API::Base
api_method :findStringLength, :expects => [{:str => :string}],
:returns => [:int]
end

And my test controller

class WeblogicWebServiceTesterController < ApplicationController
web_client_api :weblogicTester, :soap,
http://localhost:7001/RubyWebService/com/captech/ruby/ReverseRubyWebService.jws’,
:handler_name => ‘weblogicTester’

def findStringLength
len = weblogicTester.FindStringLength(‘Ron’)
end
end

When I run, I get the following:

Processing WeblogicWebServiceTesterController#findStringLength (for
127.0.0.1 at 2006-03-22 12:51:12) [GET]

Parameters: {“action”=>“findStringLength”,
“controller”=>“weblogic_web_service_tester”}

SOAP::FaultError (

Could not resolve method with element
‘urn:ActionWebService:FindStringLength’ as top element.

):

#SOAP::Mapping::Object:0x391eaa0

And on the web service side I see the following:

<Mar 22, 2006 12:51:12 PM EST> <000000> <Returning HTTP
500 due
to SOAP fault occurring on
DispFile=com.captech.ruby.ReverseRubyWebService>

Is there any way to dump the SOAP message before it leaves so I can see
the request? any thoughts on what is going wrong?

BTW…I can get a remote web service to connect in fine to ROR, just not
the other way around…yet.

Ron

<?xml version="1.0" encoding="utf-8"?>



<s:schema elementFormDefault=“qualified”
targetNamespace=“http://www.openuri.org/
xmlns:s=“http://www.w3.org/2001/XMLSchema”>
<s:element name=“findStringLength”>
<s:complexType>
<s:sequence>
<s:element name=“str” type=“s:string” minOccurs=“0”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“findStringLengthResponse”>
<s:complexType>
<s:sequence>
<s:element name=“findStringLengthResult” type=“s:int”/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=“int” type=“s:int”/>
</s:schema>


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Lori O. wrote:

I upgraded myself to use Scriptaculous 1.5.3 (this includes upgrades to
prototype.js and other js files as well). There is an important
enhancement in there for “evalScripts” support for RJS.

script.aculo.us - downloads

Hi Lori,

thanks a lot. I’ll check tomorrow and post here about the result.

  • Bernd

Martin,

Are you maybe using the :update option on link_to_remote? You don’t
want to use that option with RJS templates.

On 3/22/06, Martin Bernd S. [email protected] wrote:

thanks a lot. I’ll check tomorrow and post here about the result.

  • Bernd


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Cody F.
http://www.codyfauser.com

Are you maybe using the :update option on link_to_remote? You don’t
want to use that option with RJS templates.

Hi Cody!

Thanks a lot. You saved my life. Yes, that was the problem. Or in other
words, the problem was copy & paste without understanding what’s going
on behind the curtains. That forker kept me busy for hours.

Again, thanks a lot, now I can continue coding…

  • Bernd

Don’t use web_client_api API in order to call third party web services,
instead use soap4r directly.