How to get the value of hidden field with xquery in Marklogic? [closed] - xquery

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a hidden field in a xqy page. Now I want to get its value in the same page through xquery code. The page is not refreshing. I do not want to use javascript. Is there any way to get the value of the hidden field with xquery without submitting the page.

Instead of simple HTML and outputting it directly you could use XForms. Some extensive documentation about XForms is available at http://en.wikibooks.org/wiki/XForms
You can then use a XForms-Processor (e.g. XSLTForms or betterForms), which can be used server- and client-side. This allows you to get the value of any fields (not just hidden fields) with pure X-technologies. XForms also includes MVC by default, which is quite nice. However, depending on your project and the amount of code already existing you might have to change a lot, as it is a complete technology. But normally this is the way to go to avoid JavaScript and instead using X*

You would need XQuery capabilities within the browser. MarkLogic runs server-side, so needs a round-trip (e.g. a submit). But you could have a look at XQiB: http://www.xqib.org/
HTH!

This question is vague enough to be interpreted several different ways: you will get better answers if you ask better questions.
But I'll be a little more optimistic than Geert. If the form field is in an HTML form built by a server XQuery module, the data for it must be available to that module while it is building the form. Arrange your code so that you can use it for whatever is needed, before returning the completed page.
You might be looking for some magical way to write XPath against the half-complete results of the query that's actually running. That isn't possible without some work on your part. You could arrange your code so that the form or the hidden field is a node returned by some other function, and write XPath relative to it to retrieve its value. If the hidden field was built using a request parameter from the previous HTTP request, you could call xdmp:get-request-field again. The point is to arrange your code so that you have the data you need it, when you need it.
The XQuery code at https://github.com/mblakele/cq might have some useful examples. It plays all sorts of games with form fields, both with and without JavaScript.

Related

