If a field called new_something on a form of entity Stuff is changed, I'm running a check to see if there's an instance of an entity of type Thing with corresponding value on its new_something_else field. This works perfectly.
Now, the customer'd like to to smack up the found, corresponding instance on the screen as well. Is there a smooth way to do that using the value of new_something or do I have to fetch the ID of the pre-existing entity and use it with redirection of the browser?
It seems to me like an ugly and unsupported approach but perhaps that's how it's supposed to be done in 4.0 - other suggestions are welcome.
I think you will need to retrieve the ID of the other record and use that to open the other entity.
However URL addressable forms is a supported option.
Related
For a f:link show action in my fluid list template i want to pass a javascript variable to the arguments, basically the uid (to pass that specific object to the showAction), but it doesn't work the way i intend to do it. Is there a workaround for this particular problem?
The naked template looks like this:
<f:for each="{termins}" as="termin">
<tr>
<td><f:link.action action="show" arguments="{termin : termin}"> {termin.mitarbeiter}</f:link.action></td>
<td><f:link.action action="show" arguments="{termin : termin}"> {termin.kunde}</f:link.action></td>
</tr>
</f:for>
</table>
You can't - and you also can't (read: never should) generate links to controller actions from JS since it needs to generate a security checksum. Modifying the URL you create will generate a security error. The checksum exists to prevent DDOS so it has good reason.
There are two options:
You can generate all links in advance
You can make a link-generating service that you call with XHR to generate the necessary links from JS.
Only the first one is appropriate to your use case. Especially so since you want to pass UID values which always refer to an object in the database - which means you can easily generate a list of links to all possible detail views, then read/pass that list of links from your JS to select the right one.
The JS is something working after the fluid template. The right order is, your fluid template is parsed into the HTML, and then the browser render the HTML/JS/CSS to you. So, you can not expect to use JS value in your fluid template.
There are 2 possibilities:
1) Instead of a link use a form and transmit it via POST. Set a form field dynamically with JavaScript. That way your variable isn't included in the (cHash-) checksum.
2) Create an AJAX action that accepts your variable as argument. Let it generate a valid link. Use POST to call it with your variable data. Show the link on your page with JavaScript.
I am writing an application to list or update users using Javascript. I have enabled the relevant API's in dev console. This all works ok if I use AdminDirectory.Users.list, however when I try to get a single user via AdminDirectory.Users.get and pass the google ID as the key, I get Login Required.
I have tried to add option .viewType = "domain_public" but to no avail.
For now, Im going to re-write the local function that uses .get to get the user via list, but would like to know if anyone else has this problem or know how to fix it.
I ran into the same issue when I tried to write a custom function to retrieve the users in our directory. After reading Paul's comment, I checked and found that custom functions operate with same minimal permissions, so I also added a custom menu to load the users.
At risk of giving advice without testing it myself: for triggers, you'll need to use an event with an authMode value of FULL.
See the Google Apps Script Event Objects guide.
I have a simple news update interface where I read news headlines/titles from a database and print them on page as a list. The goal is, that when I click one of the headlines it brings out an area with a form where the news article could be modified and then updated back into database.
Now in order to do that I need to somehow pass the information (an id, or the headline itself) on to the form, so I can there read the proper article and other info from the database. It seems like a very simple task, but I've come to notice it seems like an impossible task. I could of course put the whole form inside a javascript function and then pass on the headline as a parameter using this.innerHTML to the function and then read it from a variable, but then I'd have to generate all the html using javascript, or php, but I think there must be a simpler way to do this.
I've tried using a hidden input tag and others like span and div elements and then pass the headline there as the input elements value using onclick="document.getElementByID("elementsname").value=this.innerHTML;" and onclick="document.getElementsByName("elementname")[0].setAttribute("value/name", this.innerHTML);". Something like this would be so simple, but for some reason unknown to me these methods don't work. Either the info doesn't get there, or it's not further readable from the elements by javascript.
For example I can pass on the info using input element when setting it to type="text" and it shows up on the page as a text field, but it's not readable from there for some reason and it doesn't even appear on the code when checking the source code from the browser. Why is this? For that reason I can't get the info passed to my SQL query, so I could read the corresponding news article in to a textarea from database.
So, is there a way to somehow make that idea to work, or should I forget it and use other methods? How is this usually done anyway by web developers when they want to open something for editing/updating from database?
This approach is usually going to be accomplished using ajax and a separate template view for the form which is populated dynamically server side.
You will have your page of news articles. When one is clicked, it will make an ajax request to your server with an identifier for the article. The server will compose a page containing a WYSIWYG editor pre-filled with the information from the article inside of a set of input elements along with a save or cancel action.
The response from the server with this template page will come in the success callback in your page of news articles which will then popup a modal type of element containing the server side produced view.
Upon completing changes if the view is saved an update is called to the relevant news article on the page, as well as posting the changes to the server.
I'm currently working on a Safari Extension to create a printable form based upon information provided within a website. A custom CSS stylesheet wouldn't be ideal, instead I was hoping that it would be possible to do the following...
If I were to have the following DIV on page called name.html
<div id="name">John</div>
Is there a way of getting the contents of #name and passing it into a text field in another page called form.html? Ideally, avoiding server side scripts?
To retrieve the element's text (as in ALL the text, subnodes included):
var value = document.getElementById('name').textContent;
Then to assigned the text to the input field in another page:
document.getElementById('myField').value = value;
Of course that doesn't work across pages. If you don't want to use server-side code for this, one simple way of doing it would be to pass the code in a query string, redirect to your form page, and retrieve the variable from the query parameters. Which sounds simpler than it actually is, as you'd need a function to add a query parameter, another one to read a query parameter, and to be sure that everything is encoded and decoded properly.
Another - bad - alternative could be to use cookies via JavaScript.
Another - better but not yet widespread - alternative could to use the WebStorage API. (see localStorage and/or sessionStorage). This will require a modern browser supporting these APIs (for instance, Google Chrome, IE9, Firefox 4, etc...)
The embedded links will provide the missing parts.
Now, this requirement may seem weird. But i would like to know how to achieve this?
I am having an HTML file, which is having few input box, check box, radio button etc. I would like to retain the changes a user [ actually i ] performs on this page. Like if the user has ticked a checkbox then next time anybody open that file should see that checkbox as ticked.
This thing can be done easily using HTTP cookies. But i don't want to use cookies.
The answer can be as simple as "No you can not do that" :)
Edit
That's the problem with not phrasing the question correctly.
I guess i can't use DB as if i will send my HTML page to someone then he/she will not be able to see my changes. I want my changes to be reflected on other systems also. [ thats the reason i was not going for cookies ]. Other solution what i was thinking was, using FileSystemObject. Any other solution ? again the answer can be "No you can not do that" :D
You could bind the change events of your form elements to an AJAX submit, log the submits to the db and then on any page load grab the latest states from the db for rendering.
Edit
If you want these changes to appear "simultaneously" for other users then you could use jQuery polling to update the page - have the page periodically poll the server for the latest state.
Having said that, if you give them a server link and not the actual file they will see your db changes.
However, it sounds like you want to actually send the file (not send someone to a web server) in which case you could do something like one of these approaches:
Your PHP/whatever file (can possibly even do this with javascript) outputs a HTML file with appropriate checked="checked", selected="selected", value="blah" etc. You send this file.
Your PHP/whatever file outputs a static reference file. Your HTML file has javascript referencing and using the values stored in this file. You send both of these files around (although value updates only require a changed static reference file).
I sounds like you want to change the actual file using Javascript - this should be rather difficult. Javascript was designed from scratch as a web scripting language and as such it doesn't have any built in file/IO functionality.
What you can do in Javascript is load ActiveX objects and plug ins. How this works depends a lot on which browser you're using. For instance in IE you could load an ActiveX object (written in VB or whatever) that could edit your file:
var fileWriter = new ActiveXObject("My.FileWriter");
fileWriter.Update("myFile.htm", "inputName", "newValue");
You'd have to write your FileWriter utility though.
Alternatively you could use HTML5's new data storage stuff - but then you're still limited on browser.
You need some method to identify the user when he or she visits again. A browser cookie is useful, because it is stored on the user's computer, which serves as identification. The other serious option is to store the user's preferences in a database. This would, at least, require a server-side language. In addition, you need some way to identify the user, such as username, or, less reliably, IP address.
I hear other options may exist in HTML5, but I don't think those can be used seriously at this time. You can read about it here in Offline Web Applications. It seems to me like something very similar in spirit, although much more powerful, than cookies.