I am new to Boonex Dolphin and I want to get user data (userid, username, avatar and link) in javascript. How do I get this data in a javascript file? Are there any functions that provide the above data?
Use getProfileInfo(); method and passing inside parameter as user id thats it.
There is no default function to get the profile info from javascript
You've 2 options
Pass the ajax request to get the profile info
pass the userInfo into the JS page , before loading
Related
I have a simple blog site built on rails. I have a Post model and Picture model.
A Post has_many pictures and
A Picture belongs_to post
Below is what I want to achieve -
When I start to create new post, I will provide a link in the form that opens up a new window where I can upload multiple reference images with some name field as well.
Then I will use a macro string in my post body like ##IMG_<image-name>##.
I will dynamically create a new <img> tag to display relevant images, while the user is still creating the post.
My Problems -
As you know, during the time of post creation, I will not have a post_id.
Then how do I relate the reference_images being uploaded to a particular post?
Can I somehow assign a temporary-id to the post as soon as I enter create page and then after I save the post, anyway rails will takeover?
Hope you got where I am stuck. Please help!
Thanks in advance.
I appreciate all the responses you have given. But I had to achieve this is another hacky way for my needs -
HTML
I provided a <input type="file" id="refImg" onchange="javascript: uploadImage(this);">.
After the user has selected the required image, the uploadImage() funtion would create a dynamic form and do an AJAX POST to a distinct API. http://example.com/uploadImage
Rails
In rails controller referenceImages#uploadImage, I used paperclip to upload the image to cloudinary. The cloudinary upload call will return back with the image URL, if the upload is successful.
I responded with this URL in the JSON format.
JS
In javascript function uploadImage(), in the success function of ajax call, I parsed the URL from the response and dynamically created a <img src="parsed_image_url"> tag and appended it to the current cursor position of post body.
I'm creating a form which contains the fields "URL", "Title" and "Image". I'd like to update the value of title and image textboxes when user paste a URL in the first field(onkeyup). These values could come from meta tags. How can I do it? Thanks.
You could perform an ajax request to a second endpoint within your app, which sends the url that the user has entered. That endpoint would use the opengraph gem which extracts the metadata and returns it to the page as json data. That data would then be used to populate the other form fields.
I am new to struts2. I am working on the struts2 with spring application.
I developed user registration functionality. In this registration process have the 3 steps(3forms). First page is step1 contains some fields, second page is step2 contain some other fields and step3 contains some other fields.I used session map in the action class to put the all field values of all forms.After submission form in step3 it goes to call rest service and give the response.If the response is OK then i am redirecting to success page step4. In some cases if user is already exits then it gives response existed user then am redirecting to step5 page. In this page i used one message " Sorry the user is already exists" and with one link "Home Page".
I used this link <s:a id="next" href="/sample/register/user.action"> Homepage </s:a> in step5 page. After clicking on this link it goes to homepage(means step1 page) fine,but it doesn't contain user entered values. I have to maintain all field values in the step1,step2,step3 process. How to achieve this problem.
Please any one can give suggestion.
IF you are using session map to persist values being entered by the user, i believe they should be available in the session until you have not removed them from the session or session expired.more over when you do redirect a new request -response cycle started by the framework and a new value stack will be created that means all old values will be lost.
From your description i believe you are creating a wizard like functionality and if this is the case i believe struts2 provide a more elegant and flexible solution
ScopeInterceptor
This is designed to solve a few simple issues related to wizard-like functionality in Struts
Still you need to show how you trying to show the values in the form being filled by the user if something fails or when user is already exists in the system as described in your case.In this case you need to fetch object/data from the session.
I've got search form, which contains checkboxlist which is binded to my model. So when I set GET method to form I got long url:
(I even have exception:
The length of the query string for this request exceeds the configured maxQueryStringLength value.)
it's expecting, [0].IsSelected=false&[0].Id=6&[1].IsSelected=false...
But I would like url like this
www.domain.com/Action/Comma-separated-selected-idx
for example:
www.domain.com/Search/1,6,7
How can I fix,edit form get action? Thanks
I would do a POST instead, then redirect to the URL you desire.
OR
You could capture the form with some JavaScript and build the URL there.
agreed, POST or JS are your best options, I'd opt for a POST.
I have a page "Results" with a form and when "submit" is clicked, the form is submmited to another Action. So far, so good...
But, this works fine just if user is logged in. If not, he will be redirected to "Login" page and my FormCollection loses its data.
Is there a way to persist this data without using TempData??
Thanks!!
I don't think that's possible. The only thing the system remembers during the redirect to the login page is the 'return url'. No post data is saved (this could be megabytes of data...)
You can use the Session object as alternative, or make sure that the user is logged in before you post.
Or, if it's just a search result, try to live without the POST, and use a GET (which also has other advantages)
I would prefer to disallow unauthorized user to visit "Results" page or at least to show him message "Please login first" instead of the form.