sitecore, setting language based on country or keyboard [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
How can I set the default language based on Country and/or keyboard using the sitecore framework?
I take your point that you would expect an out of the box solution, but in fact the requirements are often perculiar to the project. That said, here are some thoughts
Creating a custom language resolver is probably the best approach.
First Attempt
I normally start by trying to use the the browser language preferences (HttpRequest.UserLanguages), which might supply the whole 2-part language 'en-GB', or sometimes just the basic language 'en'.
If this gave you the whole language, then your're done. Just get the system language with the with the same name.
If it gave you the basic language only, you need to get the country somehow.
If it didn't give you anything. You need to get the country, and find a default language for that country.
Getting the Country
If you go with the MaxMind option, you should probably use the the GeoLite version locally, as you can't rely on the DMS Geo IP lookup being performed in a timely manner.
If the lookup is successful, and you already had a basic language then you should now have 2-part language to compare against your system languages.
If the lookup was successful, but you don't have basic language, then you need to get a default. In the past, I have created a 'Language Mapping' template with 2 fields. A 'Country code' text field, and a 'Language' droplink source to the list of system language. When you have obtained the country code, you simply look it up in your mapping items, and set the context language accordingly.
Some things to consider
Remember you need to have some sort of fallback for when the lookups haven't worked.
Perhaps store the language as a cookie, so the lookup is not done every time.

PDF Form Generation [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have an ASP.NET 4.0 Web Application that needs to create application forms for insurance. Basically, the program loads a PDF Template, populates the form fields, then flattens and closes the PDF. The templates are small when I create them from Word (about 156k for 5 pages) but each form field added to the template via Adobe Acrobat adds about 5-10k to the overall file size. Unfortunately, these pages have a whole lot of form fields (200+), and the end result tends to be about half a MB to a 1 MB per page.
Can anyone suggest an alternate application, usable dynamically from an ASP.NET webpage, that can do a similar job but maintain a smaller file size? It doesn't need to be a free component, but it does need to have a way for me to create a template from a word document but not use Office automation to populate the word doc and save as PDF. My preference would also be that it deal with streams and not files, but that is a minor consideration for me in the circumstances.
Take a look at ABCpdf, I'm pretty sure it can handle what you're looking for
It might be worth looking at Docmosis. You can use word documents as templates to populate and produce PDF and other outputs. Because of the way it works, the document size will not "explode" as you have indicated is a problem with a large number of fields with your current scenario. ASP.NET can invoke Docmosis in various ways depending on your application's runtime environment. Docmosis offers online web-services which have minimal footprint/requirements for an application environment as well as downloadable and embeddable options. It is commercial (I work for the company that created it) and has no Office Automation requirements.
Hope that helps.
You might try Docotic.Pdf library for this.
The library can be used to fill existing fields from code or by importing FDF files.
The library can not flatten form fields but you can make fields read-only or protect the whole document from changes with permissions.
Here are some sample that might be useful:
Fill existing form
Import FDF data
Find control by name
Permissions
Disclaimer: I work for the vendor of the library.

What is the difference between GET and POST methods? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
When do you use POST and when do you use GET?
I know the basic difference between GET and POST methods. That is we can see the URL parameters in case of GET and can't see the URL parameters in case of POST. Of course we can pass huge amounts of data by POST which is not possible through GET.
Are there any other differences between these two methods ?
GET is for data retrieval only. You can refine what you are getting but it is a read only setup and yes, as you mentioned anything used for refinement are part of the URL.
POST is meant for sending data, but is generally a way to 'break' the simple workings of HTML because you are neither guaranteed of anything that is happening, it can just fetch data, send data or delete data.
There are also PUT and DELETE in the HTML standards, but its all about finding web servers that support these actions as well. As the names imply PUT sends data for either the creation or updating while DELETE is for removal of data.
Enjoy! :)
Other implementation differences in GET and POST:
they have different encoding schemes. multipart/form-data is for POST only
the result of POST may not result in an actual page.
url limit necessitates use of POST
If you are using HIDDEN inputs in form then submitting a GET request reveals those inputs

How to create a small form that pull data out of a database in Drupal [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I created a content type for some Quizz on my site, and now I'd like to create a basic form (only available to admins) to pull some stats on them.
The fields used for the quizz are name, start date, end date and correct answer. Each of these fields should be a searchable criteria in the form, and return a list of quizz. There should also be a relationship with the user table to display a list of those who answered the quizz.
Later I'm gonna need an option to extract the data in excel, but let's focus on the form first.
The version i'm using is Drupal6 and please take in consideration that I'm still pretty new to Drupal.
How can I do this?
I imagine you are using CCK for the 'quiz' content type?
If you are, then the best way to 'mash' this data up with getting overly complex is to use Views. You can think of views as an interactive SQL query builder.
You can create pages, blocks or even RSS feeds from the output of Views.
Module Forena seems like a valid alternative to consider. For more details about Forena, 2 types of documentation are available:
Community documentation.
Documentation that comes with Forena, which you can access right after install and enable of the module. Checkout the demo site for an online example of the current:
Forena documentation - use the link 'Reporting documentation' or visit relative link /reports/help.
Forena samples - use the link 'Reporting samples' or visit relative link /reports/samples (these samples are fully functional, so make sure to experiment a bit with it, such as the drill downs available on the SVG Graph sample).
The newest 7.x-4.x version also includes an amazing (I think) UI for either creating your reports (the WYSIWYG report editor) and/or for creating your SQL queries (the Query Builder).
Be aware: I'm a co-maintainer of Forena.

Good pattern or technique for webforms with 100s of fields [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
At my job, I have to implement web forms for loan applications with sometimes up to a hundred different input fields, and then save the application into the database for later retrieval.
The person whom I replaced created a sql table with 100s of columns where each row represents a loan application and there is a column for every field.
The problem with this is that I find myself having to type out the 100 fields a bunch of times, getting data from form, saving to database, retrieving from database, writing to output webform.
And then whenever there is a change to the application, I have to make the change in quite a few places.
So it can not only be cumbersome but error prone.
Is there a good design pattern that handles this?
See if you can come up with a better table design. 100 Cols is just too much IMO. If not you could use dynamic data. Also look for a better UI pattern or break it into more than 1 pages, looking at 100 fields to fill in could be over whelming for the users.
Code generation is the best bet. MyGeneration and CodeSmith are two very good tools.
I've had very similar projects and I used both generation tools and prefer CodeSmith.
100's of fields in a form is too many. Try to aim for max 20 per page.
If you can, try to isolate each part of this form into a separate page, and even better, into a wizard of some kind.
e.g. (example steps)
Step 1: Client Profile (name, age, SSN, etc.)
Step 2: Loan Data (Fixed, Variable, Amount, Terms, Special Deals...)
Step 3: Credit Check?, Pre-Approval?
Step 4: Variations/Calculations...
If you organize the data in structured groups, you should be able to make each portion work independently (e.g. you can input basic loan data, and get some preliminary numbers without needing to enter client data (yet).
More importantly, if the user enters a value in one of the 100 fields that causes the backend to not store (e.g. value out of range) what happens? does the user lose all the data they entered? - for usability make sure that nothing is lost when the user attempts to save/move to the next step.
Perhaps ASP.NET Dynamic Data would work for you. It is described as "a framework that enables you to quickly build a functional data-driven application"
I've worked with these loan applications before and I'll tell you straight out that your data model is broken. Are you gonna make a new row in the BigTable when a borrower comes in for a refi? What if the deal falls through but they want to try again for a different house? If you just edit the data in the row for that application then you're losing valuable metrics on your % of closed deals.
First, fix your data model. Then, embrace LINQ if at all possible.
With respect to the UI, I'd either do it as a wizard (which is pretty close to how these apps are filled out) or build it as one big form that the user scrolls through and adds stuff to (use AJAX in each section so that the user can save as they go along).
You also need to consider off the shelf solutions for this stuff. Don't reinvent the wheel here; these loan apps don't change often enough to throw a full time developer at them.
Edit: Sorry I was assuming that this was for residential mortgages. I don't know if that's true, but I still think your data model is broken. If you have the ability to change it you should.
Design pattern? But of course: The Adaptive Object-Model.
One thing that you can do is programmatically take the column names and put them on a file in the format you need. That will be to solve your immediate pain. Below is a piece of c# code that will get the column name from a oledbreader object.
internal List<string> GetFieldList(string sTableName)
{
tableName = sTableName;
BuildQuery("*");
command = SetupConnection();
List<string> FieldList = new List<string>();
OleDbDataReader reader = command.ExecuteReader();
for (int i = 0; i < reader.FieldCount; i++)
FieldList.Add(reader.GetName(i).ToString());
return FieldList;
}
To solve the situation in the long run, you probably want to do store procedures or functions with the fields as parameteres. you still have to put the values in each of the parameters, but is going to easy the management of each
he problem with this is that I find myself having to type out the 100 fields a bunch of times, getting data from form, saving to database, retrieving from database, writing to output webform.
hope it helps!!!
Ouch.
Is LINQ available to you? What version of .NET are we talking about here?
BTW, if it isn't obvious already, from a GUI perspective I suggest you hide most of these fields from the end user and reveal them in sections as the user progresses, which has the advantage that you can avoid showing what doesn't need to be and validate as you go.
And with some sort of progress indicator so they know there's an end in site (ha ha).
I've had issues like this before, and know there may be valid reasons for having so many columns. It's rare, but it can happen.
What you might want to do, is create a partial class in it's own file which contains all the data field code. This might be fields, properties, and possibly method parameters, and/or just your CRUD functionality. And generate that partial class, this will help ease your future maintanence.
Good Luck.

Resources